void printCOFFExports() override;
void printCOFFDirectives() override;
void printCOFFBaseReloc() override;
+ void printCodeViewDebugInfo() override;
void printStackMap() const override;
private:
void printSymbol(const SymbolRef &Sym);
void printBaseOfDataField(const pe32_header *Hdr);
void printBaseOfDataField(const pe32plus_header *Hdr);
- void printCodeViewDebugInfo(const SectionRef &Section);
+ void printCodeViewSection(const SectionRef &Section);
void printCodeViewSymbolsSubsection(StringRef Subsection,
const SectionRef &Section,
static const EnumEntry<COFF::SectionCharacteristics>
ImageSectionCharacteristics[] = {
+ LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_SCN_TYPE_NOLOAD ),
LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_SCN_TYPE_NO_PAD ),
LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_SCN_CNT_CODE ),
LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_SCN_CNT_INITIALIZED_DATA ),
void COFFDumper::printBaseOfDataField(const pe32plus_header *) {}
-void COFFDumper::printCodeViewDebugInfo(const SectionRef &Section) {
+void COFFDumper::printCodeViewDebugInfo() {
+ for (const SectionRef &S : Obj->sections()) {
+ StringRef SecName;
+ error(S.getName(SecName));
+ if (SecName == ".debug$S")
+ printCodeViewSection(S);
+ }
+}
+
+void COFFDumper::printCodeViewSection(const SectionRef &Section) {
StringRef Data;
error(Section.getContents(Data));
switch (SubSectionType) {
case COFF::DEBUG_SYMBOL_SUBSECTION:
- if (opts::SectionSymbols)
- printCodeViewSymbolsSubsection(Contents, Section, Offset);
+ printCodeViewSymbolsSubsection(Contents, Section, Offset);
break;
case COFF::DEBUG_LINE_TABLE_SUBSECTION: {
// Holds a PC to file:line table. Some data to parse this subsection is
return;
}
- StringRef FunctionName;
+ StringRef LinkageName;
error(resolveSymbolName(Obj->getCOFFSection(Section), Offset,
- FunctionName));
- W.printString("FunctionName", FunctionName);
- if (FunctionLineTables.count(FunctionName) != 0) {
+ LinkageName));
+ W.printString("LinkageName", LinkageName);
+ if (FunctionLineTables.count(LinkageName) != 0) {
// Saw debug info for this function already?
error(object_error::parse_failed);
return;
}
- FunctionLineTables[FunctionName] = Contents;
- FunctionNames.push_back(FunctionName);
+ FunctionLineTables[LinkageName] = Contents;
+ FunctionNames.push_back(LinkageName);
break;
}
case COFF::DEBUG_STRING_TABLE_SUBSECTION:
for (unsigned I = 0, E = FunctionNames.size(); I != E; ++I) {
StringRef Name = FunctionNames[I];
ListScope S(W, "FunctionLineTable");
- W.printString("FunctionName", Name);
+ W.printString("LinkageName", Name);
DataExtractor DE(FunctionLineTables[Name], true, 4);
uint32_t Offset = 6; // Skip relocations.
// in the line table. The filename string is accessed using double
// indirection to the string table subsection using the index subsection.
uint32_t OffsetInIndex = DE.getU32(&Offset),
- SegmentLength = DE.getU32(&Offset),
+ NumLines = DE.getU32(&Offset),
FullSegmentSize = DE.getU32(&Offset);
+ uint32_t ColumnOffset = Offset + 8 * NumLines;
+ DataExtractor ColumnDE(DE.getData(), true, 4);
+
if (FullSegmentSize !=
- 12 + 8 * SegmentLength +
- (HasColumnInformation ? 4 * SegmentLength : 0)) {
+ 12 + 8 * NumLines + (HasColumnInformation ? 4 * NumLines : 0)) {
error(object_error::parse_failed);
return;
}
StringRef Filename(CVStringTable.data() + FilenameOffset);
ListScope S(W, "FilenameSegment");
W.printString("Filename", Filename);
- for (unsigned J = 0; J != SegmentLength && DE.isValidOffset(Offset);
- ++J) {
+ for (unsigned LineIdx = 0;
+ LineIdx != NumLines && DE.isValidOffset(Offset); ++LineIdx) {
// Then go the (PC, LineNumber) pairs. The line number is stored in the
// least significant 31 bits of the respective word in the table.
- uint32_t PC = DE.getU32(&Offset),
- LineNumber = DE.getU32(&Offset) & 0x7fffffff;
+ uint32_t PC = DE.getU32(&Offset), LineData = DE.getU32(&Offset);
if (PC >= FunctionSize) {
error(object_error::parse_failed);
return;
}
char Buffer[32];
format("+0x%X", PC).snprint(Buffer, 32);
- W.printNumber(Buffer, LineNumber);
- }
- if (HasColumnInformation) {
- for (unsigned J = 0; J != SegmentLength && DE.isValidOffset(Offset);
- ++J) {
- uint16_t ColStart = DE.getU16(&Offset);
+ ListScope PCScope(W, Buffer);
+ uint32_t LineNumberStart = LineData & COFF::CVL_MaxLineNumber;
+ uint32_t LineNumberEndDelta =
+ (LineData >> COFF::CVL_LineNumberStartBits) &
+ COFF::CVL_LineNumberEndDeltaMask;
+ bool IsStatement = LineData & COFF::CVL_IsStatement;
+ W.printNumber("LineNumberStart", LineNumberStart);
+ W.printNumber("LineNumberEndDelta", LineNumberEndDelta);
+ W.printBoolean("IsStatement", IsStatement);
+ if (HasColumnInformation &&
+ ColumnDE.isValidOffsetForDataOfSize(ColumnOffset, 4)) {
+ uint16_t ColStart = ColumnDE.getU16(&ColumnOffset);
W.printNumber("ColStart", ColStart);
- uint16_t ColEnd = DE.getU16(&Offset);
+ uint16_t ColEnd = ColumnDE.getU16(&ColumnOffset);
W.printNumber("ColEnd", ColEnd);
}
}
+ // Skip over the column data.
+ if (HasColumnInformation) {
+ for (unsigned LineIdx = 0;
+ LineIdx != NumLines && DE.isValidOffset(Offset); ++LineIdx) {
+ DE.getU32(&Offset);
+ }
+ }
}
}
}
}
}
- if (Name == ".debug$S" && opts::CodeView)
- printCodeViewDebugInfo(Sec);
-
if (opts::SectionData &&
!(Section->Characteristics & COFF::IMAGE_SCN_CNT_UNINITIALIZED_DATA)) {
StringRef Data;