Index: include/llvm/Support/COFF.h =================================================================== --- include/llvm/Support/COFF.h +++ include/llvm/Support/COFF.h @@ -664,16 +664,16 @@ } }; - enum CodeViewLineTableIdentifiers { - DEBUG_SECTION_MAGIC = 0x4, - DEBUG_SYMBOL_SUBSECTION = 0xF1, - DEBUG_LINE_TABLE_SUBSECTION = 0xF2, + enum CodeViewIdentifiers { + DEBUG_SECTION_MAGIC = 0x4, + DEBUG_SYMBOL_SUBSECTION = 0xF1, + DEBUG_LINE_TABLE_SUBSECTION = 0xF2, DEBUG_STRING_TABLE_SUBSECTION = 0xF3, - DEBUG_INDEX_SUBSECTION = 0xF4, + DEBUG_INDEX_SUBSECTION = 0xF4, // Symbol subsections are split into records of different types. DEBUG_SYMBOL_TYPE_PROC_START = 0x1147, - DEBUG_SYMBOL_TYPE_PROC_END = 0x114F + DEBUG_SYMBOL_TYPE_PROC_END = 0x114F }; inline bool isReservedSectionNumber(int32_t SectionNumber) { Index: test/tools/llvm-readobj/codeview-linetables.test =================================================================== --- test/tools/llvm-readobj/codeview-linetables.test +++ test/tools/llvm-readobj/codeview-linetables.test @@ -18,16 +18,16 @@ ; z(); ; } ; using 32-/64-bit versions of CL v17.00.61030 and v18.00.21005.1 respectively. -RUN: llvm-readobj -s -codeview-linetables %p/Inputs/multifunction-linetables.obj.coff-2012-i368 \ +RUN: llvm-readobj -s -codeview %p/Inputs/multifunction-linetables.obj.coff-2012-i368 \ RUN: | FileCheck %s -check-prefix MFUN32 -RUN: llvm-readobj -s -codeview-linetables %p/Inputs/multifunction-linetables.obj.coff-2013-i368 \ +RUN: llvm-readobj -s -codeview %p/Inputs/multifunction-linetables.obj.coff-2013-i368 \ RUN: | FileCheck %s -check-prefix MFUN32 -RUN: llvm-readobj -s -codeview-linetables %p/Inputs/multifunction-linetables.obj.coff-2012-x86_64 \ +RUN: llvm-readobj -s -codeview %p/Inputs/multifunction-linetables.obj.coff-2012-x86_64 \ RUN: | FileCheck %s -check-prefix MFUN64 -RUN: llvm-readobj -s -codeview-linetables %p/Inputs/multifunction-linetables.obj.coff-2013-x86_64 \ +RUN: llvm-readobj -s -codeview %p/Inputs/multifunction-linetables.obj.coff-2013-x86_64 \ RUN: | FileCheck %s -check-prefix MFUN64 -MFUN32: CodeViewLineTables [ +MFUN32: CodeViewDebugInfo [ MFUN32-NEXT: Magic: 0x4 MFUN32-NEXT: Subsection [ MFUN32-NEXT: Type: 0xF1 @@ -136,7 +136,7 @@ MFUN32-NEXT: ] MFUN32-NEXT: ] -MFUN64: CodeViewLineTables [ +MFUN64: CodeViewDebugInfo [ MFUN64-NEXT: Magic: 0x4 MFUN64-NEXT: Subsection [ MFUN64-NEXT: Type: 0xF1 @@ -248,16 +248,16 @@ ; g(); ; } ; using 32-/64-bit versions of CL v17.00.61030 and v18.00.21005.1 respectively. -RUN: llvm-readobj -s -codeview-linetables %p/Inputs/multifile-linetables.obj.coff-2012-i368 \ +RUN: llvm-readobj -s -codeview %p/Inputs/multifile-linetables.obj.coff-2012-i368 \ RUN: | FileCheck %s -check-prefix MFILE32 -RUN: llvm-readobj -s -codeview-linetables %p/Inputs/multifile-linetables.obj.coff-2013-i368 \ +RUN: llvm-readobj -s -codeview %p/Inputs/multifile-linetables.obj.coff-2013-i368 \ RUN: | FileCheck %s -check-prefix MFILE32 -RUN: llvm-readobj -s -codeview-linetables %p/Inputs/multifile-linetables.obj.coff-2012-x86_64 \ +RUN: llvm-readobj -s -codeview %p/Inputs/multifile-linetables.obj.coff-2012-x86_64 \ RUN: | FileCheck %s -check-prefix MFILE64 -RUN: llvm-readobj -s -codeview-linetables %p/Inputs/multifile-linetables.obj.coff-2013-x86_64 \ +RUN: llvm-readobj -s -codeview %p/Inputs/multifile-linetables.obj.coff-2013-x86_64 \ RUN: | FileCheck %s -check-prefix MFILE64 -MFILE32: CodeViewLineTables [ +MFILE32: CodeViewDebugInfo [ MFILE32-NEXT: Magic: 0x4 MFILE32-NEXT: Subsection [ MFILE32-NEXT: Type: 0xF1 @@ -317,7 +317,7 @@ MFILE32-NEXT: ] MFILE32-NEXT: ] -MFILE64: CodeViewLineTables [ +MFILE64: CodeViewDebugInfo [ MFILE64-NEXT: Magic: 0x4 MFILE64-NEXT: Subsection [ MFILE64-NEXT: Type: 0xF1 @@ -387,9 +387,9 @@ ; return 0; ; } ; using 32-version of CL v17.00.61030 and v18.00.21005.1 respectively. -RUN: llvm-readobj -s -codeview-linetables %p/Inputs/comdat-function-linetables.obj.coff-2012-i386 \ +RUN: llvm-readobj -s -codeview %p/Inputs/comdat-function-linetables.obj.coff-2012-i386 \ RUN: | FileCheck %s -check-prefix MCOMDAT -RUN: llvm-readobj -s -codeview-linetables %p/Inputs/comdat-function-linetables.obj.coff-2013-i386 \ +RUN: llvm-readobj -s -codeview %p/Inputs/comdat-function-linetables.obj.coff-2013-i386 \ RUN: | FileCheck %s -check-prefix MCOMDAT MCOMDAT: ProcStart { Index: tools/llvm-readobj/COFFDumper.cpp =================================================================== --- tools/llvm-readobj/COFFDumper.cpp +++ tools/llvm-readobj/COFFDumper.cpp @@ -71,7 +71,7 @@ void printBaseOfDataField(const pe32_header *Hdr); void printBaseOfDataField(const pe32plus_header *Hdr); - void printCodeViewLineTables(const SectionRef &Section); + void printCodeViewDebugInfo(const SectionRef &Section); void printCodeViewSymbolsSubsection(StringRef Subsection, const SectionRef &Section, @@ -469,7 +469,7 @@ void COFFDumper::printBaseOfDataField(const pe32plus_header *) {} -void COFFDumper::printCodeViewLineTables(const SectionRef &Section) { +void COFFDumper::printCodeViewDebugInfo(const SectionRef &Section) { StringRef Data; if (error(Section.getContents(Data))) return; @@ -477,7 +477,7 @@ SmallVector FunctionNames; StringMap FunctionLineTables; - ListScope D(W, "CodeViewLineTables"); + ListScope D(W, "CodeViewDebugInfo"); { // FIXME: Add more offset correctness checks. DataExtractor DE(Data, true, 4); @@ -696,6 +696,15 @@ break; } default: + if (opts::CodeViewSymbols) { + ListScope S(W, "Record"); + W.printHex("Length", Size); + W.printHex("Type", Type); + + StringRef Contents = DE.getData().substr(Offset, Size); + W.printBinaryBlock("Contents", Contents); + } + Offset += Size; break; } @@ -747,8 +756,8 @@ } } - if (Name == ".debug$S" && opts::CodeViewLineTables) - printCodeViewLineTables(Sec); + if (Name == ".debug$S" && opts::CodeView) + printCodeViewDebugInfo(Sec); if (opts::SectionData && !(Section->Characteristics & COFF::IMAGE_SCN_CNT_UNINITIALIZED_DATA)) { Index: tools/llvm-readobj/llvm-readobj.h =================================================================== --- tools/llvm-readobj/llvm-readobj.h +++ tools/llvm-readobj/llvm-readobj.h @@ -36,7 +36,8 @@ extern llvm::cl::opt DynamicSymbols; extern llvm::cl::opt UnwindInfo; extern llvm::cl::opt ExpandRelocs; - extern llvm::cl::opt CodeViewLineTables; + extern llvm::cl::opt CodeView; + extern llvm::cl::opt CodeViewSymbols; extern llvm::cl::opt ARMAttributes; extern llvm::cl::opt MipsPLTGOT; } // namespace opts Index: tools/llvm-readobj/llvm-readobj.cpp =================================================================== --- tools/llvm-readobj/llvm-readobj.cpp +++ tools/llvm-readobj/llvm-readobj.cpp @@ -127,9 +127,13 @@ cl::opt ExpandRelocs("expand-relocs", cl::desc("Expand each shown relocation to multiple lines")); - // -codeview-linetables - cl::opt CodeViewLineTables("codeview-linetables", - cl::desc("Display CodeView line table information")); + // -codeview + cl::opt CodeView("codeview", + cl::desc("Display CodeView debug information")); + + // -codeview-symbols + cl::opt CodeViewSymbols("codeview-symbols", + cl::desc("Display CodeView symbol records")); // -arm-attributes, -a cl::opt ARMAttributes("arm-attributes",