diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2011-09-15 16:57:13 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2011-09-15 16:57:13 +0000 |
commit | 34f864fd382156331c61fbb6b7ae4828108b9d69 (patch) | |
tree | 1f1263c4821c34ae7e4e41f6fe5268ee21abca9d /lib/DebugInfo | |
parent | 70796ca867132fd8c767301061afb9760cd69167 (diff) |
DWARF: wire up .debug_str dumping.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139799 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/DebugInfo')
-rw-r--r-- | lib/DebugInfo/DWARFContext.cpp | 13 | ||||
-rw-r--r-- | lib/DebugInfo/DWARFDebugInfoEntry.cpp | 2 | ||||
-rw-r--r-- | lib/DebugInfo/DWARFFormValue.cpp | 24 | ||||
-rw-r--r-- | lib/DebugInfo/DWARFFormValue.h | 3 |
4 files changed, 25 insertions, 17 deletions
diff --git a/lib/DebugInfo/DWARFContext.cpp b/lib/DebugInfo/DWARFContext.cpp index 68f58d9031..215effac41 100644 --- a/lib/DebugInfo/DWARFContext.cpp +++ b/lib/DebugInfo/DWARFContext.cpp @@ -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 @@ void DWARFContext::dump(raw_ostream &OS) { 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() { diff --git a/lib/DebugInfo/DWARFDebugInfoEntry.cpp b/lib/DebugInfo/DWARFDebugInfoEntry.cpp index f8c89fde93..1b089adbe1 100644 --- a/lib/DebugInfo/DWARFDebugInfoEntry.cpp +++ b/lib/DebugInfo/DWARFDebugInfoEntry.cpp @@ -89,7 +89,7 @@ void DWARFDebugInfoEntryMinimal::dumpAttribute(raw_ostream &OS, return; OS << "\t("; - formValue.dump(OS, 0, cu); + formValue.dump(OS, cu); OS << ")\n"; } diff --git a/lib/DebugInfo/DWARFFormValue.cpp b/lib/DebugInfo/DWARFFormValue.cpp index 506aab8812..705efe5549 100644 --- a/lib/DebugInfo/DWARFFormValue.cpp +++ b/lib/DebugInfo/DWARFFormValue.cpp @@ -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 @@ DWARFFormValue::skipValue(uint16_t form, DataExtractor debug_info_data, } 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 @@ DWARFFormValue::dump(raw_ostream &OS, const DataExtractor *debug_str_data, 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; diff --git a/lib/DebugInfo/DWARFFormValue.h b/lib/DebugInfo/DWARFFormValue.h index b1b04491d3..22ac011664 100644 --- a/lib/DebugInfo/DWARFFormValue.h +++ b/lib/DebugInfo/DWARFFormValue.h @@ -48,8 +48,7 @@ public: 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 { |