[llvm-commits] [llvm] r139808 - in /llvm/trunk/lib/DebugInfo: DWARFCompileUnit.cpp DWARFCompileUnit.h DWARFContext.cpp

Benjamin Kramer benny.kra at googlemail.com
Thu Sep 15 11:02:20 PDT 2011


Author: d0k
Date: Thu Sep 15 13:02:20 2011
New Revision: 139808

URL: http://llvm.org/viewvc/llvm-project?rev=139808&view=rev
Log:
DWARF: Print line tables per compile unit, so they get the right address size.

Modified:
    llvm/trunk/lib/DebugInfo/DWARFCompileUnit.cpp
    llvm/trunk/lib/DebugInfo/DWARFCompileUnit.h
    llvm/trunk/lib/DebugInfo/DWARFContext.cpp

Modified: llvm/trunk/lib/DebugInfo/DWARFCompileUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFCompileUnit.cpp?rev=139808&r1=139807&r2=139808&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARFCompileUnit.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARFCompileUnit.cpp Thu Sep 15 13:02:20 2011
@@ -94,8 +94,7 @@
      << " (next CU at " << format("0x%08x", getNextCompileUnitOffset())
      << ")\n";
 
-  extractDIEsIfNeeded(false);
-  DieArray[0].dump(OS, this, -1U);
+  getCompileUnitDIE(false)->dump(OS, this, -1U);
 }
 
 void DWARFCompileUnit::setDIERelations() {

Modified: llvm/trunk/lib/DebugInfo/DWARFCompileUnit.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFCompileUnit.h?rev=139808&r1=139807&r2=139808&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARFCompileUnit.h (original)
+++ llvm/trunk/lib/DebugInfo/DWARFCompileUnit.h Thu Sep 15 13:02:20 2011
@@ -70,6 +70,14 @@
     BaseAddr = base_addr;
   }
 
+  const DWARFDebugInfoEntryMinimal *
+  getCompileUnitDIE(bool extract_cu_die_only = true) {
+    extractDIEsIfNeeded(extract_cu_die_only);
+    if (DieArray.empty())
+      return NULL;
+    return &DieArray[0];
+  }
+
   /// setDIERelations - We read in all of the DIE entries into our flat list
   /// of DIE entries and now we need to go back through all of them and set the
   /// parent, sibling and child pointers for quick DIE navigation.

Modified: llvm/trunk/lib/DebugInfo/DWARFContext.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFContext.cpp?rev=139808&r1=139807&r2=139808&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARFContext.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARFContext.cpp Thu Sep 15 13:02:20 2011
@@ -8,9 +8,11 @@
 //===----------------------------------------------------------------------===//
 
 #include "DWARFContext.h"
+#include "llvm/Support/Dwarf.h"
 #include "llvm/Support/Format.h"
 #include "llvm/Support/raw_ostream.h"
 using namespace llvm;
+using namespace dwarf;
 
 void DWARFContext::dump(raw_ostream &OS) {
   OS << ".debug_abbrev contents:\n";
@@ -28,9 +30,18 @@
     set.dump(OS);
 
   OS << "\n.debug_lines contents:\n";
-  // FIXME: must be done per CU.
-  DataExtractor lineData(getLineSection(), isLittleEndian(), /*FIXME*/8);
-  DWARFDebugLine::dump(lineData, OS);
+  for (unsigned i = 0, e = getNumCompileUnits(); i != e; ++i) {
+    DWARFCompileUnit *cu = getCompileUnitAtIndex(i);
+    unsigned stmtOffset =
+      cu->getCompileUnitDIE()->getAttributeValueAsUnsigned(cu, DW_AT_stmt_list,
+                                                           -1U);
+    if (stmtOffset != -1U) {
+      DataExtractor lineData(getLineSection(), isLittleEndian(),
+                             cu->getAddressByteSize());
+      DWARFDebugLine::DumpingState state(OS);
+      DWARFDebugLine::parseStatementTable(lineData, &stmtOffset, state);
+    }
+  }
 
   OS << "\n.debug_str contents:\n";
   DataExtractor strData(getStringSection(), isLittleEndian(), 0);





More information about the llvm-commits mailing list