[llvm] r202091 - llvm-dwarfdump: Support for debug_line.dwo section for file names for type units under fission.

David Blaikie dblaikie at gmail.com
Mon Feb 24 15:58:54 PST 2014


Author: dblaikie
Date: Mon Feb 24 17:58:54 2014
New Revision: 202091

URL: http://llvm.org/viewvc/llvm-project?rev=202091&view=rev
Log:
llvm-dwarfdump: Support for debug_line.dwo section for file names for type units under fission.

Added:
    llvm/trunk/test/DebugInfo/Inputs/dwarfdump-line-dwo.cc
    llvm/trunk/test/DebugInfo/Inputs/dwarfdump-line-dwo.elf-x86-64
    llvm/trunk/test/DebugInfo/dwarfdump-line-dwo.test
Modified:
    llvm/trunk/include/llvm/DebugInfo/DIContext.h
    llvm/trunk/lib/DebugInfo/DWARFContext.cpp
    llvm/trunk/lib/DebugInfo/DWARFContext.h
    llvm/trunk/lib/DebugInfo/DWARFDebugLine.cpp
    llvm/trunk/lib/DebugInfo/DWARFDebugLine.h
    llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp

Modified: llvm/trunk/include/llvm/DebugInfo/DIContext.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/DIContext.h?rev=202091&r1=202090&r2=202091&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/DIContext.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/DIContext.h Mon Feb 24 17:58:54 2014
@@ -107,6 +107,7 @@ enum DIDumpType {
   DIDT_Types,
   DIDT_TypesDwo,
   DIDT_Line,
+  DIDT_LineDwo,
   DIDT_Loc,
   DIDT_Ranges,
   DIDT_Pubnames,

Modified: llvm/trunk/lib/DebugInfo/DWARFContext.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFContext.cpp?rev=202091&r1=202090&r2=202091&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARFContext.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARFContext.cpp Mon Feb 24 17:58:54 2014
@@ -136,6 +136,16 @@ void DWARFContext::dump(raw_ostream &OS,
     }
   }
 
+  if (DumpType == DIDT_All || DumpType == DIDT_LineDwo) {
+    OS << "\n.debug_line.dwo contents:\n";
+    unsigned stmtOffset = 0;
+    DataExtractor lineData(getLineDWOSection().Data, isLittleEndian(),
+                           savedAddressByteSize);
+    DWARFDebugLine::DumpingState state(OS);
+    while (DWARFDebugLine::parsePrologue(lineData, &stmtOffset, &state.Prologue))
+      state.finalize();
+  }
+
   if (DumpType == DIDT_All || DumpType == DIDT_Str) {
     OS << "\n.debug_str contents:\n";
     DataExtractor strData(getStringSection(), isLittleEndian(), 0);
@@ -645,6 +655,7 @@ DWARFContextInMemory::DWARFContextInMemo
             .Case("debug_gnu_pubtypes", &GnuPubTypesSection)
             .Case("debug_info.dwo", &InfoDWOSection.Data)
             .Case("debug_abbrev.dwo", &AbbrevDWOSection)
+            .Case("debug_line.dwo", &LineDWOSection.Data)
             .Case("debug_str.dwo", &StringDWOSection)
             .Case("debug_str_offsets.dwo", &StringOffsetDWOSection)
             .Case("debug_addr", &AddrSection)

Modified: llvm/trunk/lib/DebugInfo/DWARFContext.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFContext.h?rev=202091&r1=202090&r2=202091&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARFContext.h (original)
+++ llvm/trunk/lib/DebugInfo/DWARFContext.h Mon Feb 24 17:58:54 2014
@@ -166,6 +166,7 @@ public:
   virtual StringRef getARangeSection() = 0;
   virtual StringRef getDebugFrameSection() = 0;
   virtual const Section &getLineSection() = 0;
+  virtual const Section &getLineDWOSection() = 0;
   virtual StringRef getStringSection() = 0;
   virtual StringRef getRangeSection() = 0;
   virtual StringRef getPubNamesSection() = 0;
@@ -208,6 +209,7 @@ class DWARFContextInMemory : public DWAR
   StringRef ARangeSection;
   StringRef DebugFrameSection;
   Section LineSection;
+  Section LineDWOSection;
   StringRef StringSection;
   StringRef RangeSection;
   StringRef PubNamesSection;
@@ -238,6 +240,7 @@ public:
   virtual StringRef getARangeSection() { return ARangeSection; }
   virtual StringRef getDebugFrameSection() { return DebugFrameSection; }
   virtual const Section &getLineSection() { return LineSection; }
+  virtual const Section &getLineDWOSection() { return LineDWOSection; }
   virtual StringRef getStringSection() { return StringSection; }
   virtual StringRef getRangeSection() { return RangeSection; }
   virtual StringRef getPubNamesSection() { return PubNamesSection; }

Modified: llvm/trunk/lib/DebugInfo/DWARFDebugLine.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFDebugLine.cpp?rev=202091&r1=202090&r2=202091&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARFDebugLine.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARFDebugLine.cpp Mon Feb 24 17:58:54 2014
@@ -18,14 +18,15 @@ using namespace dwarf;
 
 void DWARFDebugLine::Prologue::dump(raw_ostream &OS) const {
   OS << "Line table prologue:\n"
-     << format("   total_length: 0x%8.8x\n", TotalLength)
-     << format("        version: %u\n", Version)
-     << format("prologue_length: 0x%8.8x\n", PrologueLength)
-     << format("min_inst_length: %u\n", MinInstLength)
-     << format("default_is_stmt: %u\n", DefaultIsStmt)
-     << format("      line_base: %i\n", LineBase)
-     << format("     line_range: %u\n", LineRange)
-     << format("    opcode_base: %u\n", OpcodeBase);
+     << format("    total_length: 0x%8.8x\n", TotalLength)
+     << format("         version: %u\n", Version)
+     << format(" prologue_length: 0x%8.8x\n", PrologueLength)
+     << format(" min_inst_length: %u\n", MinInstLength)
+     << format(Version >= 4 ? "max_ops_per_inst: %u\n" : "", MaxOpsPerInst)
+     << format(" default_is_stmt: %u\n", DefaultIsStmt)
+     << format("       line_base: %i\n", LineBase)
+     << format("      line_range: %u\n", LineRange)
+     << format("     opcode_base: %u\n", OpcodeBase);
 
   for (uint32_t i = 0; i < StandardOpcodeLengths.size(); ++i)
     OS << format("standard_opcode_lengths[%s] = %u\n", LNStandardString(i+1),
@@ -172,12 +173,14 @@ DWARFDebugLine::parsePrologue(DataExtrac
   prologue->clear();
   prologue->TotalLength = debug_line_data.getU32(offset_ptr);
   prologue->Version = debug_line_data.getU16(offset_ptr);
-  if (prologue->Version != 2)
+  if (prologue->Version < 2)
     return false;
 
   prologue->PrologueLength = debug_line_data.getU32(offset_ptr);
   const uint32_t end_prologue_offset = prologue->PrologueLength + *offset_ptr;
   prologue->MinInstLength = debug_line_data.getU8(offset_ptr);
+  if (prologue->Version >= 4)
+    prologue->MaxOpsPerInst = debug_line_data.getU8(offset_ptr);
   prologue->DefaultIsStmt = debug_line_data.getU8(offset_ptr);
   prologue->LineBase = debug_line_data.getU8(offset_ptr);
   prologue->LineRange = debug_line_data.getU8(offset_ptr);
@@ -220,10 +223,9 @@ DWARFDebugLine::parsePrologue(DataExtrac
   return true;
 }
 
-bool
-DWARFDebugLine::parseStatementTable(DataExtractor debug_line_data, 
-                                    const RelocAddrMap *RMap,
-                                    uint32_t *offset_ptr, State &state) {
+bool DWARFDebugLine::parseStatementTable(DataExtractor debug_line_data,
+                                         const RelocAddrMap *RMap,
+                                         uint32_t *offset_ptr, State &state) {
   const uint32_t debug_line_offset = *offset_ptr;
 
   Prologue *prologue = &state.Prologue;

Modified: llvm/trunk/lib/DebugInfo/DWARFDebugLine.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFDebugLine.h?rev=202091&r1=202090&r2=202091&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARFDebugLine.h (original)
+++ llvm/trunk/lib/DebugInfo/DWARFDebugLine.h Mon Feb 24 17:58:54 2014
@@ -34,8 +34,9 @@ public:
 
   struct Prologue {
     Prologue()
-      : TotalLength(0), Version(0), PrologueLength(0), MinInstLength(0),
-        DefaultIsStmt(0), LineBase(0), LineRange(0), OpcodeBase(0) {}
+        : TotalLength(0), Version(0), PrologueLength(0), MinInstLength(0),
+          MaxOpsPerInst(0), DefaultIsStmt(0), LineBase(0), LineRange(0),
+          OpcodeBase(0) {}
 
     // The size in bytes of the statement information for this compilation unit
     // (not including the total_length field itself).
@@ -49,6 +50,9 @@ public:
     // program opcodes that alter the address register first multiply their
     // operands by this value.
     uint8_t MinInstLength;
+    // The maximum number of individual operations that may be encoded in an
+    // instruction.
+    uint8_t MaxOpsPerInst;
     // The initial value of theis_stmtregister.
     uint8_t DefaultIsStmt;
     // This parameter affects the meaning of the special opcodes. See below.

Added: llvm/trunk/test/DebugInfo/Inputs/dwarfdump-line-dwo.cc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/Inputs/dwarfdump-line-dwo.cc?rev=202091&view=auto
==============================================================================
--- llvm/trunk/test/DebugInfo/Inputs/dwarfdump-line-dwo.cc (added)
+++ llvm/trunk/test/DebugInfo/Inputs/dwarfdump-line-dwo.cc Mon Feb 24 17:58:54 2014
@@ -0,0 +1,10 @@
+struct foo {
+};
+
+foo f;
+
+// Built with GCC
+// $ mkdir -p /tmp/dbginfo
+// $ cp dwarfdump-line-dwo.cc /tmp/dbginfo
+// $ cd /tmp/dbginfo
+// $ g++ -c -fdebug-types-section dwarfdump-line-dwo.cc -o <output>

Added: llvm/trunk/test/DebugInfo/Inputs/dwarfdump-line-dwo.elf-x86-64
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/Inputs/dwarfdump-line-dwo.elf-x86-64?rev=202091&view=auto
==============================================================================
Binary files llvm/trunk/test/DebugInfo/Inputs/dwarfdump-line-dwo.elf-x86-64 (added) and llvm/trunk/test/DebugInfo/Inputs/dwarfdump-line-dwo.elf-x86-64 Mon Feb 24 17:58:54 2014 differ

Added: llvm/trunk/test/DebugInfo/dwarfdump-line-dwo.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/dwarfdump-line-dwo.test?rev=202091&view=auto
==============================================================================
--- llvm/trunk/test/DebugInfo/dwarfdump-line-dwo.test (added)
+++ llvm/trunk/test/DebugInfo/dwarfdump-line-dwo.test Mon Feb 24 17:58:54 2014
@@ -0,0 +1,6 @@
+RUN: llvm-dwarfdump %p/Inputs/dwarfdump-line-dwo.elf-x86-64 | FileCheck %s
+
+CHECK: .debug_line.dwo contents:
+CHECK: version: 4
+CHECK: max_ops_per_inst: 1
+CHECK: file_names[  1]{{.*}}dwarfdump-line-dwo.cc

Modified: llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp?rev=202091&r1=202090&r2=202091&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp (original)
+++ llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp Mon Feb 24 17:58:54 2014
@@ -65,6 +65,7 @@ DumpType("debug-dump", cl::init(DIDT_All
         clEnumValN(DIDT_Types, "types", ".debug_types"),
         clEnumValN(DIDT_TypesDwo, "types.dwo", ".debug_types.dwo"),
         clEnumValN(DIDT_Line, "line", ".debug_line"),
+        clEnumValN(DIDT_LineDwo, "line.dwo", ".debug_line.dwo"),
         clEnumValN(DIDT_Loc, "loc", ".debug_loc"),
         clEnumValN(DIDT_Frames, "frames", ".debug_frame"),
         clEnumValN(DIDT_Ranges, "ranges", ".debug_ranges"),





More information about the llvm-commits mailing list