summaryrefslogtreecommitdiffstats
path: root/llvm/lib/DebugInfo
diff options
context:
space:
mode:
authorPavel Labath <labath@google.com>2018-06-13 08:14:27 +0000
committerPavel Labath <labath@google.com>2018-06-13 08:14:27 +0000
commit4adc88ed25b313b1dc6594f3b00d1a206f5449b6 (patch)
treebe04e2b6d57a26947082c18f4564d8a77fbab2d5 /llvm/lib/DebugInfo
parent2527c378c67bc274c0a93bb0fabbbabd95405699 (diff)
downloadbcm5719-llvm-4adc88ed25b313b1dc6594f3b00d1a206f5449b6.tar.gz
bcm5719-llvm-4adc88ed25b313b1dc6594f3b00d1a206f5449b6.zip
[DWARF/AccelTable] Remove getDIESectionOffset for DWARF v5 entries
Summary: This method was not correct for entries in DWO files as it assumed it could just add up the CU and DIE offsets to get the absolute DIE offset. This is not correct for the DWO files, as here the CU offset will reference the skeleton unit, whereas the DIE offset will be the offset in the full unit in the DWO file. Unfortunately, this means that we are not able to determine the absolute DIE offset using the information in the .debug_names section alone, which means we have to offload some of this work to the users of this class. To demonstrate how this can be done, I've added/fixed the ability to lookup entries using accelerator tables in DWO files in llvm-dwarfdump. To make this happen, I've needed to make two extra changes in other classes: - made the DWARFContext method to lookup a CU based on the section offset public. I've needed this functionality to lookup a CU, and this seems like a useful thing in general. - made DWARFUnit::getDWOId call extractDIEsIfNeeded. Before this, the DWOId was filled in only if the root DIE happened to be parsed before we called the accessor. Since the lazy parsing is supposed to happen under the hood, calling extractDIEsIfNeeded seems appropriate. Reviewers: JDevlieghere, aprantl, dblaikie Subscribers: mgrang, llvm-commits Differential Revision: https://reviews.llvm.org/D48009 llvm-svn: 334578
Diffstat (limited to 'llvm/lib/DebugInfo')
-rw-r--r--llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp8
-rw-r--r--llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp7
2 files changed, 4 insertions, 11 deletions
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp b/llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp
index c2ba9e6027b..0ded97cabf2 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp
@@ -556,14 +556,6 @@ Optional<uint64_t> DWARFDebugNames::Entry::getCUOffset() const {
return NameIdx->getCUOffset(*Index);
}
-Optional<uint64_t> DWARFDebugNames::Entry::getDIESectionOffset() const {
- Optional<uint64_t> CUOff = getCUOffset();
- Optional<uint64_t> DIEOff = getDIEUnitOffset();
- if (CUOff && DIEOff)
- return *CUOff + *DIEOff;
- return None;
-}
-
void DWARFDebugNames::Entry::dump(ScopedPrinter &W) const {
W.printHex("Abbrev", Abbr->Code);
W.startLine() << formatv("Tag: {0}\n", Abbr->Tag);
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp b/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
index fe44071d9a2..e456de5b103 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
@@ -1088,7 +1088,7 @@ unsigned DWARFVerifier::verifyNameIndexEntries(
continue;
}
uint32_t CUOffset = NI.getCUOffset(CUIndex);
- uint64_t DIEOffset = *EntryOr->getDIESectionOffset();
+ uint64_t DIEOffset = CUOffset + *EntryOr->getDIEUnitOffset();
DWARFDie DIE = DCtx.getDIEForOffset(DIEOffset);
if (!DIE) {
error() << formatv("Name Index @ {0:x}: Entry @ {1:x} references a "
@@ -1261,9 +1261,10 @@ unsigned DWARFVerifier::verifyNameIndexCompleteness(
// Now we know that our Die should be present in the Index. Let's check if
// that's the case.
unsigned NumErrors = 0;
+ uint64_t DieUnitOffset = Die.getOffset() - Die.getDwarfUnit()->getOffset();
for (StringRef Name : EntryNames) {
- if (none_of(NI.equal_range(Name), [&Die](const DWARFDebugNames::Entry &E) {
- return E.getDIESectionOffset() == uint64_t(Die.getOffset());
+ if (none_of(NI.equal_range(Name), [&](const DWARFDebugNames::Entry &E) {
+ return E.getDIEUnitOffset() == DieUnitOffset;
})) {
error() << formatv("Name Index @ {0:x}: Entry for DIE @ {1:x} ({2}) with "
"name {3} missing.\n",
OpenPOWER on IntegriCloud