summaryrefslogtreecommitdiffstats
path: root/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/DebugInfo/DWARF/DWARFContext.cpp')
-rw-r--r--llvm/lib/DebugInfo/DWARF/DWARFContext.cpp79
1 files changed, 36 insertions, 43 deletions
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
index b7bb9c2347a..0c28db31425 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
@@ -138,7 +138,7 @@ static void dumpDWARFv5StringOffsetsSection(
DWARFDataExtractor StrOffsetExt(Obj, StringOffsetsSection, LittleEndian, 0);
DataExtractor StrData(StringSection, LittleEndian, 0);
uint64_t SectionSize = StringOffsetsSection.Data.size();
- uint32_t Offset = 0;
+ uint64_t Offset = 0;
for (auto &Contribution : Contributions) {
// Report an ill-formed contribution.
if (!Contribution) {
@@ -166,10 +166,10 @@ static void dumpDWARFv5StringOffsetsSection(
}
// Report a gap in the table.
if (Offset < ContributionHeader) {
- OS << format("0x%8.8x: Gap, length = ", Offset);
+ OS << format("0x%8.8" PRIx64 ": Gap, length = ", Offset);
OS << (ContributionHeader - Offset) << "\n";
}
- OS << format("0x%8.8x: ", (uint32_t)ContributionHeader);
+ OS << format("0x%8.8" PRIx64 ": ", ContributionHeader);
// In DWARF v5 the contribution size in the descriptor does not equal
// the originally encoded length (it does not contain the length of the
// version field and the padding, a total of 4 bytes). Add them back in
@@ -181,26 +181,19 @@ static void dumpDWARFv5StringOffsetsSection(
Offset = Contribution->Base;
unsigned EntrySize = Contribution->getDwarfOffsetByteSize();
while (Offset - Contribution->Base < Contribution->Size) {
- OS << format("0x%8.8x: ", Offset);
- // FIXME: We can only extract strings if the offset fits in 32 bits.
+ OS << format("0x%8.8" PRIx64 ": ", Offset);
uint64_t StringOffset =
StrOffsetExt.getRelocatedValue(EntrySize, &Offset);
- // Extract the string if we can and display it. Otherwise just report
- // the offset.
- if (StringOffset <= std::numeric_limits<uint32_t>::max()) {
- uint32_t StringOffset32 = (uint32_t)StringOffset;
- OS << format("%8.8x ", StringOffset32);
- const char *S = StrData.getCStr(&StringOffset32);
- if (S)
- OS << format("\"%s\"", S);
- } else
- OS << format("%16.16" PRIx64 " ", StringOffset);
+ OS << format("%8.8" PRIx64 " ", StringOffset);
+ const char *S = StrData.getCStr(&StringOffset);
+ if (S)
+ OS << format("\"%s\"", S);
OS << "\n";
}
}
// Report a gap at the end of the table.
if (Offset < SectionSize) {
- OS << format("0x%8.8x: Gap, length = ", Offset);
+ OS << format("0x%8.8" PRIx64 ": Gap, length = ", Offset);
OS << (SectionSize - Offset) << "\n";
}
}
@@ -225,7 +218,7 @@ static void dumpStringOffsetsSection(raw_ostream &OS, StringRef SectionName,
StringSection, Units, LittleEndian);
else {
DataExtractor strOffsetExt(StringOffsetsSection.Data, LittleEndian, 0);
- uint32_t offset = 0;
+ uint64_t offset = 0;
uint64_t size = StringOffsetsSection.Data.size();
// Ensure that size is a multiple of the size of an entry.
if (size & ((uint64_t)(sizeof(uint32_t) - 1))) {
@@ -235,9 +228,9 @@ static void dumpStringOffsetsSection(raw_ostream &OS, StringRef SectionName,
}
DataExtractor StrData(StringSection, LittleEndian, 0);
while (offset < size) {
- OS << format("0x%8.8x: ", offset);
- uint32_t StringOffset = strOffsetExt.getU32(&offset);
- OS << format("%8.8x ", StringOffset);
+ OS << format("0x%8.8" PRIx64 ": ", offset);
+ uint64_t StringOffset = strOffsetExt.getU32(&offset);
+ OS << format("%8.8" PRIx64 " ", StringOffset);
const char *S = StrData.getCStr(&StringOffset);
if (S)
OS << format("\"%s\"", S);
@@ -250,10 +243,10 @@ static void dumpStringOffsetsSection(raw_ostream &OS, StringRef SectionName,
static void dumpAddrSection(raw_ostream &OS, DWARFDataExtractor &AddrData,
DIDumpOptions DumpOpts, uint16_t Version,
uint8_t AddrSize) {
- uint32_t Offset = 0;
+ uint64_t Offset = 0;
while (AddrData.isValidOffset(Offset)) {
DWARFDebugAddrTable AddrTable;
- uint32_t TableOffset = Offset;
+ uint64_t TableOffset = Offset;
if (Error Err = AddrTable.extract(AddrData, &Offset, Version, AddrSize,
DWARFContext::dumpWarning)) {
WithColor::error() << toString(std::move(Err)) << '\n';
@@ -261,8 +254,7 @@ static void dumpAddrSection(raw_ostream &OS, DWARFDataExtractor &AddrData,
// could be read. If it couldn't, stop reading the section.
if (!AddrTable.hasValidLength())
break;
- uint64_t Length = AddrTable.getLength();
- Offset = TableOffset + Length;
+ Offset = TableOffset + AddrTable.getLength();
} else {
AddrTable.dump(OS, DumpOpts);
}
@@ -275,10 +267,10 @@ static void dumpRnglistsSection(
llvm::function_ref<Optional<object::SectionedAddress>(uint32_t)>
LookupPooledAddress,
DIDumpOptions DumpOpts) {
- uint32_t Offset = 0;
+ uint64_t Offset = 0;
while (rnglistData.isValidOffset(Offset)) {
llvm::DWARFDebugRnglistTable Rnglists;
- uint32_t TableOffset = Offset;
+ uint64_t TableOffset = Offset;
if (Error Err = Rnglists.extract(rnglistData, &Offset)) {
WithColor::error() << toString(std::move(Err)) << '\n';
uint64_t Length = Rnglists.length();
@@ -297,7 +289,7 @@ static void dumpLoclistsSection(raw_ostream &OS, DIDumpOptions DumpOpts,
DWARFDataExtractor Data,
const MCRegisterInfo *MRI,
Optional<uint64_t> DumpOffset) {
- uint32_t Offset = 0;
+ uint64_t Offset = 0;
DWARFDebugLoclists Loclists;
DWARFListTableHeader Header(".debug_loclists", "locations");
@@ -418,7 +410,7 @@ void DWARFContext::dump(
if (shouldDump(Explicit, ".debug_aranges", DIDT_ID_DebugAranges,
DObj->getARangeSection())) {
- uint32_t offset = 0;
+ uint64_t offset = 0;
DataExtractor arangesData(DObj->getARangeSection(), isLittleEndian(), 0);
DWARFDebugArangeSet set;
while (set.extract(arangesData, &offset))
@@ -433,7 +425,8 @@ void DWARFContext::dump(
Parser.skip(dumpWarning);
continue;
}
- OS << "debug_line[" << format("0x%8.8x", Parser.getOffset()) << "]\n";
+ OS << "debug_line[" << format("0x%8.8" PRIx64, Parser.getOffset())
+ << "]\n";
if (DumpOpts.Verbose) {
Parser.parseNext(dumpWarning, dumpWarning, &OS);
} else {
@@ -476,30 +469,30 @@ void DWARFContext::dump(
if (shouldDump(Explicit, ".debug_str", DIDT_ID_DebugStr,
DObj->getStringSection())) {
DataExtractor strData(DObj->getStringSection(), isLittleEndian(), 0);
- uint32_t offset = 0;
- uint32_t strOffset = 0;
+ uint64_t offset = 0;
+ uint64_t strOffset = 0;
while (const char *s = strData.getCStr(&offset)) {
- OS << format("0x%8.8x: \"%s\"\n", strOffset, s);
+ OS << format("0x%8.8" PRIx64 ": \"%s\"\n", strOffset, s);
strOffset = offset;
}
}
if (shouldDump(ExplicitDWO, ".debug_str.dwo", DIDT_ID_DebugStr,
DObj->getStringDWOSection())) {
DataExtractor strDWOData(DObj->getStringDWOSection(), isLittleEndian(), 0);
- uint32_t offset = 0;
- uint32_t strDWOOffset = 0;
+ uint64_t offset = 0;
+ uint64_t strDWOOffset = 0;
while (const char *s = strDWOData.getCStr(&offset)) {
- OS << format("0x%8.8x: \"%s\"\n", strDWOOffset, s);
+ OS << format("0x%8.8" PRIx64 ": \"%s\"\n", strDWOOffset, s);
strDWOOffset = offset;
}
}
if (shouldDump(Explicit, ".debug_line_str", DIDT_ID_DebugLineStr,
DObj->getLineStringSection())) {
DataExtractor strData(DObj->getLineStringSection(), isLittleEndian(), 0);
- uint32_t offset = 0;
- uint32_t strOffset = 0;
+ uint64_t offset = 0;
+ uint64_t strOffset = 0;
while (const char *s = strData.getCStr(&offset)) {
- OS << format("0x%8.8x: \"", strOffset);
+ OS << format("0x%8.8" PRIx64 ": \"", strOffset);
OS.write_escaped(s);
OS << "\"\n";
strOffset = offset;
@@ -518,7 +511,7 @@ void DWARFContext::dump(
uint8_t savedAddressByteSize = getCUAddrSize();
DWARFDataExtractor rangesData(*DObj, DObj->getRangeSection(),
isLittleEndian(), savedAddressByteSize);
- uint32_t offset = 0;
+ uint64_t offset = 0;
DWARFDebugRangeList rangeList;
while (rangesData.isValidOffset(offset)) {
if (Error E = rangeList.extract(rangesData, &offset)) {
@@ -641,7 +634,7 @@ DWARFCompileUnit *DWARFContext::getDWOCompileUnitForHash(uint64_t Hash) {
return nullptr;
}
-DWARFDie DWARFContext::getDIEForOffset(uint32_t Offset) {
+DWARFDie DWARFContext::getDIEForOffset(uint64_t Offset) {
parseNormalUnits();
if (auto *CU = NormalUnits.getUnitForOffset(Offset))
return CU->getDIEForOffset(Offset);
@@ -858,7 +851,7 @@ Expected<const DWARFDebugLine::LineTable *> DWARFContext::getLineTableForUnit(
if (!Offset)
return nullptr; // No line table for this compile unit.
- uint32_t stmtOffset = *Offset + U->getLineTableOffset();
+ uint64_t stmtOffset = *Offset + U->getLineTableOffset();
// See if the line table is cached.
if (const DWARFLineTable *lt = Line->getLineTable(stmtOffset))
return lt;
@@ -898,7 +891,7 @@ void DWARFContext::parseDWOUnits(bool Lazy) {
});
}
-DWARFCompileUnit *DWARFContext::getCompileUnitForOffset(uint32_t Offset) {
+DWARFCompileUnit *DWARFContext::getCompileUnitForOffset(uint64_t Offset) {
parseNormalUnits();
return dyn_cast_or_null<DWARFCompileUnit>(
NormalUnits.getUnitForOffset(Offset));
@@ -906,7 +899,7 @@ DWARFCompileUnit *DWARFContext::getCompileUnitForOffset(uint32_t Offset) {
DWARFCompileUnit *DWARFContext::getCompileUnitForAddress(uint64_t Address) {
// First, get the offset of the compile unit.
- uint32_t CUOffset = getDebugAranges()->findAddress(Address);
+ uint64_t CUOffset = getDebugAranges()->findAddress(Address);
// Retrieve the compile unit.
return getCompileUnitForOffset(CUOffset);
}
OpenPOWER on IntegriCloud