DWARF: Print line tables per compile unit, so they get the right address size.
authorBenjamin Kramer <benny.kra@googlemail.com>
Thu, 15 Sep 2011 18:02:20 +0000 (18:02 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Thu, 15 Sep 2011 18:02:20 +0000 (18:02 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139808 91177308-0d34-0410-b5e6-96231b3b80d8

lib/DebugInfo/DWARFCompileUnit.cpp
lib/DebugInfo/DWARFCompileUnit.h
lib/DebugInfo/DWARFContext.cpp

index d535df05d3b5bb29d7db3b10b5c10ae9a94d3a2f..24bf97ff608ab302de56e343e62592239edd5f7b 100644 (file)
@@ -94,8 +94,7 @@ void DWARFCompileUnit::dump(raw_ostream &OS) {
      << " (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() {
index 378b6ced8cfe0fa26eef211b3cd25ba36f02b1e3..d9167292a9df2a9da748383c61ed1c71c5b3400e 100644 (file)
@@ -70,6 +70,14 @@ public:
     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.
index 215effac41ffc6dc3795bb82e0d9c630f622553a..184a8b595c596bb11c3805a3d1b6b03e5b0e0897 100644 (file)
@@ -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 @@ void DWARFContext::dump(raw_ostream &OS) {
     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);