mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-11-02 07:11:49 +00:00
Extend the dumping infrastructure to deal with additional
sections for debug info. These are some of the dwo sections from the DWARF5 split debug info proposal. Update the fission-cu.ll testcase to show what we should be able to dump more of now. Work in progress: Ultimately the relocations will be gone for the dwo section and the strings will be a different form (as well as the rest of the sections will be included). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171428 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
278bac3fba
commit
82de10a34c
@ -17,8 +17,7 @@ using namespace llvm;
|
|||||||
using namespace dwarf;
|
using namespace dwarf;
|
||||||
|
|
||||||
DataExtractor DWARFCompileUnit::getDebugInfoExtractor() const {
|
DataExtractor DWARFCompileUnit::getDebugInfoExtractor() const {
|
||||||
return DataExtractor(Context.getInfoSection(),
|
return DataExtractor(InfoSection, isLittleEndian, AddrSize);
|
||||||
Context.isLittleEndian(), getAddressByteSize());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DWARFCompileUnit::extract(DataExtractor debug_info, uint32_t *offset_ptr) {
|
bool DWARFCompileUnit::extract(DataExtractor debug_info, uint32_t *offset_ptr) {
|
||||||
@ -28,7 +27,6 @@ bool DWARFCompileUnit::extract(DataExtractor debug_info, uint32_t *offset_ptr) {
|
|||||||
|
|
||||||
if (debug_info.isValidOffset(*offset_ptr)) {
|
if (debug_info.isValidOffset(*offset_ptr)) {
|
||||||
uint64_t abbrOffset;
|
uint64_t abbrOffset;
|
||||||
const DWARFDebugAbbrev *abbr = Context.getDebugAbbrev();
|
|
||||||
Length = debug_info.getU32(offset_ptr);
|
Length = debug_info.getU32(offset_ptr);
|
||||||
Version = debug_info.getU16(offset_ptr);
|
Version = debug_info.getU16(offset_ptr);
|
||||||
abbrOffset = debug_info.getU32(offset_ptr);
|
abbrOffset = debug_info.getU32(offset_ptr);
|
||||||
@ -36,11 +34,11 @@ bool DWARFCompileUnit::extract(DataExtractor debug_info, uint32_t *offset_ptr) {
|
|||||||
|
|
||||||
bool lengthOK = debug_info.isValidOffset(getNextCompileUnitOffset()-1);
|
bool lengthOK = debug_info.isValidOffset(getNextCompileUnitOffset()-1);
|
||||||
bool versionOK = DWARFContext::isSupportedVersion(Version);
|
bool versionOK = DWARFContext::isSupportedVersion(Version);
|
||||||
bool abbrOffsetOK = Context.getAbbrevSection().size() > abbrOffset;
|
bool abbrOffsetOK = AbbrevSection.size() > abbrOffset;
|
||||||
bool addrSizeOK = AddrSize == 4 || AddrSize == 8;
|
bool addrSizeOK = AddrSize == 4 || AddrSize == 8;
|
||||||
|
|
||||||
if (lengthOK && versionOK && addrSizeOK && abbrOffsetOK && abbr != NULL) {
|
if (lengthOK && versionOK && addrSizeOK && abbrOffsetOK && Abbrev != NULL) {
|
||||||
Abbrevs = abbr->getAbbreviationDeclarationSet(abbrOffset);
|
Abbrevs = Abbrev->getAbbreviationDeclarationSet(abbrOffset);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,8 +77,7 @@ bool DWARFCompileUnit::extractRangeList(uint32_t RangeListOffset,
|
|||||||
DWARFDebugRangeList &RangeList) const {
|
DWARFDebugRangeList &RangeList) const {
|
||||||
// Require that compile unit is extracted.
|
// Require that compile unit is extracted.
|
||||||
assert(DieArray.size() > 0);
|
assert(DieArray.size() > 0);
|
||||||
DataExtractor RangesData(Context.getRangeSection(),
|
DataExtractor RangesData(RangeSection, isLittleEndian, AddrSize);
|
||||||
Context.isLittleEndian(), AddrSize);
|
|
||||||
return RangeList.extract(RangesData, &RangeListOffset);
|
return RangeList.extract(RangesData, &RangeListOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,11 +17,19 @@
|
|||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
|
|
||||||
class DWARFContext;
|
class DWARFDebugAbbrev;
|
||||||
|
class StringRef;
|
||||||
class raw_ostream;
|
class raw_ostream;
|
||||||
|
typedef DenseMap<uint64_t, std::pair<uint8_t, int64_t> > RelocAddrMap;
|
||||||
|
|
||||||
class DWARFCompileUnit {
|
class DWARFCompileUnit {
|
||||||
DWARFContext &Context;
|
const DWARFDebugAbbrev *Abbrev;
|
||||||
|
StringRef InfoSection;
|
||||||
|
StringRef AbbrevSection;
|
||||||
|
StringRef RangeSection;
|
||||||
|
StringRef StringSection;
|
||||||
|
const RelocAddrMap *RelocMap;
|
||||||
|
bool isLittleEndian;
|
||||||
|
|
||||||
uint32_t Offset;
|
uint32_t Offset;
|
||||||
uint32_t Length;
|
uint32_t Length;
|
||||||
@ -32,11 +40,16 @@ class DWARFCompileUnit {
|
|||||||
// The compile unit debug information entry item.
|
// The compile unit debug information entry item.
|
||||||
std::vector<DWARFDebugInfoEntryMinimal> DieArray;
|
std::vector<DWARFDebugInfoEntryMinimal> DieArray;
|
||||||
public:
|
public:
|
||||||
DWARFCompileUnit(DWARFContext &context) : Context(context) {
|
|
||||||
|
DWARFCompileUnit(const DWARFDebugAbbrev *DA, StringRef IS, StringRef AS,
|
||||||
|
StringRef RS, StringRef SS, const RelocAddrMap *M, bool LE) :
|
||||||
|
Abbrev(DA), InfoSection(IS), AbbrevSection(AS),
|
||||||
|
RangeSection(RS), StringSection(SS), RelocMap(M), isLittleEndian(LE) {
|
||||||
clear();
|
clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
DWARFContext &getContext() const { return Context; }
|
StringRef getStringSection() const { return StringSection; }
|
||||||
|
const RelocAddrMap *getRelocMap() const { return RelocMap; }
|
||||||
DataExtractor getDebugInfoExtractor() const;
|
DataExtractor getDebugInfoExtractor() const;
|
||||||
|
|
||||||
bool extract(DataExtractor debug_info, uint32_t* offset_ptr);
|
bool extract(DataExtractor debug_info, uint32_t* offset_ptr);
|
||||||
|
@ -53,10 +53,10 @@ void DWARFContext::dump(raw_ostream &OS) {
|
|||||||
OS << "\n.debug_str contents:\n";
|
OS << "\n.debug_str contents:\n";
|
||||||
DataExtractor strData(getStringSection(), isLittleEndian(), 0);
|
DataExtractor strData(getStringSection(), isLittleEndian(), 0);
|
||||||
offset = 0;
|
offset = 0;
|
||||||
uint32_t lastOffset = 0;
|
uint32_t strOffset = 0;
|
||||||
while (const char *s = strData.getCStr(&offset)) {
|
while (const char *s = strData.getCStr(&offset)) {
|
||||||
OS << format("0x%8.8x: \"%s\"\n", lastOffset, s);
|
OS << format("0x%8.8x: \"%s\"\n", strOffset, s);
|
||||||
lastOffset = offset;
|
strOffset = offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
OS << "\n.debug_ranges contents:\n";
|
OS << "\n.debug_ranges contents:\n";
|
||||||
@ -70,6 +70,22 @@ void DWARFContext::dump(raw_ostream &OS) {
|
|||||||
DWARFDebugRangeList rangeList;
|
DWARFDebugRangeList rangeList;
|
||||||
while (rangeList.extract(rangesData, &offset))
|
while (rangeList.extract(rangesData, &offset))
|
||||||
rangeList.dump(OS);
|
rangeList.dump(OS);
|
||||||
|
|
||||||
|
OS << "\n.debug_abbrev.dwo contents:\n";
|
||||||
|
getDebugAbbrevDWO()->dump(OS);
|
||||||
|
|
||||||
|
OS << "\n.debug_info.dwo contents:\n";
|
||||||
|
for (unsigned i = 0, e = getNumDWOCompileUnits(); i != e; ++i)
|
||||||
|
getDWOCompileUnitAtIndex(i)->dump(OS);
|
||||||
|
|
||||||
|
OS << "\n.debug_str.dwo contents:\n";
|
||||||
|
DataExtractor strDWOData(getStringDWOSection(), isLittleEndian(), 0);
|
||||||
|
offset = 0;
|
||||||
|
uint32_t strDWOOffset = 0;
|
||||||
|
while (const char *s = strDWOData.getCStr(&offset)) {
|
||||||
|
OS << format("0x%8.8x: \"%s\"\n", strDWOOffset, s);
|
||||||
|
strDWOOffset = offset;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const DWARFDebugAbbrev *DWARFContext::getDebugAbbrev() {
|
const DWARFDebugAbbrev *DWARFContext::getDebugAbbrev() {
|
||||||
@ -83,6 +99,16 @@ const DWARFDebugAbbrev *DWARFContext::getDebugAbbrev() {
|
|||||||
return Abbrev.get();
|
return Abbrev.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const DWARFDebugAbbrev *DWARFContext::getDebugAbbrevDWO() {
|
||||||
|
if (AbbrevDWO)
|
||||||
|
return AbbrevDWO.get();
|
||||||
|
|
||||||
|
DataExtractor abbrData(getAbbrevDWOSection(), isLittleEndian(), 0);
|
||||||
|
AbbrevDWO.reset(new DWARFDebugAbbrev());
|
||||||
|
AbbrevDWO->parse(abbrData);
|
||||||
|
return AbbrevDWO.get();
|
||||||
|
}
|
||||||
|
|
||||||
const DWARFDebugAranges *DWARFContext::getDebugAranges() {
|
const DWARFDebugAranges *DWARFContext::getDebugAranges() {
|
||||||
if (Aranges)
|
if (Aranges)
|
||||||
return Aranges.get();
|
return Aranges.get();
|
||||||
@ -124,7 +150,10 @@ void DWARFContext::parseCompileUnits() {
|
|||||||
const DataExtractor &DIData = DataExtractor(getInfoSection(),
|
const DataExtractor &DIData = DataExtractor(getInfoSection(),
|
||||||
isLittleEndian(), 0);
|
isLittleEndian(), 0);
|
||||||
while (DIData.isValidOffset(offset)) {
|
while (DIData.isValidOffset(offset)) {
|
||||||
CUs.push_back(DWARFCompileUnit(*this));
|
CUs.push_back(DWARFCompileUnit(getDebugAbbrev(), getInfoSection(),
|
||||||
|
getAbbrevSection(), getRangeSection(),
|
||||||
|
getStringSection(), &infoRelocMap(),
|
||||||
|
isLittleEndian()));
|
||||||
if (!CUs.back().extract(DIData, &offset)) {
|
if (!CUs.back().extract(DIData, &offset)) {
|
||||||
CUs.pop_back();
|
CUs.pop_back();
|
||||||
break;
|
break;
|
||||||
@ -134,6 +163,26 @@ void DWARFContext::parseCompileUnits() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DWARFContext::parseDWOCompileUnits() {
|
||||||
|
uint32_t offset = 0;
|
||||||
|
const DataExtractor &DIData = DataExtractor(getInfoDWOSection(),
|
||||||
|
isLittleEndian(), 0);
|
||||||
|
while (DIData.isValidOffset(offset)) {
|
||||||
|
DWOCUs.push_back(DWARFCompileUnit(getDebugAbbrevDWO(), getInfoDWOSection(),
|
||||||
|
getAbbrevDWOSection(),
|
||||||
|
getRangeDWOSection(),
|
||||||
|
getStringDWOSection(),
|
||||||
|
&infoDWORelocMap(),
|
||||||
|
isLittleEndian()));
|
||||||
|
if (!DWOCUs.back().extract(DIData, &offset)) {
|
||||||
|
DWOCUs.pop_back();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
offset = DWOCUs.back().getNextCompileUnitOffset();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
struct OffsetComparator {
|
struct OffsetComparator {
|
||||||
bool operator()(const DWARFCompileUnit &LHS,
|
bool operator()(const DWARFCompileUnit &LHS,
|
||||||
@ -322,14 +371,28 @@ DWARFContextInMemory::DWARFContextInMemory(object::ObjectFile *Obj) :
|
|||||||
ARangeSection = data;
|
ARangeSection = data;
|
||||||
else if (name == "debug_str")
|
else if (name == "debug_str")
|
||||||
StringSection = data;
|
StringSection = data;
|
||||||
else if (name == "debug_ranges")
|
else if (name == "debug_ranges") {
|
||||||
|
// FIXME: Use the other dwo range section when we emit it.
|
||||||
|
RangeDWOSection = data;
|
||||||
RangeSection = data;
|
RangeSection = data;
|
||||||
|
}
|
||||||
|
else if (name == "debug_info.dwo")
|
||||||
|
InfoDWOSection = data;
|
||||||
|
else if (name == "debug_abbrev.dwo")
|
||||||
|
AbbrevDWOSection = data;
|
||||||
|
else if (name == "debug_str.dwo")
|
||||||
|
StringDWOSection = data;
|
||||||
// Any more debug info sections go here.
|
// Any more debug info sections go here.
|
||||||
else
|
else
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// TODO: For now only handle relocations for the debug_info section.
|
// TODO: For now only handle relocations for the debug_info section.
|
||||||
if (name != "debug_info")
|
RelocAddrMap *Map;
|
||||||
|
if (name == "debug_info")
|
||||||
|
Map = &InfoRelocMap;
|
||||||
|
else if (name == "debug_info.dwo")
|
||||||
|
Map = &InfoDWORelocMap;
|
||||||
|
else
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (i->begin_relocations() != i->end_relocations()) {
|
if (i->begin_relocations() != i->end_relocations()) {
|
||||||
@ -372,7 +435,7 @@ DWARFContextInMemory::DWARFContextInMemory(object::ObjectFile *Obj) :
|
|||||||
<< " at " << format("%p", Address)
|
<< " at " << format("%p", Address)
|
||||||
<< " with width " << format("%d", R.Width)
|
<< " with width " << format("%d", R.Width)
|
||||||
<< "\n");
|
<< "\n");
|
||||||
RelocMap[Address] = std::make_pair(R.Width, R.Value);
|
Map->insert(std::make_pair(Address, std::make_pair(R.Width, R.Value)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,12 +30,19 @@ class DWARFContext : public DIContext {
|
|||||||
OwningPtr<DWARFDebugAranges> Aranges;
|
OwningPtr<DWARFDebugAranges> Aranges;
|
||||||
OwningPtr<DWARFDebugLine> Line;
|
OwningPtr<DWARFDebugLine> Line;
|
||||||
|
|
||||||
|
SmallVector<DWARFCompileUnit, 1> DWOCUs;
|
||||||
|
OwningPtr<DWARFDebugAbbrev> AbbrevDWO;
|
||||||
|
|
||||||
DWARFContext(DWARFContext &) LLVM_DELETED_FUNCTION;
|
DWARFContext(DWARFContext &) LLVM_DELETED_FUNCTION;
|
||||||
DWARFContext &operator=(DWARFContext &) LLVM_DELETED_FUNCTION;
|
DWARFContext &operator=(DWARFContext &) LLVM_DELETED_FUNCTION;
|
||||||
|
|
||||||
/// Read compile units from the debug_info section and store them in CUs.
|
/// Read compile units from the debug_info section and store them in CUs.
|
||||||
void parseCompileUnits();
|
void parseCompileUnits();
|
||||||
|
|
||||||
|
/// Read compile units from the debug_info.dwo section and store them in
|
||||||
|
/// DWOCUs.
|
||||||
|
void parseDWOCompileUnits();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DWARFContext() {}
|
DWARFContext() {}
|
||||||
virtual void dump(raw_ostream &OS);
|
virtual void dump(raw_ostream &OS);
|
||||||
@ -46,6 +53,14 @@ public:
|
|||||||
parseCompileUnits();
|
parseCompileUnits();
|
||||||
return CUs.size();
|
return CUs.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Get the number of compile units in the DWO context.
|
||||||
|
unsigned getNumDWOCompileUnits() {
|
||||||
|
if (DWOCUs.empty())
|
||||||
|
parseDWOCompileUnits();
|
||||||
|
return DWOCUs.size();
|
||||||
|
}
|
||||||
|
|
||||||
/// Get the compile unit at the specified index for this compile unit.
|
/// Get the compile unit at the specified index for this compile unit.
|
||||||
DWARFCompileUnit *getCompileUnitAtIndex(unsigned index) {
|
DWARFCompileUnit *getCompileUnitAtIndex(unsigned index) {
|
||||||
if (CUs.empty())
|
if (CUs.empty())
|
||||||
@ -53,9 +68,19 @@ public:
|
|||||||
return &CUs[index];
|
return &CUs[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Get the compile unit at the specified index for the DWO compile units.
|
||||||
|
DWARFCompileUnit *getDWOCompileUnitAtIndex(unsigned index) {
|
||||||
|
if (DWOCUs.empty())
|
||||||
|
parseDWOCompileUnits();
|
||||||
|
return &DWOCUs[index];
|
||||||
|
}
|
||||||
|
|
||||||
/// Get a pointer to the parsed DebugAbbrev object.
|
/// Get a pointer to the parsed DebugAbbrev object.
|
||||||
const DWARFDebugAbbrev *getDebugAbbrev();
|
const DWARFDebugAbbrev *getDebugAbbrev();
|
||||||
|
|
||||||
|
/// Get a pointer to the parsed dwo abbreviations object.
|
||||||
|
const DWARFDebugAbbrev *getDebugAbbrevDWO();
|
||||||
|
|
||||||
/// Get a pointer to the parsed DebugAranges object.
|
/// Get a pointer to the parsed DebugAranges object.
|
||||||
const DWARFDebugAranges *getDebugAranges();
|
const DWARFDebugAranges *getDebugAranges();
|
||||||
|
|
||||||
@ -69,7 +94,7 @@ public:
|
|||||||
DILineInfoSpecifier Specifier = DILineInfoSpecifier());
|
DILineInfoSpecifier Specifier = DILineInfoSpecifier());
|
||||||
|
|
||||||
virtual bool isLittleEndian() const = 0;
|
virtual bool isLittleEndian() const = 0;
|
||||||
virtual const RelocAddrMap &relocMap() const = 0;
|
virtual const RelocAddrMap &infoRelocMap() const = 0;
|
||||||
virtual StringRef getInfoSection() = 0;
|
virtual StringRef getInfoSection() = 0;
|
||||||
virtual StringRef getAbbrevSection() = 0;
|
virtual StringRef getAbbrevSection() = 0;
|
||||||
virtual StringRef getARangeSection() = 0;
|
virtual StringRef getARangeSection() = 0;
|
||||||
@ -77,6 +102,13 @@ public:
|
|||||||
virtual StringRef getStringSection() = 0;
|
virtual StringRef getStringSection() = 0;
|
||||||
virtual StringRef getRangeSection() = 0;
|
virtual StringRef getRangeSection() = 0;
|
||||||
|
|
||||||
|
// Sections for DWARF5 split dwarf proposal.
|
||||||
|
virtual StringRef getInfoDWOSection() = 0;
|
||||||
|
virtual StringRef getAbbrevDWOSection() = 0;
|
||||||
|
virtual StringRef getStringDWOSection() = 0;
|
||||||
|
virtual StringRef getRangeDWOSection() = 0;
|
||||||
|
virtual const RelocAddrMap &infoDWORelocMap() const = 0;
|
||||||
|
|
||||||
static bool isSupportedVersion(unsigned version) {
|
static bool isSupportedVersion(unsigned version) {
|
||||||
return version == 2 || version == 3;
|
return version == 2 || version == 3;
|
||||||
}
|
}
|
||||||
@ -95,23 +127,38 @@ private:
|
|||||||
class DWARFContextInMemory : public DWARFContext {
|
class DWARFContextInMemory : public DWARFContext {
|
||||||
virtual void anchor();
|
virtual void anchor();
|
||||||
bool IsLittleEndian;
|
bool IsLittleEndian;
|
||||||
RelocAddrMap RelocMap;
|
RelocAddrMap InfoRelocMap;
|
||||||
StringRef InfoSection;
|
StringRef InfoSection;
|
||||||
StringRef AbbrevSection;
|
StringRef AbbrevSection;
|
||||||
StringRef ARangeSection;
|
StringRef ARangeSection;
|
||||||
StringRef LineSection;
|
StringRef LineSection;
|
||||||
StringRef StringSection;
|
StringRef StringSection;
|
||||||
StringRef RangeSection;
|
StringRef RangeSection;
|
||||||
|
|
||||||
|
// Sections for DWARF5 split dwarf proposal.
|
||||||
|
RelocAddrMap InfoDWORelocMap;
|
||||||
|
StringRef InfoDWOSection;
|
||||||
|
StringRef AbbrevDWOSection;
|
||||||
|
StringRef StringDWOSection;
|
||||||
|
StringRef RangeDWOSection;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DWARFContextInMemory(object::ObjectFile *);
|
DWARFContextInMemory(object::ObjectFile *);
|
||||||
virtual bool isLittleEndian() const { return IsLittleEndian; }
|
virtual bool isLittleEndian() const { return IsLittleEndian; }
|
||||||
virtual const RelocAddrMap &relocMap() const { return RelocMap; }
|
virtual const RelocAddrMap &infoRelocMap() const { return InfoRelocMap; }
|
||||||
virtual StringRef getInfoSection() { return InfoSection; }
|
virtual StringRef getInfoSection() { return InfoSection; }
|
||||||
virtual StringRef getAbbrevSection() { return AbbrevSection; }
|
virtual StringRef getAbbrevSection() { return AbbrevSection; }
|
||||||
virtual StringRef getARangeSection() { return ARangeSection; }
|
virtual StringRef getARangeSection() { return ARangeSection; }
|
||||||
virtual StringRef getLineSection() { return LineSection; }
|
virtual StringRef getLineSection() { return LineSection; }
|
||||||
virtual StringRef getStringSection() { return StringSection; }
|
virtual StringRef getStringSection() { return StringSection; }
|
||||||
virtual StringRef getRangeSection() { return RangeSection; }
|
virtual StringRef getRangeSection() { return RangeSection; }
|
||||||
|
|
||||||
|
// Sections for DWARF5 split dwarf proposal.
|
||||||
|
virtual StringRef getInfoDWOSection() { return InfoDWOSection; }
|
||||||
|
virtual StringRef getAbbrevDWOSection() { return AbbrevDWOSection; }
|
||||||
|
virtual StringRef getStringDWOSection() { return StringDWOSection; }
|
||||||
|
virtual StringRef getRangeDWOSection() { return RangeDWOSection; }
|
||||||
|
virtual const RelocAddrMap &infoDWORelocMap() const { return InfoDWORelocMap; }
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -417,8 +417,7 @@ DWARFDebugInfoEntryMinimal::getAttributeValueAsString(
|
|||||||
const {
|
const {
|
||||||
DWARFFormValue form_value;
|
DWARFFormValue form_value;
|
||||||
if (getAttributeValue(cu, attr, form_value)) {
|
if (getAttributeValue(cu, attr, form_value)) {
|
||||||
DataExtractor stringExtractor(cu->getContext().getStringSection(),
|
DataExtractor stringExtractor(cu->getStringSection(), false, 0);
|
||||||
false, 0);
|
|
||||||
return form_value.getAsCString(&stringExtractor);
|
return form_value.getAsCString(&stringExtractor);
|
||||||
}
|
}
|
||||||
return fail_value;
|
return fail_value;
|
||||||
|
@ -105,8 +105,8 @@ DWARFFormValue::extractValue(DataExtractor data, uint32_t *offset_ptr,
|
|||||||
case DW_FORM_addr:
|
case DW_FORM_addr:
|
||||||
case DW_FORM_ref_addr: {
|
case DW_FORM_ref_addr: {
|
||||||
RelocAddrMap::const_iterator AI
|
RelocAddrMap::const_iterator AI
|
||||||
= cu->getContext().relocMap().find(*offset_ptr);
|
= cu->getRelocMap()->find(*offset_ptr);
|
||||||
if (AI != cu->getContext().relocMap().end()) {
|
if (AI != cu->getRelocMap()->end()) {
|
||||||
const std::pair<uint8_t, int64_t> &R = AI->second;
|
const std::pair<uint8_t, int64_t> &R = AI->second;
|
||||||
Value.uval = data.getUnsigned(offset_ptr, cu->getAddressByteSize()) +
|
Value.uval = data.getUnsigned(offset_ptr, cu->getAddressByteSize()) +
|
||||||
R.second;
|
R.second;
|
||||||
@ -153,8 +153,8 @@ DWARFFormValue::extractValue(DataExtractor data, uint32_t *offset_ptr,
|
|||||||
break;
|
break;
|
||||||
case DW_FORM_strp: {
|
case DW_FORM_strp: {
|
||||||
RelocAddrMap::const_iterator AI
|
RelocAddrMap::const_iterator AI
|
||||||
= cu->getContext().relocMap().find(*offset_ptr);
|
= cu->getRelocMap()->find(*offset_ptr);
|
||||||
if (AI != cu->getContext().relocMap().end()) {
|
if (AI != cu->getRelocMap()->end()) {
|
||||||
const std::pair<uint8_t, int64_t> &R = AI->second;
|
const std::pair<uint8_t, int64_t> &R = AI->second;
|
||||||
Value.uval = data.getU32(offset_ptr) + R.second;
|
Value.uval = data.getU32(offset_ptr) + R.second;
|
||||||
} else
|
} else
|
||||||
@ -320,7 +320,7 @@ DWARFFormValue::skipValue(uint16_t form, DataExtractor debug_info_data,
|
|||||||
|
|
||||||
void
|
void
|
||||||
DWARFFormValue::dump(raw_ostream &OS, const DWARFCompileUnit *cu) const {
|
DWARFFormValue::dump(raw_ostream &OS, const DWARFCompileUnit *cu) const {
|
||||||
DataExtractor debug_str_data(cu->getContext().getStringSection(), true, 0);
|
DataExtractor debug_str_data(cu->getStringSection(), true, 0);
|
||||||
uint64_t uvalue = getUnsigned();
|
uint64_t uvalue = getUnsigned();
|
||||||
bool cu_relative_offset = false;
|
bool cu_relative_offset = false;
|
||||||
|
|
||||||
|
@ -19,11 +19,21 @@
|
|||||||
; DW_AT_low_pc, DW_AT_high_pc, DW_AT_ranges, DW_AT_dwo_name, DW_AT_dwo_id,
|
; DW_AT_low_pc, DW_AT_high_pc, DW_AT_ranges, DW_AT_dwo_name, DW_AT_dwo_id,
|
||||||
; DW_AT_ranges_base, DW_AT_addr_base.
|
; DW_AT_ranges_base, DW_AT_addr_base.
|
||||||
|
|
||||||
|
; CHECK: .debug_info contents:
|
||||||
; CHECK: DW_TAG_compile_unit
|
; CHECK: DW_TAG_compile_unit
|
||||||
; CHECK: DW_AT_GNU_dwo_name [DW_FORM_strp] ( .debug_str[0x00000000] = "baz.c")
|
; CHECK: DW_AT_GNU_dwo_name [DW_FORM_strp] ( .debug_str[0x00000000] = "baz.c")
|
||||||
; CHECK: DW_AT_low_pc [DW_FORM_addr] (0x0000000000000000)
|
; CHECK: DW_AT_low_pc [DW_FORM_addr] (0x0000000000000000)
|
||||||
; CHECK: DW_AT_stmt_list [DW_FORM_data4] (0x00000000)
|
; CHECK: DW_AT_stmt_list [DW_FORM_data4] (0x00000000)
|
||||||
; CHECK: DW_AT_comp_dir [DW_FORM_strp] ( .debug_str[0x00000006] = "/usr/local/google/home/echristo/tmp")
|
; CHECK: DW_AT_comp_dir [DW_FORM_strp] ( .debug_str[0x00000006] = "/usr/local/google/home/echristo/tmp")
|
||||||
|
|
||||||
; Make sure there's only one compile unit for now.
|
; Check that the rest of the compile units have information.
|
||||||
; CHECK-NOT: DW_TAG_compile_unit
|
; FIXME: Strings will ultimately be a different form.
|
||||||
|
; CHECK: .debug_info.dwo contents:
|
||||||
|
; CHECK: DW_TAG_compile_unit
|
||||||
|
; CHECK: DW_AT_producer [DW_FORM_strp]
|
||||||
|
; CHECK: DW_AT_language [DW_FORM_data2] (0x000c)
|
||||||
|
; CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000035] = "baz.c")
|
||||||
|
; CHECK: DW_TAG_base_type
|
||||||
|
; CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000061] = "int")
|
||||||
|
; CHECK: DW_TAG_variable
|
||||||
|
; CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x0000005f] = "a")
|
||||||
|
Loading…
Reference in New Issue
Block a user