Skip to content

Commit

Permalink
Store TypeUnits in a SmallVector<DWARFUnitSection> instead of a singl…
Browse files Browse the repository at this point in the history
…e DWARFUnitSection.

Summary:
There will be multiple TypeUnits in an unlinked object that will be extracted
from different sections. Now that we have DWARFUnitSection that is supposed
to represent an input section, we need a DWARFUnitSection<TypeUnit> per
input .debug_types section.

Once this is done, the interface is homogenous and we can move the Section
parsing code into DWARFUnitSection.

Reviewers: samsonov, dblaikie

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D5482

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218513 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
fredriss committed Sep 26, 2014
1 parent 12aa552 commit 5fb5bdb
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 16 deletions.
26 changes: 16 additions & 10 deletions lib/DebugInfo/DWARFContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,17 @@ void DWARFContext::dump(raw_ostream &OS, DIDumpType DumpType) {

if ((DumpType == DIDT_All || DumpType == DIDT_Types) && getNumTypeUnits()) {
OS << "\n.debug_types contents:\n";
for (const auto &TU : type_units())
TU->dump(OS);
for (const auto &TUS : type_unit_sections())
for (const auto &TU : TUS)
TU->dump(OS);
}

if ((DumpType == DIDT_All || DumpType == DIDT_TypesDwo) &&
getNumDWOTypeUnits()) {
OS << "\n.debug_types.dwo contents:\n";
for (const auto &DWOTU : dwo_type_units())
DWOTU->dump(OS);
for (const auto &DWOTUS : dwo_type_unit_sections())
for (const auto &DWOTU : DWOTUS)
DWOTU->dump(OS);
}

if (DumpType == DIDT_All || DumpType == DIDT_Loc) {
Expand Down Expand Up @@ -337,15 +339,17 @@ void DWARFContext::parseTypeUnits() {
uint32_t offset = 0;
const DataExtractor &DIData =
DataExtractor(I.second.Data, isLittleEndian(), 0);
TUs.push_back(DWARFUnitSection<DWARFTypeUnit>());
auto &TUS = TUs.back();
while (DIData.isValidOffset(offset)) {
std::unique_ptr<DWARFTypeUnit> TU(new DWARFTypeUnit(*this,
getDebugAbbrev(), I.second.Data, getRangeSection(),
getStringSection(), StringRef(), getAddrSection(),
&I.second.Relocs, isLittleEndian(), TUs));
&I.second.Relocs, isLittleEndian(), TUS));
if (!TU->extract(DIData, &offset))
break;
TUs.push_back(std::move(TU));
offset = TUs.back()->getNextUnitOffset();
TUS.push_back(std::move(TU));
offset = TUS.back()->getNextUnitOffset();
}
}
}
Expand Down Expand Up @@ -376,15 +380,17 @@ void DWARFContext::parseDWOTypeUnits() {
uint32_t offset = 0;
const DataExtractor &DIData =
DataExtractor(I.second.Data, isLittleEndian(), 0);
DWOTUs.push_back(DWARFUnitSection<DWARFTypeUnit>());
auto &TUS = DWOTUs.back();
while (DIData.isValidOffset(offset)) {
std::unique_ptr<DWARFTypeUnit> TU(new DWARFTypeUnit(*this,
getDebugAbbrevDWO(), I.second.Data, getRangeDWOSection(),
getStringDWOSection(), getStringOffsetDWOSection(), getAddrSection(),
&I.second.Relocs, isLittleEndian(), DWOTUs));
&I.second.Relocs, isLittleEndian(), TUS));
if (!TU->extract(DIData, &offset))
break;
DWOTUs.push_back(std::move(TU));
offset = DWOTUs.back()->getNextUnitOffset();
TUS.push_back(std::move(TU));
offset = TUS.back()->getNextUnitOffset();
}
}
}
Expand Down
13 changes: 7 additions & 6 deletions lib/DebugInfo/DWARFContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ namespace llvm {
class DWARFContext : public DIContext {

DWARFUnitSection<DWARFCompileUnit> CUs;
DWARFUnitSection<DWARFTypeUnit> TUs;
SmallVector<DWARFUnitSection<DWARFTypeUnit>,1> TUs;
std::unique_ptr<DWARFDebugAbbrev> Abbrev;
std::unique_ptr<DWARFDebugLoc> Loc;
std::unique_ptr<DWARFDebugAranges> Aranges;
std::unique_ptr<DWARFDebugLine> Line;
std::unique_ptr<DWARFDebugFrame> DebugFrame;

DWARFUnitSection<DWARFCompileUnit> DWOCUs;
DWARFUnitSection<DWARFTypeUnit> DWOTUs;
SmallVector<DWARFUnitSection<DWARFTypeUnit>,1> DWOTUs;
std::unique_ptr<DWARFDebugAbbrev> AbbrevDWO;
std::unique_ptr<DWARFDebugLocDWO> LocDWO;

Expand Down Expand Up @@ -77,6 +77,7 @@ class DWARFContext : public DIContext {

typedef DWARFUnitSection<DWARFCompileUnit>::iterator_range cu_iterator_range;
typedef DWARFUnitSection<DWARFTypeUnit>::iterator_range tu_iterator_range;
typedef iterator_range<SmallVectorImpl<DWARFUnitSection<DWARFTypeUnit>>::iterator> tu_section_iterator_range;

/// Get compile units in this context.
cu_iterator_range compile_units() {
Expand All @@ -85,9 +86,9 @@ class DWARFContext : public DIContext {
}

/// Get type units in this context.
tu_iterator_range type_units() {
tu_section_iterator_range type_unit_sections() {
parseTypeUnits();
return tu_iterator_range(TUs.begin(), TUs.end());
return tu_section_iterator_range(TUs.begin(), TUs.end());
}

/// Get compile units in the DWO context.
Expand All @@ -97,9 +98,9 @@ class DWARFContext : public DIContext {
}

/// Get type units in the DWO context.
tu_iterator_range dwo_type_units() {
tu_section_iterator_range dwo_type_unit_sections() {
parseDWOTypeUnits();
return tu_iterator_range(DWOTUs.begin(), DWOTUs.end());
return tu_section_iterator_range(DWOTUs.begin(), DWOTUs.end());
}

/// Get the number of compile units in this context.
Expand Down

0 comments on commit 5fb5bdb

Please sign in to comment.