diff options
author | Alexey Samsonov <samsonov@google.com> | 2013-08-27 09:20:22 +0000 |
---|---|---|
committer | Alexey Samsonov <samsonov@google.com> | 2013-08-27 09:20:22 +0000 |
commit | e3ba81bf19295fbbc4dd58007c02203b396ae617 (patch) | |
tree | fff8a410275f31d336d2887f5b492ced7cdceb45 /llvm/lib/DebugInfo/DWARFFormValue.cpp | |
parent | cb3f0ed817b1e53a583058cd74ad2f4e03c81f8a (diff) | |
download | bcm5719-llvm-e3ba81bf19295fbbc4dd58007c02203b396ae617.tar.gz bcm5719-llvm-e3ba81bf19295fbbc4dd58007c02203b396ae617.zip |
Add support for DebugFission to DWARF parser
Summary:
1) Make llvm-symbolizer properly symbolize
files with split debug info (by using stanalone .dwo files).
2) Make DWARFCompileUnit parse and store corresponding .dwo file,
if necessary.
3) Make bits of DWARF parsing more CompileUnit-oriented.
Reviewers: echristo
Reviewed By: echristo
CC: bkramer, llvm-commits
Differential Revision: http://llvm-reviews.chandlerc.com/D1164
llvm-svn: 189329
Diffstat (limited to 'llvm/lib/DebugInfo/DWARFFormValue.cpp')
-rw-r--r-- | llvm/lib/DebugInfo/DWARFFormValue.cpp | 61 |
1 files changed, 29 insertions, 32 deletions
diff --git a/llvm/lib/DebugInfo/DWARFFormValue.cpp b/llvm/lib/DebugInfo/DWARFFormValue.cpp index 1a1cf2452cd..48e0d209080 100644 --- a/llvm/lib/DebugInfo/DWARFFormValue.cpp +++ b/llvm/lib/DebugInfo/DWARFFormValue.cpp @@ -183,10 +183,9 @@ DWARFFormValue::extractValue(DataExtractor data, uint32_t *offset_ptr, Value.uval = data.getU64(offset_ptr); break; case DW_FORM_GNU_addr_index: - Value.uval = data.getULEB128(offset_ptr); - break; case DW_FORM_GNU_str_index: Value.uval = data.getULEB128(offset_ptr); + Value.IsDWOIndex = true; break; default: return false; @@ -322,12 +321,11 @@ 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 + uint64_t Address; + if (cu->getAddrOffsetSectionItem(uvalue, Address)) + OS << format("0x%016" PRIx64, Address); + else OS << "<no .debug_addr section>"; break; } @@ -376,7 +374,7 @@ DWARFFormValue::dump(raw_ostream &OS, const DWARFCompileUnit *cu) const { case DW_FORM_udata: OS << getUnsigned(); break; case DW_FORM_strp: { OS << format(" .debug_str[0x%8.8x] = ", (uint32_t)uvalue); - const char* dbg_str = getAsCString(&debug_str_data); + const char* dbg_str = getAsCString(cu); if (dbg_str) { OS << '"'; OS.write_escaped(dbg_str); @@ -386,8 +384,7 @@ DWARFFormValue::dump(raw_ostream &OS, const DWARFCompileUnit *cu) const { } 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); + const char *dbg_str = getAsCString(cu); if (dbg_str) { OS << '"'; OS.write_escaped(dbg_str); @@ -440,33 +437,33 @@ DWARFFormValue::dump(raw_ostream &OS, const DWARFCompileUnit *cu) const { } const char* -DWARFFormValue::getAsCString(const DataExtractor *debug_str_data_ptr) const { - if (isInlinedCStr()) { +DWARFFormValue::getAsCString(const DWARFCompileUnit *CU) const { + if (isInlinedCStr()) return Value.cstr; - } else if (debug_str_data_ptr) { - uint32_t offset = Value.uval; - return debug_str_data_ptr->getCStr(&offset); + if (!CU) + return NULL; + uint32_t Offset = Value.uval; + if (Value.IsDWOIndex) { + uint32_t StrOffset; + if (!CU->getStringOffsetSectionItem(Offset, StrOffset)) + return NULL; + Offset = StrOffset; } - 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->getU32(&offset); - return DS->getCStr(&soffset); + return CU->getStringExtractor().getCStr(&Offset); } 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); +DWARFFormValue::getAsAddress(const DWARFCompileUnit *CU) const { + if (!CU) + return 0; + if (Value.IsDWOIndex) { + uint32_t Index = Value.uval; + uint64_t Address; + if (!CU->getAddrOffsetSectionItem(Index, Address)) + return 0; + return Address; + } + return Value.uval; } uint64_t DWARFFormValue::getReference(const DWARFCompileUnit *cu) const { |