mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-21 03:32:21 +00:00
Store TypeUnits in a SmallVector<DWARFUnitSection> instead of a single DWARFUnitSection.
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. This is a respin of r218513 that got reverted because it broke some builders. This new version features an explicit move constructor for the DWARFUnitSection class to workaround compilers unable to generate correct C++11 default constructors. Reviewers: samsonov, dblaikie Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D5482 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218606 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
dbaeb6e7cb
commit
97552d7c1c
@ -86,15 +86,17 @@ void DWARFContext::dump(raw_ostream &OS, DIDumpType DumpType) {
|
|||||||
|
|
||||||
if ((DumpType == DIDT_All || DumpType == DIDT_Types) && getNumTypeUnits()) {
|
if ((DumpType == DIDT_All || DumpType == DIDT_Types) && getNumTypeUnits()) {
|
||||||
OS << "\n.debug_types contents:\n";
|
OS << "\n.debug_types contents:\n";
|
||||||
for (const auto &TU : type_units())
|
for (const auto &TUS : type_unit_sections())
|
||||||
TU->dump(OS);
|
for (const auto &TU : TUS)
|
||||||
|
TU->dump(OS);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((DumpType == DIDT_All || DumpType == DIDT_TypesDwo) &&
|
if ((DumpType == DIDT_All || DumpType == DIDT_TypesDwo) &&
|
||||||
getNumDWOTypeUnits()) {
|
getNumDWOTypeUnits()) {
|
||||||
OS << "\n.debug_types.dwo contents:\n";
|
OS << "\n.debug_types.dwo contents:\n";
|
||||||
for (const auto &DWOTU : dwo_type_units())
|
for (const auto &DWOTUS : dwo_type_unit_sections())
|
||||||
DWOTU->dump(OS);
|
for (const auto &DWOTU : DWOTUS)
|
||||||
|
DWOTU->dump(OS);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DumpType == DIDT_All || DumpType == DIDT_Loc) {
|
if (DumpType == DIDT_All || DumpType == DIDT_Loc) {
|
||||||
@ -337,15 +339,17 @@ void DWARFContext::parseTypeUnits() {
|
|||||||
uint32_t offset = 0;
|
uint32_t offset = 0;
|
||||||
const DataExtractor &DIData =
|
const DataExtractor &DIData =
|
||||||
DataExtractor(I.second.Data, isLittleEndian(), 0);
|
DataExtractor(I.second.Data, isLittleEndian(), 0);
|
||||||
|
TUs.push_back(DWARFUnitSection<DWARFTypeUnit>());
|
||||||
|
auto &TUS = TUs.back();
|
||||||
while (DIData.isValidOffset(offset)) {
|
while (DIData.isValidOffset(offset)) {
|
||||||
std::unique_ptr<DWARFTypeUnit> TU(new DWARFTypeUnit(*this,
|
std::unique_ptr<DWARFTypeUnit> TU(new DWARFTypeUnit(*this,
|
||||||
getDebugAbbrev(), I.second.Data, getRangeSection(),
|
getDebugAbbrev(), I.second.Data, getRangeSection(),
|
||||||
getStringSection(), StringRef(), getAddrSection(),
|
getStringSection(), StringRef(), getAddrSection(),
|
||||||
&I.second.Relocs, isLittleEndian(), TUs));
|
&I.second.Relocs, isLittleEndian(), TUS));
|
||||||
if (!TU->extract(DIData, &offset))
|
if (!TU->extract(DIData, &offset))
|
||||||
break;
|
break;
|
||||||
TUs.push_back(std::move(TU));
|
TUS.push_back(std::move(TU));
|
||||||
offset = TUs.back()->getNextUnitOffset();
|
offset = TUS.back()->getNextUnitOffset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -376,15 +380,17 @@ void DWARFContext::parseDWOTypeUnits() {
|
|||||||
uint32_t offset = 0;
|
uint32_t offset = 0;
|
||||||
const DataExtractor &DIData =
|
const DataExtractor &DIData =
|
||||||
DataExtractor(I.second.Data, isLittleEndian(), 0);
|
DataExtractor(I.second.Data, isLittleEndian(), 0);
|
||||||
|
DWOTUs.push_back(DWARFUnitSection<DWARFTypeUnit>());
|
||||||
|
auto &TUS = DWOTUs.back();
|
||||||
while (DIData.isValidOffset(offset)) {
|
while (DIData.isValidOffset(offset)) {
|
||||||
std::unique_ptr<DWARFTypeUnit> TU(new DWARFTypeUnit(*this,
|
std::unique_ptr<DWARFTypeUnit> TU(new DWARFTypeUnit(*this,
|
||||||
getDebugAbbrevDWO(), I.second.Data, getRangeDWOSection(),
|
getDebugAbbrevDWO(), I.second.Data, getRangeDWOSection(),
|
||||||
getStringDWOSection(), getStringOffsetDWOSection(), getAddrSection(),
|
getStringDWOSection(), getStringOffsetDWOSection(), getAddrSection(),
|
||||||
&I.second.Relocs, isLittleEndian(), DWOTUs));
|
&I.second.Relocs, isLittleEndian(), TUS));
|
||||||
if (!TU->extract(DIData, &offset))
|
if (!TU->extract(DIData, &offset))
|
||||||
break;
|
break;
|
||||||
DWOTUs.push_back(std::move(TU));
|
TUS.push_back(std::move(TU));
|
||||||
offset = DWOTUs.back()->getNextUnitOffset();
|
offset = TUS.back()->getNextUnitOffset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
#include "llvm/ADT/MapVector.h"
|
#include "llvm/ADT/MapVector.h"
|
||||||
#include "llvm/ADT/SmallVector.h"
|
#include "llvm/ADT/SmallVector.h"
|
||||||
#include "llvm/DebugInfo/DIContext.h"
|
#include "llvm/DebugInfo/DIContext.h"
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
|
|
||||||
@ -30,7 +31,7 @@ namespace llvm {
|
|||||||
class DWARFContext : public DIContext {
|
class DWARFContext : public DIContext {
|
||||||
|
|
||||||
DWARFUnitSection<DWARFCompileUnit> CUs;
|
DWARFUnitSection<DWARFCompileUnit> CUs;
|
||||||
DWARFUnitSection<DWARFTypeUnit> TUs;
|
std::vector<DWARFUnitSection<DWARFTypeUnit>> TUs;
|
||||||
std::unique_ptr<DWARFDebugAbbrev> Abbrev;
|
std::unique_ptr<DWARFDebugAbbrev> Abbrev;
|
||||||
std::unique_ptr<DWARFDebugLoc> Loc;
|
std::unique_ptr<DWARFDebugLoc> Loc;
|
||||||
std::unique_ptr<DWARFDebugAranges> Aranges;
|
std::unique_ptr<DWARFDebugAranges> Aranges;
|
||||||
@ -38,7 +39,7 @@ class DWARFContext : public DIContext {
|
|||||||
std::unique_ptr<DWARFDebugFrame> DebugFrame;
|
std::unique_ptr<DWARFDebugFrame> DebugFrame;
|
||||||
|
|
||||||
DWARFUnitSection<DWARFCompileUnit> DWOCUs;
|
DWARFUnitSection<DWARFCompileUnit> DWOCUs;
|
||||||
DWARFUnitSection<DWARFTypeUnit> DWOTUs;
|
std::vector<DWARFUnitSection<DWARFTypeUnit>> DWOTUs;
|
||||||
std::unique_ptr<DWARFDebugAbbrev> AbbrevDWO;
|
std::unique_ptr<DWARFDebugAbbrev> AbbrevDWO;
|
||||||
std::unique_ptr<DWARFDebugLocDWO> LocDWO;
|
std::unique_ptr<DWARFDebugLocDWO> LocDWO;
|
||||||
|
|
||||||
@ -77,6 +78,7 @@ public:
|
|||||||
|
|
||||||
typedef DWARFUnitSection<DWARFCompileUnit>::iterator_range cu_iterator_range;
|
typedef DWARFUnitSection<DWARFCompileUnit>::iterator_range cu_iterator_range;
|
||||||
typedef DWARFUnitSection<DWARFTypeUnit>::iterator_range tu_iterator_range;
|
typedef DWARFUnitSection<DWARFTypeUnit>::iterator_range tu_iterator_range;
|
||||||
|
typedef iterator_range<std::vector<DWARFUnitSection<DWARFTypeUnit>>::iterator> tu_section_iterator_range;
|
||||||
|
|
||||||
/// Get compile units in this context.
|
/// Get compile units in this context.
|
||||||
cu_iterator_range compile_units() {
|
cu_iterator_range compile_units() {
|
||||||
@ -85,9 +87,9 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Get type units in this context.
|
/// Get type units in this context.
|
||||||
tu_iterator_range type_units() {
|
tu_section_iterator_range type_unit_sections() {
|
||||||
parseTypeUnits();
|
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.
|
/// Get compile units in the DWO context.
|
||||||
@ -97,9 +99,9 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Get type units in the DWO context.
|
/// Get type units in the DWO context.
|
||||||
tu_iterator_range dwo_type_units() {
|
tu_section_iterator_range dwo_type_unit_sections() {
|
||||||
parseDWOTypeUnits();
|
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.
|
/// Get the number of compile units in this context.
|
||||||
|
@ -53,6 +53,10 @@ class DWARFUnitSection final : public SmallVector<std::unique_ptr<UnitType>, 1>,
|
|||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
DWARFUnitSection() {}
|
||||||
|
DWARFUnitSection(DWARFUnitSection &&DUS) :
|
||||||
|
SmallVector<std::unique_ptr<UnitType>, 1>(std::move(DUS)) {}
|
||||||
|
|
||||||
typedef llvm::SmallVectorImpl<std::unique_ptr<UnitType>> UnitVector;
|
typedef llvm::SmallVectorImpl<std::unique_ptr<UnitType>> UnitVector;
|
||||||
typedef typename UnitVector::iterator iterator;
|
typedef typename UnitVector::iterator iterator;
|
||||||
typedef llvm::iterator_range<typename UnitVector::iterator> iterator_range;
|
typedef llvm::iterator_range<typename UnitVector::iterator> iterator_range;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user