summaryrefslogtreecommitdiffstats
path: root/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
diff options
context:
space:
mode:
authorPavel Labath <labath@google.com>2018-06-01 10:33:11 +0000
committerPavel Labath <labath@google.com>2018-06-01 10:33:11 +0000
commitd6ca063907988beee6fbbd99aa436996a2d621ca (patch)
tree05f8ae2c718cc28c78793feb676243d2934add9d /llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
parent823b056f583f24961be8a1ca65dcc1aeb2fff096 (diff)
downloadbcm5719-llvm-d6ca063907988beee6fbbd99aa436996a2d621ca.tar.gz
bcm5719-llvm-d6ca063907988beee6fbbd99aa436996a2d621ca.zip
DWARFAcceleratorTable: Add an iterator-based api for accessing names in the index
Summary: Back when we were introducing the DWARF v5 name index, there was a short discussion whether we shouldn't have a nicer api for iterating over the index. At that time, I did not find it necessary since the iteration over names was done only from within the index itself (and I figured the internal implementation can deal with a slightly rough interface). However, now I ran into a use for this kind of API in LLDB (for finding all names matching a regular expression), so it looked like a nice opportunity to introduce one. To make the API more useful, I've made the NameTableEntry class a bit smarter: it now stores the string section reference (so it can return its name) and its position in the name index (mainly useful for dumping/logging). I also convert the internal users to use the new API, which also gives test coverage for the added code. Reviewers: JDevlieghere, aprantl, dblaikie Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D47590 llvm-svn: 333738
Diffstat (limited to 'llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp')
-rw-r--r--llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp37
1 files changed, 18 insertions, 19 deletions
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp b/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
index 67da9ccaefd..fe44071d9a2 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
@@ -920,8 +920,7 @@ DWARFVerifier::verifyNameIndexBuckets(const DWARFDebugNames::NameIndex &NI,
if (Hash % NI.getBucketCount() != B.Bucket)
break;
- auto NTE = NI.getNameTableEntry(Idx);
- const char *Str = StrData.getCStr(&NTE.StringOffset);
+ const char *Str = NI.getNameTableEntry(Idx).getString();
if (caseFoldingDjbHash(Str) != Hash) {
error() << formatv("Name Index @ {0:x}: String ({1}) at index {2} "
"hashes to {3:x}, but "
@@ -1057,30 +1056,29 @@ static SmallVector<StringRef, 2> getNames(const DWARFDie &DIE) {
return Result;
}
-unsigned
-DWARFVerifier::verifyNameIndexEntries(const DWARFDebugNames::NameIndex &NI,
- uint32_t Name,
- const DataExtractor &StrData) {
+unsigned DWARFVerifier::verifyNameIndexEntries(
+ const DWARFDebugNames::NameIndex &NI,
+ const DWARFDebugNames::NameTableEntry &NTE) {
// Verifying type unit indexes not supported.
if (NI.getLocalTUCount() + NI.getForeignTUCount() > 0)
return 0;
- DWARFDebugNames::NameTableEntry NTE = NI.getNameTableEntry(Name);
- const char *CStr = StrData.getCStr(&NTE.StringOffset);
+ const char *CStr = NTE.getString();
if (!CStr) {
error() << formatv(
"Name Index @ {0:x}: Unable to get string associated with name {1}.\n",
- NI.getUnitOffset(), Name);
+ NI.getUnitOffset(), NTE.getIndex());
return 1;
}
StringRef Str(CStr);
unsigned NumErrors = 0;
unsigned NumEntries = 0;
- uint32_t EntryID = NTE.EntryOffset;
- Expected<DWARFDebugNames::Entry> EntryOr = NI.getEntry(&NTE.EntryOffset);
- for (; EntryOr; ++NumEntries, EntryID = NTE.EntryOffset,
- EntryOr = NI.getEntry(&NTE.EntryOffset)) {
+ uint32_t EntryID = NTE.getEntryOffset();
+ uint32_t NextEntryID = EntryID;
+ Expected<DWARFDebugNames::Entry> EntryOr = NI.getEntry(&NextEntryID);
+ for (; EntryOr; ++NumEntries, EntryID = NextEntryID,
+ EntryOr = NI.getEntry(&NextEntryID)) {
uint32_t CUIndex = *EntryOr->getCUIndex();
if (CUIndex > NI.getCUCount()) {
error() << formatv("Name Index @ {0:x}: Entry @ {1:x} contains an "
@@ -1129,13 +1127,14 @@ DWARFVerifier::verifyNameIndexEntries(const DWARFDebugNames::NameIndex &NI,
return;
error() << formatv("Name Index @ {0:x}: Name {1} ({2}) is "
"not associated with any entries.\n",
- NI.getUnitOffset(), Name, Str);
+ NI.getUnitOffset(), NTE.getIndex(), Str);
++NumErrors;
},
[&](const ErrorInfoBase &Info) {
- error() << formatv(
- "Name Index @ {0:x}: Name {1} ({2}): {3}\n",
- NI.getUnitOffset(), Name, Str, Info.message());
+ error()
+ << formatv("Name Index @ {0:x}: Name {1} ({2}): {3}\n",
+ NI.getUnitOffset(), NTE.getIndex(), Str,
+ Info.message());
++NumErrors;
});
return NumErrors;
@@ -1302,8 +1301,8 @@ unsigned DWARFVerifier::verifyDebugNames(const DWARFSection &AccelSection,
if (NumErrors > 0)
return NumErrors;
for (const auto &NI : AccelTable)
- for (uint64_t Name = 1; Name <= NI.getNameCount(); ++Name)
- NumErrors += verifyNameIndexEntries(NI, Name, StrData);
+ for (DWARFDebugNames::NameTableEntry NTE : NI)
+ NumErrors += verifyNameIndexEntries(NI, NTE);
if (NumErrors > 0)
return NumErrors;
OpenPOWER on IntegriCloud