[llvm-commits] [llvm] r139799 - in /llvm/trunk: lib/DebugInfo/DWARFContext.cpp lib/DebugInfo/DWARFDebugInfoEntry.cpp lib/DebugInfo/DWARFFormValue.cpp lib/DebugInfo/DWARFFormValue.h tools/llvm-dwarfdump/llvm-dwarfdump.cpp

Benjamin Kramer benny.kra at googlemail.com
Thu Sep 15 09:57:13 PDT 2011


Author: d0k
Date: Thu Sep 15 11:57:13 2011
New Revision: 139799

URL: http://llvm.org/viewvc/llvm-project?rev=139799&view=rev
Log:
DWARF: wire up .debug_str dumping.

Modified:
    llvm/trunk/lib/DebugInfo/DWARFContext.cpp
    llvm/trunk/lib/DebugInfo/DWARFDebugInfoEntry.cpp
    llvm/trunk/lib/DebugInfo/DWARFFormValue.cpp
    llvm/trunk/lib/DebugInfo/DWARFFormValue.h
    llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp

Modified: llvm/trunk/lib/DebugInfo/DWARFContext.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFContext.cpp?rev=139799&r1=139798&r2=139799&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARFContext.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARFContext.cpp Thu Sep 15 11:57:13 2011
@@ -8,6 +8,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "DWARFContext.h"
+#include "llvm/Support/Format.h"
 #include "llvm/Support/raw_ostream.h"
 using namespace llvm;
 
@@ -27,8 +28,18 @@
     set.dump(OS);
 
   OS << "\n.debug_lines contents:\n";
-  DataExtractor lineData(getLineSection(), isLittleEndian(), 8);
+  // FIXME: must be done per CU.
+  DataExtractor lineData(getLineSection(), isLittleEndian(), /*FIXME*/8);
   DWARFDebugLine::dump(lineData, OS);
+
+  OS << "\n.debug_str contents:\n";
+  DataExtractor strData(getStringSection(), isLittleEndian(), 0);
+  offset = 0;
+  uint32_t lastOffset = 0;
+  while (const char *s = strData.getCStr(&offset)) {
+    OS << format("0x%8.8x: \"%s\"\n", lastOffset, s);
+    lastOffset = offset;
+  }
 }
 
 const DWARFDebugAbbrev *DWARFContext::getDebugAbbrev() {

Modified: llvm/trunk/lib/DebugInfo/DWARFDebugInfoEntry.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFDebugInfoEntry.cpp?rev=139799&r1=139798&r2=139799&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARFDebugInfoEntry.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARFDebugInfoEntry.cpp Thu Sep 15 11:57:13 2011
@@ -89,7 +89,7 @@
     return;
 
   OS << "\t(";
-  formValue.dump(OS, 0, cu);
+  formValue.dump(OS, cu);
   OS << ")\n";
 }
 

Modified: llvm/trunk/lib/DebugInfo/DWARFFormValue.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFFormValue.cpp?rev=139799&r1=139798&r2=139799&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARFFormValue.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARFFormValue.cpp Thu Sep 15 11:57:13 2011
@@ -9,6 +9,7 @@
 
 #include "DWARFFormValue.h"
 #include "DWARFCompileUnit.h"
+#include "DWARFContext.h"
 #include "llvm/Support/Dwarf.h"
 #include "llvm/Support/Format.h"
 #include "llvm/Support/raw_ostream.h"
@@ -256,8 +257,8 @@
 }
 
 void
-DWARFFormValue::dump(raw_ostream &OS, const DataExtractor *debug_str_data,
-                     const DWARFCompileUnit *cu) const {
+DWARFFormValue::dump(raw_ostream &OS, const DWARFCompileUnit *cu) const {
+  DataExtractor debug_str_data(cu->getContext().getStringSection(), true, 0);
   uint64_t uvalue = getUnsigned();
   bool cu_relative_offset = false;
 
@@ -302,19 +303,16 @@
 
   case DW_FORM_sdata:     OS << getSigned();   break;
   case DW_FORM_udata:     OS << getUnsigned(); break;
-  case DW_FORM_strp:
-    if (debug_str_data) {
-      OS << format(" .debug_str[0x%8.8x] = ", (uint32_t)uvalue);
-      const char* dbg_str = getAsCString(debug_str_data);
-      if (dbg_str) {
-        OS << '"';
-        OS.write_escaped(dbg_str);
-        OS << '"';
-      }
-    } else {
-      OS << format("0x%08x", uvalue);
+  case DW_FORM_strp: {
+    OS << format(" .debug_str[0x%8.8x] = ", (uint32_t)uvalue);
+    const char* dbg_str = getAsCString(&debug_str_data);
+    if (dbg_str) {
+      OS << '"';
+      OS.write_escaped(dbg_str);
+      OS << '"';
     }
     break;
+  }
   case DW_FORM_ref_addr:
     OS << format("0x%016x", uvalue);
     break;

Modified: llvm/trunk/lib/DebugInfo/DWARFFormValue.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFFormValue.h?rev=139799&r1=139798&r2=139799&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARFFormValue.h (original)
+++ llvm/trunk/lib/DebugInfo/DWARFFormValue.h Thu Sep 15 11:57:13 2011
@@ -48,8 +48,7 @@
   DWARFFormValue(uint16_t form = 0) : Form(form) {}
   uint16_t getForm() const { return Form; }
   const ValueType& value() const { return Value; }
-  void dump(raw_ostream &OS, const DataExtractor *debug_str_data,
-            const DWARFCompileUnit* cu) const;
+  void dump(raw_ostream &OS, const DWARFCompileUnit* cu) const;
   bool extractValue(DataExtractor data, uint32_t *offset_ptr,
                     const DWARFCompileUnit *cu);
   bool isInlinedCStr() const {

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=139799&r1=139798&r2=139799&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp (original)
+++ llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp Thu Sep 15 11:57:13 2011
@@ -53,6 +53,7 @@
   StringRef DebugAbbrevSection;
   StringRef DebugLineSection;
   StringRef DebugArangesSection;
+  StringRef DebugStringSection;
 
   error_code ec;
   for (ObjectFile::section_iterator i = Obj->begin_sections(),
@@ -74,13 +75,16 @@
       DebugLineSection = data;
     else if (name == "debug_aranges")
       DebugArangesSection = data;
+    else if (name == "debug_str")
+      DebugStringSection = data;
   }
 
   OwningPtr<DIContext> dictx(DIContext::getDWARFContext(/*FIXME*/true,
                                                         DebugInfoSection,
                                                         DebugAbbrevSection,
                                                         DebugArangesSection,
-                                                        DebugLineSection));
+                                                        DebugLineSection,
+                                                        DebugStringSection));
   dictx->dump(outs());
 }
 





More information about the llvm-commits mailing list