diff options
author | Eric Christopher <echristo@gmail.com> | 2013-01-07 19:32:41 +0000 |
---|---|---|
committer | Eric Christopher <echristo@gmail.com> | 2013-01-07 19:32:41 +0000 |
commit | dd8e9f395e881972b320d947de88102a0be04b70 (patch) | |
tree | 21842f103965e21cb354a45a98cc813c108576b8 /lib/DebugInfo | |
parent | 5b7f9216c357f1cdf507f300f396b44cb982eb3f (diff) | |
download | external_llvm-dd8e9f395e881972b320d947de88102a0be04b70.zip external_llvm-dd8e9f395e881972b320d947de88102a0be04b70.tar.gz external_llvm-dd8e9f395e881972b320d947de88102a0be04b70.tar.bz2 |
Add support for separating strings for the split debug info DWARF5
proposal. This leaves the strings in the skeleton die as strp,
but in all dwo files they're accessed now via DW_FORM_GNU_str_index.
Add support for dumping these sections and modify the fission-cu.ll
testcase to have the correct strings and form. Fix a small bug
in the fixed form sizes routine that involved out of array accesses
for the table and add a FIXME in the extractFast routine to fix
this up.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171779 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/DebugInfo')
-rw-r--r-- | lib/DebugInfo/DWARFCompileUnit.h | 8 | ||||
-rw-r--r-- | lib/DebugInfo/DWARFContext.cpp | 6 | ||||
-rw-r--r-- | lib/DebugInfo/DWARFContext.h | 5 | ||||
-rw-r--r-- | lib/DebugInfo/DWARFDebugInfoEntry.cpp | 13 | ||||
-rw-r--r-- | lib/DebugInfo/DWARFFormValue.cpp | 28 | ||||
-rw-r--r-- | lib/DebugInfo/DWARFFormValue.h | 2 |
6 files changed, 53 insertions, 9 deletions
diff --git a/lib/DebugInfo/DWARFCompileUnit.h b/lib/DebugInfo/DWARFCompileUnit.h index ba638df..c58664f 100644 --- a/lib/DebugInfo/DWARFCompileUnit.h +++ b/lib/DebugInfo/DWARFCompileUnit.h @@ -28,6 +28,7 @@ class DWARFCompileUnit { StringRef AbbrevSection; StringRef RangeSection; StringRef StringSection; + StringRef StringOffsetSection; const RelocAddrMap *RelocMap; bool isLittleEndian; @@ -42,13 +43,16 @@ class DWARFCompileUnit { public: DWARFCompileUnit(const DWARFDebugAbbrev *DA, StringRef IS, StringRef AS, - StringRef RS, StringRef SS, const RelocAddrMap *M, bool LE) : + StringRef RS, StringRef SS, StringRef SOS, + const RelocAddrMap *M, bool LE) : Abbrev(DA), InfoSection(IS), AbbrevSection(AS), - RangeSection(RS), StringSection(SS), RelocMap(M), isLittleEndian(LE) { + RangeSection(RS), StringSection(SS), StringOffsetSection(SOS), + RelocMap(M), isLittleEndian(LE) { clear(); } StringRef getStringSection() const { return StringSection; } + StringRef getStringOffsetSection() const { return StringOffsetSection; } const RelocAddrMap *getRelocMap() const { return RelocMap; } DataExtractor getDebugInfoExtractor() const; diff --git a/lib/DebugInfo/DWARFContext.cpp b/lib/DebugInfo/DWARFContext.cpp index 1270e6e..d6d9fcf 100644 --- a/lib/DebugInfo/DWARFContext.cpp +++ b/lib/DebugInfo/DWARFContext.cpp @@ -152,7 +152,8 @@ void DWARFContext::parseCompileUnits() { while (DIData.isValidOffset(offset)) { CUs.push_back(DWARFCompileUnit(getDebugAbbrev(), getInfoSection(), getAbbrevSection(), getRangeSection(), - getStringSection(), &infoRelocMap(), + getStringSection(), "", + &infoRelocMap(), isLittleEndian())); if (!CUs.back().extract(DIData, &offset)) { CUs.pop_back(); @@ -172,6 +173,7 @@ void DWARFContext::parseDWOCompileUnits() { getAbbrevDWOSection(), getRangeDWOSection(), getStringDWOSection(), + getStringOffsetDWOSection(), &infoDWORelocMap(), isLittleEndian())); if (!DWOCUs.back().extract(DIData, &offset)) { @@ -382,6 +384,8 @@ DWARFContextInMemory::DWARFContextInMemory(object::ObjectFile *Obj) : AbbrevDWOSection = data; else if (name == "debug_str.dwo") StringDWOSection = data; + else if (name == "debug_str_offsets.dwo") + StringOffsetDWOSection = data; // Any more debug info sections go here. else continue; diff --git a/lib/DebugInfo/DWARFContext.h b/lib/DebugInfo/DWARFContext.h index 0c3eb30..c6d6283 100644 --- a/lib/DebugInfo/DWARFContext.h +++ b/lib/DebugInfo/DWARFContext.h @@ -106,6 +106,7 @@ public: virtual StringRef getInfoDWOSection() = 0; virtual StringRef getAbbrevDWOSection() = 0; virtual StringRef getStringDWOSection() = 0; + virtual StringRef getStringOffsetDWOSection() = 0; virtual StringRef getRangeDWOSection() = 0; virtual const RelocAddrMap &infoDWORelocMap() const = 0; @@ -140,6 +141,7 @@ class DWARFContextInMemory : public DWARFContext { StringRef InfoDWOSection; StringRef AbbrevDWOSection; StringRef StringDWOSection; + StringRef StringOffsetDWOSection; StringRef RangeDWOSection; public: @@ -157,6 +159,9 @@ public: virtual StringRef getInfoDWOSection() { return InfoDWOSection; } virtual StringRef getAbbrevDWOSection() { return AbbrevDWOSection; } virtual StringRef getStringDWOSection() { return StringDWOSection; } + virtual StringRef getStringOffsetDWOSection() { + return StringOffsetDWOSection; + } virtual StringRef getRangeDWOSection() { return RangeDWOSection; } virtual const RelocAddrMap &infoDWORelocMap() const { return InfoDWORelocMap; } }; diff --git a/lib/DebugInfo/DWARFDebugInfoEntry.cpp b/lib/DebugInfo/DWARFDebugInfoEntry.cpp index c083b8c..bb11850 100644 --- a/lib/DebugInfo/DWARFDebugInfoEntry.cpp +++ b/lib/DebugInfo/DWARFDebugInfoEntry.cpp @@ -12,6 +12,7 @@ #include "DWARFContext.h" #include "DWARFDebugAbbrev.h" #include "DWARFFormValue.h" +#include "llvm/Support/Debug.h" #include "llvm/Support/Dwarf.h" #include "llvm/Support/Format.h" #include "llvm/Support/raw_ostream.h" @@ -113,9 +114,14 @@ bool DWARFDebugInfoEntryMinimal::extractFast(const DWARFCompileUnit *cu, uint32_t i; uint16_t form; for (i=0; i<numAttributes; ++i) { + form = AbbrevDecl->getFormByIndex(i); - const uint8_t fixed_skip_size = fixed_form_sizes[form]; + // FIXME: Currently we're checking if this is less than the last + // entry in the fixed_form_sizes table, but this should be changed + // to use dynamic dispatch. + const uint8_t fixed_skip_size = (form < DW_FORM_ref_sig8) ? + fixed_form_sizes[form] : 0; if (fixed_skip_size) offset += fixed_skip_size; else { @@ -187,6 +193,8 @@ bool DWARFDebugInfoEntryMinimal::extractFast(const DWARFCompileUnit *cu, case DW_FORM_sdata: case DW_FORM_udata: case DW_FORM_ref_udata: + case DW_FORM_GNU_str_index: + case DW_FORM_GNU_addr_index: debug_info_data.getULEB128(&offset); break; @@ -207,7 +215,6 @@ bool DWARFDebugInfoEntryMinimal::extractFast(const DWARFCompileUnit *cu, return false; } offset += form_size; - } while (form_is_indirect); } } @@ -327,6 +334,8 @@ DWARFDebugInfoEntryMinimal::extract(const DWARFCompileUnit *cu, case DW_FORM_sdata: case DW_FORM_udata: case DW_FORM_ref_udata: + case DW_FORM_GNU_str_index: + case DW_FORM_GNU_addr_index: debug_info_data.getULEB128(&offset); break; diff --git a/lib/DebugInfo/DWARFFormValue.cpp b/lib/DebugInfo/DWARFFormValue.cpp index 1610db2..47fad8b 100644 --- a/lib/DebugInfo/DWARFFormValue.cpp +++ b/lib/DebugInfo/DWARFFormValue.cpp @@ -46,8 +46,6 @@ static const uint8_t form_sizes_addr4[] = { 0, // 0x18 DW_FORM_exprloc 0, // 0x19 DW_FORM_flag_present 8, // 0x20 DW_FORM_ref_sig8 - 4, // 0x1f01 DW_FORM_GNU_addr_index - 4, // 0x1f02 DW_FORM_GNU_str_index }; static const uint8_t form_sizes_addr8[] = { @@ -78,8 +76,6 @@ static const uint8_t form_sizes_addr8[] = { 0, // 0x18 DW_FORM_exprloc 0, // 0x19 DW_FORM_flag_present 8, // 0x20 DW_FORM_ref_sig8 - 8, // 0x1f01 DW_FORM_GNU_addr_index - 8, // 0x1f01 DW_FORM_GNU_str_index }; const uint8_t * @@ -295,6 +291,8 @@ DWARFFormValue::skipValue(uint16_t form, DataExtractor debug_info_data, case DW_FORM_sdata: case DW_FORM_udata: case DW_FORM_ref_udata: + case DW_FORM_GNU_str_index: + case DW_FORM_GNU_addr_index: debug_info_data.getULEB128(offset_ptr); return true; @@ -321,6 +319,7 @@ DWARFFormValue::skipValue(uint16_t form, DataExtractor debug_info_data, void DWARFFormValue::dump(raw_ostream &OS, const DWARFCompileUnit *cu) const { DataExtractor debug_str_data(cu->getStringSection(), true, 0); + DataExtractor debug_str_offset_data(cu->getStringOffsetSection(), true, 0); uint64_t uvalue = getUnsigned(); bool cu_relative_offset = false; @@ -379,6 +378,17 @@ DWARFFormValue::dump(raw_ostream &OS, const DWARFCompileUnit *cu) const { } break; } + case DW_FORM_GNU_str_index: { + OS << format(" indexed (%8.8x) string = ", (uint32_t)uvalue); + const char *dbg_str = getIndirectCString(&debug_str_data, + &debug_str_offset_data); + if (dbg_str) { + OS << '"'; + OS.write_escaped(dbg_str); + OS << '"'; + } + break; + } case DW_FORM_ref_addr: OS << format("0x%016" PRIx64, uvalue); break; @@ -436,6 +446,16 @@ DWARFFormValue::getAsCString(const DataExtractor *debug_str_data_ptr) const { return NULL; } +const char* +DWARFFormValue::getIndirectCString(const DataExtractor *DS, + const DataExtractor *DSO) const { + if (!DS || !DSO) return NULL; + + uint32_t offset = Value.uval * 4; + uint32_t soffset = DSO->getULEB128(&offset); + return DS->getCStr(&soffset); +} + uint64_t DWARFFormValue::getReference(const DWARFCompileUnit *cu) const { uint64_t die_offset = Value.uval; switch (Form) { diff --git a/lib/DebugInfo/DWARFFormValue.h b/lib/DebugInfo/DWARFFormValue.h index c5b590d..7768c18 100644 --- a/lib/DebugInfo/DWARFFormValue.h +++ b/lib/DebugInfo/DWARFFormValue.h @@ -64,6 +64,8 @@ public: uint64_t getUnsigned() const { return Value.uval; } int64_t getSigned() const { return Value.sval; } const char *getAsCString(const DataExtractor *debug_str_data_ptr) const; + const char *getIndirectCString(const DataExtractor *, + const DataExtractor *) const; bool skipValue(DataExtractor debug_info_data, uint32_t *offset_ptr, const DWARFCompileUnit *cu) const; static bool skipValue(uint16_t form, DataExtractor debug_info_data, |