diff options
author | Eric Christopher <echristo@gmail.com> | 2013-01-15 23:56:56 +0000 |
---|---|---|
committer | Eric Christopher <echristo@gmail.com> | 2013-01-15 23:56:56 +0000 |
commit | 72f7bfbf0e02bb11d3e7cca1f9598c5f9d9fa2ca (patch) | |
tree | ac0756254ac88cc3469f7274306ce15cab7f8a19 /lib/DebugInfo | |
parent | af50dda4102114b23ac7d8c2db4703f22e02f02c (diff) | |
download | external_llvm-72f7bfbf0e02bb11d3e7cca1f9598c5f9d9fa2ca.zip external_llvm-72f7bfbf0e02bb11d3e7cca1f9598c5f9d9fa2ca.tar.gz external_llvm-72f7bfbf0e02bb11d3e7cca1f9598c5f9d9fa2ca.tar.bz2 |
Split address information for DWARF5 split dwarf proposal. This involves
using the DW_FORM_GNU_addr_index and a separate .debug_addr section which
stays in the executable and is fully linked.
Sneak in two other small changes:
a) Print out the debug_str_offsets.dwo section.
b) Change form we're expecting the entries in the debug_str_offsets.dwo
section to take from ULEB128 to U32.
Add tests for all of this in the fission-cu.ll test.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172578 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/DebugInfo')
-rw-r--r-- | lib/DebugInfo/DWARFCompileUnit.h | 6 | ||||
-rw-r--r-- | lib/DebugInfo/DWARFContext.cpp | 14 | ||||
-rw-r--r-- | lib/DebugInfo/DWARFContext.h | 5 | ||||
-rw-r--r-- | lib/DebugInfo/DWARFFormValue.cpp | 21 | ||||
-rw-r--r-- | lib/DebugInfo/DWARFFormValue.h | 2 |
5 files changed, 44 insertions, 4 deletions
diff --git a/lib/DebugInfo/DWARFCompileUnit.h b/lib/DebugInfo/DWARFCompileUnit.h index c58664f..de70b2e 100644 --- a/lib/DebugInfo/DWARFCompileUnit.h +++ b/lib/DebugInfo/DWARFCompileUnit.h @@ -29,6 +29,7 @@ class DWARFCompileUnit { StringRef RangeSection; StringRef StringSection; StringRef StringOffsetSection; + StringRef AddrOffsetSection; const RelocAddrMap *RelocMap; bool isLittleEndian; @@ -43,16 +44,17 @@ class DWARFCompileUnit { public: DWARFCompileUnit(const DWARFDebugAbbrev *DA, StringRef IS, StringRef AS, - StringRef RS, StringRef SS, StringRef SOS, + StringRef RS, StringRef SS, StringRef SOS, StringRef AOS, const RelocAddrMap *M, bool LE) : Abbrev(DA), InfoSection(IS), AbbrevSection(AS), RangeSection(RS), StringSection(SS), StringOffsetSection(SOS), - RelocMap(M), isLittleEndian(LE) { + AddrOffsetSection(AOS), RelocMap(M), isLittleEndian(LE) { clear(); } StringRef getStringSection() const { return StringSection; } StringRef getStringOffsetSection() const { return StringOffsetSection; } + StringRef getAddrOffsetSection() const { return AddrOffsetSection; } const RelocAddrMap *getRelocMap() const { return RelocMap; } DataExtractor getDebugInfoExtractor() const; diff --git a/lib/DebugInfo/DWARFContext.cpp b/lib/DebugInfo/DWARFContext.cpp index 247ee5b..13a527b 100644 --- a/lib/DebugInfo/DWARFContext.cpp +++ b/lib/DebugInfo/DWARFContext.cpp @@ -86,6 +86,14 @@ void DWARFContext::dump(raw_ostream &OS) { OS << format("0x%8.8x: \"%s\"\n", strDWOOffset, s); strDWOOffset = offset; } + + OS << "\n.debug_str_offsets.dwo contents:\n"; + DataExtractor strOffsetExt(getStringOffsetDWOSection(), isLittleEndian(), 0); + offset = 0; + while (offset < getStringOffsetDWOSection().size()) { + OS << format("0x%8.8x: ", offset); + OS << format("%8.8x\n", strOffsetExt.getU32(&offset)); + } } const DWARFDebugAbbrev *DWARFContext::getDebugAbbrev() { @@ -152,7 +160,8 @@ void DWARFContext::parseCompileUnits() { while (DIData.isValidOffset(offset)) { CUs.push_back(DWARFCompileUnit(getDebugAbbrev(), getInfoSection(), getAbbrevSection(), getRangeSection(), - getStringSection(), "", + getStringSection(), StringRef(), + getAddrSection(), &infoRelocMap(), isLittleEndian())); if (!CUs.back().extract(DIData, &offset)) { @@ -174,6 +183,7 @@ void DWARFContext::parseDWOCompileUnits() { getRangeDWOSection(), getStringDWOSection(), getStringOffsetDWOSection(), + getAddrSection(), &infoDWORelocMap(), isLittleEndian())); if (!DWOCUs.back().extract(DIData, &offset)) { @@ -386,6 +396,8 @@ DWARFContextInMemory::DWARFContextInMemory(object::ObjectFile *Obj) : StringDWOSection = data; else if (name == "debug_str_offsets.dwo") StringOffsetDWOSection = data; + else if (name == "debug_addr") + AddrSection = data; // Any more debug info sections go here. else continue; diff --git a/lib/DebugInfo/DWARFContext.h b/lib/DebugInfo/DWARFContext.h index 687ff93..7da5c85 100644 --- a/lib/DebugInfo/DWARFContext.h +++ b/lib/DebugInfo/DWARFContext.h @@ -108,6 +108,7 @@ public: virtual StringRef getStringDWOSection() = 0; virtual StringRef getStringOffsetDWOSection() = 0; virtual StringRef getRangeDWOSection() = 0; + virtual StringRef getAddrSection() = 0; virtual const RelocAddrMap &infoDWORelocMap() const = 0; static bool isSupportedVersion(unsigned version) { @@ -143,6 +144,7 @@ class DWARFContextInMemory : public DWARFContext { StringRef StringDWOSection; StringRef StringOffsetDWOSection; StringRef RangeDWOSection; + StringRef AddrSection; public: DWARFContextInMemory(object::ObjectFile *); @@ -163,6 +165,9 @@ public: return StringOffsetDWOSection; } virtual StringRef getRangeDWOSection() { return RangeDWOSection; } + virtual StringRef getAddrSection() { + return AddrSection; + } virtual const RelocAddrMap &infoDWORelocMap() const { return InfoDWORelocMap; } diff --git a/lib/DebugInfo/DWARFFormValue.cpp b/lib/DebugInfo/DWARFFormValue.cpp index 14c6804..d1bcf96 100644 --- a/lib/DebugInfo/DWARFFormValue.cpp +++ b/lib/DebugInfo/DWARFFormValue.cpp @@ -325,6 +325,16 @@ DWARFFormValue::dump(raw_ostream &OS, const DWARFCompileUnit *cu) const { switch (Form) { case DW_FORM_addr: OS << format("0x%016" PRIx64, uvalue); break; + case DW_FORM_GNU_addr_index: { + StringRef AddrOffsetSec = cu->getAddrOffsetSection(); + OS << format(" indexed (%8.8x) address = ", (uint32_t)uvalue); + if (AddrOffsetSec.size() != 0) { + DataExtractor DA(AddrOffsetSec, true, cu->getAddressByteSize()); + OS << format("0x%016" PRIx64, getIndirectAddress(&DA, cu)); + } else + OS << "<no .debug_addr section>"; + break; + } case DW_FORM_flag_present: OS << "true"; break; case DW_FORM_flag: case DW_FORM_data1: OS << format("0x%02x", (uint8_t)uvalue); break; @@ -452,10 +462,19 @@ DWARFFormValue::getIndirectCString(const DataExtractor *DS, if (!DS || !DSO) return NULL; uint32_t offset = Value.uval * 4; - uint32_t soffset = DSO->getULEB128(&offset); + uint32_t soffset = DSO->getU32(&offset); return DS->getCStr(&soffset); } +uint64_t +DWARFFormValue::getIndirectAddress(const DataExtractor *DA, + const DWARFCompileUnit *cu) const { + if (!DA) return 0; + + uint32_t offset = Value.uval * cu->getAddressByteSize(); + return DA->getAddress(&offset); +} + 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 7768c18..b863001 100644 --- a/lib/DebugInfo/DWARFFormValue.h +++ b/lib/DebugInfo/DWARFFormValue.h @@ -66,6 +66,8 @@ public: const char *getAsCString(const DataExtractor *debug_str_data_ptr) const; const char *getIndirectCString(const DataExtractor *, const DataExtractor *) const; + uint64_t getIndirectAddress(const DataExtractor *, + const DWARFCompileUnit *) 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, |