forked from OSchip/llvm-project
[DebugInfo/DWARF] Remove redundant iterator type. NFC
llvm-svn: 338759
This commit is contained in:
parent
90f3249ce2
commit
96545db374
|
@ -132,49 +132,60 @@ public:
|
||||||
|
|
||||||
bool verify(raw_ostream &OS, DIDumpOptions DumpOpts = {}) override;
|
bool verify(raw_ostream &OS, DIDumpOptions DumpOpts = {}) override;
|
||||||
|
|
||||||
using cu_iterator_range = DWARFUnitVector::iterator_range;
|
using unit_iterator_range = DWARFUnitVector::iterator_range;
|
||||||
using tu_iterator_range = DWARFUnitVector::iterator_range;
|
|
||||||
|
|
||||||
/// Get units from .debug_info in this context.
|
/// Get units from .debug_info in this context.
|
||||||
cu_iterator_range info_section_units() {
|
unit_iterator_range info_section_units() {
|
||||||
parseNormalUnits();
|
parseNormalUnits();
|
||||||
return cu_iterator_range(NormalUnits.begin(),
|
return unit_iterator_range(NormalUnits.begin(),
|
||||||
NormalUnits.begin() +
|
NormalUnits.begin() +
|
||||||
NormalUnits.getNumInfoUnits());
|
NormalUnits.getNumInfoUnits());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get units from .debug_types in this context.
|
/// Get units from .debug_types in this context.
|
||||||
tu_iterator_range types_section_units() {
|
unit_iterator_range types_section_units() {
|
||||||
parseNormalUnits();
|
parseNormalUnits();
|
||||||
return tu_iterator_range(
|
return unit_iterator_range(
|
||||||
NormalUnits.begin() + NormalUnits.getNumInfoUnits(), NormalUnits.end());
|
NormalUnits.begin() + NormalUnits.getNumInfoUnits(), NormalUnits.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get compile units in this context.
|
/// Get compile units in this context.
|
||||||
cu_iterator_range compile_units() { return info_section_units(); }
|
unit_iterator_range compile_units() { return info_section_units(); }
|
||||||
|
|
||||||
/// Get type units in this context.
|
/// Get type units in this context.
|
||||||
tu_iterator_range type_units() { return types_section_units(); }
|
unit_iterator_range type_units() { return types_section_units(); }
|
||||||
|
|
||||||
|
/// Get all normal compile/type units in this context.
|
||||||
|
unit_iterator_range normal_units() {
|
||||||
|
parseNormalUnits();
|
||||||
|
return unit_iterator_range(NormalUnits.begin(), NormalUnits.end());
|
||||||
|
}
|
||||||
|
|
||||||
/// Get units from .debug_info..dwo in the DWO context.
|
/// Get units from .debug_info..dwo in the DWO context.
|
||||||
cu_iterator_range dwo_info_section_units() {
|
unit_iterator_range dwo_info_section_units() {
|
||||||
parseDWOUnits();
|
parseDWOUnits();
|
||||||
return cu_iterator_range(DWOUnits.begin(),
|
return unit_iterator_range(DWOUnits.begin(),
|
||||||
DWOUnits.begin() + DWOUnits.getNumInfoUnits());
|
DWOUnits.begin() + DWOUnits.getNumInfoUnits());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get units from .debug_types.dwo in the DWO context.
|
/// Get units from .debug_types.dwo in the DWO context.
|
||||||
tu_iterator_range dwo_types_section_units() {
|
unit_iterator_range dwo_types_section_units() {
|
||||||
parseDWOUnits();
|
parseDWOUnits();
|
||||||
return tu_iterator_range(DWOUnits.begin() + DWOUnits.getNumInfoUnits(),
|
return unit_iterator_range(DWOUnits.begin() + DWOUnits.getNumInfoUnits(),
|
||||||
DWOUnits.end());
|
DWOUnits.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get compile units in the DWO context.
|
/// Get compile units in the DWO context.
|
||||||
cu_iterator_range dwo_compile_units() { return dwo_info_section_units(); }
|
unit_iterator_range dwo_compile_units() { return dwo_info_section_units(); }
|
||||||
|
|
||||||
/// Get type units in the DWO context.
|
/// Get type units in the DWO context.
|
||||||
tu_iterator_range dwo_type_units() { return dwo_types_section_units(); }
|
unit_iterator_range dwo_type_units() { return dwo_types_section_units(); }
|
||||||
|
|
||||||
|
/// Get all units in the DWO context.
|
||||||
|
unit_iterator_range dwo_units() {
|
||||||
|
parseDWOUnits();
|
||||||
|
return unit_iterator_range(DWOUnits.begin(), DWOUnits.end());
|
||||||
|
}
|
||||||
|
|
||||||
/// Get the number of compile units in this context.
|
/// Get the number of compile units in this context.
|
||||||
unsigned getNumCompileUnits() {
|
unsigned getNumCompileUnits() {
|
||||||
|
|
|
@ -99,13 +99,10 @@ using ContributionCollection =
|
||||||
// Collect all the contributions to the string offsets table from all units,
|
// Collect all the contributions to the string offsets table from all units,
|
||||||
// sort them by their starting offsets and remove duplicates.
|
// sort them by their starting offsets and remove duplicates.
|
||||||
static ContributionCollection
|
static ContributionCollection
|
||||||
collectContributionData(DWARFContext::cu_iterator_range CUs,
|
collectContributionData(DWARFContext::unit_iterator_range Units) {
|
||||||
DWARFContext::tu_iterator_range TUs) {
|
|
||||||
ContributionCollection Contributions;
|
ContributionCollection Contributions;
|
||||||
for (const auto &CU : CUs)
|
for (const auto &U : Units)
|
||||||
Contributions.push_back(CU->getStringOffsetsTableContribution());
|
Contributions.push_back(U->getStringOffsetsTableContribution());
|
||||||
for (const auto &TU : TUs)
|
|
||||||
Contributions.push_back(TU->getStringOffsetsTableContribution());
|
|
||||||
// Sort the contributions so that any invalid ones are placed at
|
// Sort the contributions so that any invalid ones are placed at
|
||||||
// the start of the contributions vector. This way they are reported
|
// the start of the contributions vector. This way they are reported
|
||||||
// first.
|
// first.
|
||||||
|
@ -134,9 +131,8 @@ collectContributionData(DWARFContext::cu_iterator_range CUs,
|
||||||
static void dumpDWARFv5StringOffsetsSection(
|
static void dumpDWARFv5StringOffsetsSection(
|
||||||
raw_ostream &OS, StringRef SectionName, const DWARFObject &Obj,
|
raw_ostream &OS, StringRef SectionName, const DWARFObject &Obj,
|
||||||
const DWARFSection &StringOffsetsSection, StringRef StringSection,
|
const DWARFSection &StringOffsetsSection, StringRef StringSection,
|
||||||
DWARFContext::cu_iterator_range CUs, DWARFContext::tu_iterator_range TUs,
|
DWARFContext::unit_iterator_range Units, bool LittleEndian) {
|
||||||
bool LittleEndian) {
|
auto Contributions = collectContributionData(Units);
|
||||||
auto Contributions = collectContributionData(CUs, TUs);
|
|
||||||
DWARFDataExtractor StrOffsetExt(Obj, StringOffsetsSection, LittleEndian, 0);
|
DWARFDataExtractor StrOffsetExt(Obj, StringOffsetsSection, LittleEndian, 0);
|
||||||
DataExtractor StrData(StringSection, LittleEndian, 0);
|
DataExtractor StrData(StringSection, LittleEndian, 0);
|
||||||
uint64_t SectionSize = StringOffsetsSection.Data.size();
|
uint64_t SectionSize = StringOffsetsSection.Data.size();
|
||||||
|
@ -217,15 +213,14 @@ static void dumpStringOffsetsSection(raw_ostream &OS, StringRef SectionName,
|
||||||
const DWARFObject &Obj,
|
const DWARFObject &Obj,
|
||||||
const DWARFSection &StringOffsetsSection,
|
const DWARFSection &StringOffsetsSection,
|
||||||
StringRef StringSection,
|
StringRef StringSection,
|
||||||
DWARFContext::cu_iterator_range CUs,
|
DWARFContext::unit_iterator_range Units,
|
||||||
DWARFContext::tu_iterator_range TUs,
|
|
||||||
bool LittleEndian, unsigned MaxVersion) {
|
bool LittleEndian, unsigned MaxVersion) {
|
||||||
// If we have at least one (compile or type) unit with DWARF v5 or greater,
|
// If we have at least one (compile or type) unit with DWARF v5 or greater,
|
||||||
// we assume that the section is formatted like a DWARF v5 string offsets
|
// we assume that the section is formatted like a DWARF v5 string offsets
|
||||||
// section.
|
// section.
|
||||||
if (MaxVersion >= 5)
|
if (MaxVersion >= 5)
|
||||||
dumpDWARFv5StringOffsetsSection(OS, SectionName, Obj, StringOffsetsSection,
|
dumpDWARFv5StringOffsetsSection(OS, SectionName, Obj, StringOffsetsSection,
|
||||||
StringSection, CUs, TUs, LittleEndian);
|
StringSection, Units, LittleEndian);
|
||||||
else {
|
else {
|
||||||
DataExtractor strOffsetExt(StringOffsetsSection.Data, LittleEndian, 0);
|
DataExtractor strOffsetExt(StringOffsetsSection.Data, LittleEndian, 0);
|
||||||
uint32_t offset = 0;
|
uint32_t offset = 0;
|
||||||
|
@ -340,14 +335,14 @@ void DWARFContext::dump(
|
||||||
getDebugAbbrevDWO()->dump(OS);
|
getDebugAbbrevDWO()->dump(OS);
|
||||||
|
|
||||||
auto dumpDebugInfo = [&](bool IsExplicit, const char *Name,
|
auto dumpDebugInfo = [&](bool IsExplicit, const char *Name,
|
||||||
DWARFSection Section, cu_iterator_range CUs) {
|
DWARFSection Section, unit_iterator_range Units) {
|
||||||
if (shouldDump(IsExplicit, Name, DIDT_ID_DebugInfo, Section.Data)) {
|
if (shouldDump(IsExplicit, Name, DIDT_ID_DebugInfo, Section.Data)) {
|
||||||
if (DumpOffset)
|
if (DumpOffset)
|
||||||
getDIEForOffset(DumpOffset.getValue())
|
getDIEForOffset(DumpOffset.getValue())
|
||||||
.dump(OS, 0, DumpOpts.noImplicitRecursion());
|
.dump(OS, 0, DumpOpts.noImplicitRecursion());
|
||||||
else
|
else
|
||||||
for (const auto &CU : CUs)
|
for (const auto &U : Units)
|
||||||
CU->dump(OS, DumpOpts);
|
U->dump(OS, DumpOpts);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
dumpDebugInfo(Explicit, ".debug_info", DObj->getInfoSection(),
|
dumpDebugInfo(Explicit, ".debug_info", DObj->getInfoSection(),
|
||||||
|
@ -355,15 +350,15 @@ void DWARFContext::dump(
|
||||||
dumpDebugInfo(ExplicitDWO, ".debug_info.dwo", DObj->getInfoDWOSection(),
|
dumpDebugInfo(ExplicitDWO, ".debug_info.dwo", DObj->getInfoDWOSection(),
|
||||||
dwo_info_section_units());
|
dwo_info_section_units());
|
||||||
|
|
||||||
auto dumpDebugType = [&](const char *Name, tu_iterator_range TUs) {
|
auto dumpDebugType = [&](const char *Name, unit_iterator_range Units) {
|
||||||
OS << '\n' << Name << " contents:\n";
|
OS << '\n' << Name << " contents:\n";
|
||||||
DumpOffset = DumpOffsets[DIDT_ID_DebugTypes];
|
DumpOffset = DumpOffsets[DIDT_ID_DebugTypes];
|
||||||
for (const auto &TU : TUs)
|
for (const auto &U : Units)
|
||||||
if (DumpOffset)
|
if (DumpOffset)
|
||||||
TU->getDIEForOffset(*DumpOffset)
|
U->getDIEForOffset(*DumpOffset)
|
||||||
.dump(OS, 0, DumpOpts.noImplicitRecursion());
|
.dump(OS, 0, DumpOpts.noImplicitRecursion());
|
||||||
else
|
else
|
||||||
TU->dump(OS, DumpOpts);
|
U->dump(OS, DumpOpts);
|
||||||
};
|
};
|
||||||
if ((DumpType & DIDT_DebugTypes)) {
|
if ((DumpType & DIDT_DebugTypes)) {
|
||||||
if (Explicit || getNumTypeUnits())
|
if (Explicit || getNumTypeUnits())
|
||||||
|
@ -546,14 +541,14 @@ void DWARFContext::dump(
|
||||||
DObj->getStringOffsetSection().Data))
|
DObj->getStringOffsetSection().Data))
|
||||||
dumpStringOffsetsSection(OS, "debug_str_offsets", *DObj,
|
dumpStringOffsetsSection(OS, "debug_str_offsets", *DObj,
|
||||||
DObj->getStringOffsetSection(),
|
DObj->getStringOffsetSection(),
|
||||||
DObj->getStringSection(), compile_units(),
|
DObj->getStringSection(), normal_units(),
|
||||||
type_units(), isLittleEndian(), getMaxVersion());
|
isLittleEndian(), getMaxVersion());
|
||||||
if (shouldDump(ExplicitDWO, ".debug_str_offsets.dwo", DIDT_ID_DebugStrOffsets,
|
if (shouldDump(ExplicitDWO, ".debug_str_offsets.dwo", DIDT_ID_DebugStrOffsets,
|
||||||
DObj->getStringOffsetDWOSection().Data))
|
DObj->getStringOffsetDWOSection().Data))
|
||||||
dumpStringOffsetsSection(
|
dumpStringOffsetsSection(OS, "debug_str_offsets.dwo", *DObj,
|
||||||
OS, "debug_str_offsets.dwo", *DObj, DObj->getStringOffsetDWOSection(),
|
DObj->getStringOffsetDWOSection(),
|
||||||
DObj->getStringDWOSection(), dwo_compile_units(), dwo_type_units(),
|
DObj->getStringDWOSection(), dwo_units(),
|
||||||
isLittleEndian(), getMaxVersion());
|
isLittleEndian(), getMaxVersion());
|
||||||
|
|
||||||
if (shouldDump(Explicit, ".gnu_index", DIDT_ID_GdbIndex,
|
if (shouldDump(Explicit, ".gnu_index", DIDT_ID_GdbIndex,
|
||||||
DObj->getGdbIndexSection())) {
|
DObj->getGdbIndexSection())) {
|
||||||
|
|
|
@ -282,7 +282,8 @@ using HandlerFn = std::function<bool(ObjectFile &, DWARFContext &DICtx, Twine,
|
||||||
|
|
||||||
/// Print only DIEs that have a certain name.
|
/// Print only DIEs that have a certain name.
|
||||||
static void filterByName(const StringSet<> &Names,
|
static void filterByName(const StringSet<> &Names,
|
||||||
DWARFContext::cu_iterator_range CUs, raw_ostream &OS) {
|
DWARFContext::unit_iterator_range CUs,
|
||||||
|
raw_ostream &OS) {
|
||||||
for (const auto &CU : CUs)
|
for (const auto &CU : CUs)
|
||||||
for (const auto &Entry : CU->dies()) {
|
for (const auto &Entry : CU->dies()) {
|
||||||
DWARFDie Die = {CU.get(), &Entry};
|
DWARFDie Die = {CU.get(), &Entry};
|
||||||
|
@ -306,7 +307,6 @@ static void filterByName(const StringSet<> &Names,
|
||||||
Die.dump(OS, 0, getDumpOpts());
|
Die.dump(OS, 0, getDumpOpts());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void getDies(DWARFContext &DICtx, const AppleAcceleratorTable &Accel,
|
static void getDies(DWARFContext &DICtx, const AppleAcceleratorTable &Accel,
|
||||||
|
|
Loading…
Reference in New Issue