summaryrefslogtreecommitdiffstats
path: root/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
diff options
context:
space:
mode:
authorWolfgang Pieb <Wolfgang.Pieb@sony.com>2018-10-29 22:16:47 +0000
committerWolfgang Pieb <Wolfgang.Pieb@sony.com>2018-10-29 22:16:47 +0000
commitfb6cffca098afd3bf3f4885fbf7043e9fc9eea18 (patch)
tree2b55e893b80d525c609078680ccc85f26745ce20 /llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
parent89c1ac7a05c16e67ac89027ed39a7211b2b3a663 (diff)
downloadbcm5719-llvm-fb6cffca098afd3bf3f4885fbf7043e9fc9eea18.tar.gz
bcm5719-llvm-fb6cffca098afd3bf3f4885fbf7043e9fc9eea18.zip
[DWARF][NFC] Refactor range list extraction and dumping
The purpose of this patch is twofold: - Fold pre-DWARF v5 functionality into v5 to eliminate the need for 2 different versions of range list handling. We get rid of DWARFDebugRangelist{.cpp,.h}. - Templatize the handling of range list tables so that location list handling can take advantage of it as well. Location list and range list tables have the same basic layout. A non-NFC version of this patch was previously submitted with r342218, but it caused errors with some TSan tests. This patch has no functional changes. The difference to the non-NFC patch is that there are no changes to rangelist dumping in this patch. Differential Revision: https://reviews.llvm.org/D53545 llvm-svn: 345546
Diffstat (limited to 'llvm/lib/DebugInfo/DWARF/DWARFContext.cpp')
-rw-r--r--llvm/lib/DebugInfo/DWARF/DWARFContext.cpp74
1 files changed, 38 insertions, 36 deletions
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
index a29c9c2f160..3a0f52753b0 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
@@ -25,7 +25,6 @@
#include "llvm/DebugInfo/DWARF/DWARFDebugLoc.h"
#include "llvm/DebugInfo/DWARF/DWARFDebugMacro.h"
#include "llvm/DebugInfo/DWARF/DWARFDebugPubTable.h"
-#include "llvm/DebugInfo/DWARF/DWARFDebugRangeList.h"
#include "llvm/DebugInfo/DWARF/DWARFDebugRnglists.h"
#include "llvm/DebugInfo/DWARF/DWARFDie.h"
#include "llvm/DebugInfo/DWARF/DWARFFormValue.h"
@@ -268,26 +267,31 @@ static void dumpAddrSection(raw_ostream &OS, DWARFDataExtractor &AddrData,
}
}
-// Dump the .debug_rnglists or .debug_rnglists.dwo section (DWARF v5).
+// Dump a section that contains a sequence of tables of lists, such as range
+// or location list tables. In DWARF v5 we expect to find properly formatted
+// tables with headers. In DWARF v4 and earlier we simply expect a sequence of
+// lists, which we treat, mutatis mutandis, like DWARF v5 tables.
+template <typename ListTable>
static void
-dumpRnglistsSection(raw_ostream &OS, DWARFDataExtractor &rnglistData,
- llvm::function_ref<Optional<SectionedAddress>(uint32_t)>
- LookupPooledAddress,
- DIDumpOptions DumpOpts) {
+dumpListSection(raw_ostream &OS, DWARFContext *C, StringRef SectionName,
+ uint16_t MaxVersion, DWARFDataExtractor &ListData,
+ llvm::function_ref<Optional<SectionedAddress>(uint32_t)>
+ LookupPooledAddress,
+ DIDumpOptions DumpOpts, bool isDWO = false) {
uint32_t Offset = 0;
- while (rnglistData.isValidOffset(Offset)) {
- llvm::DWARFDebugRnglistTable Rnglists;
- uint32_t TableOffset = Offset;
- if (Error Err = Rnglists.extract(rnglistData, &Offset)) {
+ while (ListData.isValidOffset(Offset)) {
+ ListTable Table(C, SectionName, isDWO);
+ if (Error Err = Table.extract(ListData, MaxVersion, &Offset)) {
WithColor::error() << toString(std::move(Err)) << '\n';
- uint64_t Length = Rnglists.length();
- // Keep going after an error, if we can, assuming that the length field
- // could be read. If it couldn't, stop reading the section.
- if (Length == 0)
+ // If table extraction set Offset to 0, it indicates that we cannot
+ // continue to read the section.
+ if (Offset == 0)
break;
- Offset = TableOffset + Length;
+ // In DWARF v4 and earlier, dump as much of the lists as we can.
+ if (MaxVersion < 5)
+ Table.dump(OS, LookupPooledAddress, DumpOpts);
} else {
- Rnglists.dump(OS, LookupPooledAddress, DumpOpts);
+ Table.dump(OS, LookupPooledAddress, DumpOpts);
}
}
}
@@ -508,22 +512,6 @@ void DWARFContext::dump(
dumpAddrSection(OS, AddrData, DumpOpts, getMaxVersion(), getCUAddrSize());
}
- if (shouldDump(Explicit, ".debug_ranges", DIDT_ID_DebugRanges,
- DObj->getRangeSection().Data)) {
- uint8_t savedAddressByteSize = getCUAddrSize();
- DWARFDataExtractor rangesData(*DObj, DObj->getRangeSection(),
- isLittleEndian(), savedAddressByteSize);
- uint32_t offset = 0;
- DWARFDebugRangeList rangeList;
- while (rangesData.isValidOffset(offset)) {
- if (Error E = rangeList.extract(rangesData, &offset)) {
- WithColor::error() << toString(std::move(E)) << '\n';
- break;
- }
- rangeList.dump(OS);
- }
- }
-
auto LookupPooledAddress = [&](uint32_t Index) -> Optional<SectionedAddress> {
const auto &CUs = compile_units();
auto I = CUs.begin();
@@ -532,18 +520,32 @@ void DWARFContext::dump(
return (*I)->getAddrOffsetSectionItem(Index);
};
+ if (shouldDump(Explicit, ".debug_ranges", DIDT_ID_DebugRanges,
+ DObj->getRangeSection().Data)) {
+ uint8_t savedAddressByteSize = getCUAddrSize();
+ DWARFDataExtractor rangesData(*DObj, DObj->getRangeSection(),
+ isLittleEndian(), savedAddressByteSize);
+ dumpListSection<DWARFDebugRnglistTable>(OS, this, ".debug_ranges",
+ /* MaxVersion = */ 4, rangesData,
+ LookupPooledAddress, DumpOpts);
+ }
+
if (shouldDump(Explicit, ".debug_rnglists", DIDT_ID_DebugRnglists,
DObj->getRnglistsSection().Data)) {
DWARFDataExtractor RnglistData(*DObj, DObj->getRnglistsSection(),
- isLittleEndian(), 0);
- dumpRnglistsSection(OS, RnglistData, LookupPooledAddress, DumpOpts);
+ isLittleEndian(), getCUAddrSize());
+ dumpListSection<DWARFDebugRnglistTable>(OS, this, ".debug_rnglists",
+ getMaxVersion(5), RnglistData,
+ LookupPooledAddress, DumpOpts);
}
if (shouldDump(ExplicitDWO, ".debug_rnglists.dwo", DIDT_ID_DebugRnglists,
DObj->getRnglistsDWOSection().Data)) {
DWARFDataExtractor RnglistData(*DObj, DObj->getRnglistsDWOSection(),
- isLittleEndian(), 0);
- dumpRnglistsSection(OS, RnglistData, LookupPooledAddress, DumpOpts);
+ isLittleEndian(), getCUAddrSize());
+ dumpListSection<DWARFDebugRnglistTable>(OS, this, ".debug_rnglists.dwo",
+ getMaxVersion(5), RnglistData,
+ LookupPooledAddress, DumpOpts);
}
if (shouldDump(Explicit, ".debug_pubnames", DIDT_ID_DebugPubnames,
OpenPOWER on IntegriCloud