aboutsummaryrefslogtreecommitdiff
path: root/tools/obj2yaml/dwarf2yaml.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tools/obj2yaml/dwarf2yaml.cpp')
-rw-r--r--tools/obj2yaml/dwarf2yaml.cpp37
1 files changed, 22 insertions, 15 deletions
diff --git a/tools/obj2yaml/dwarf2yaml.cpp b/tools/obj2yaml/dwarf2yaml.cpp
index cbf34ed5388a..d41b44c06810 100644
--- a/tools/obj2yaml/dwarf2yaml.cpp
+++ b/tools/obj2yaml/dwarf2yaml.cpp
@@ -17,6 +17,13 @@
using namespace llvm;
+void dumpInitialLength(DataExtractor &Data, uint32_t &Offset,
+ DWARFYAML::InitialLength &InitialLength) {
+ InitialLength.TotalLength = Data.getU32(&Offset);
+ if (InitialLength.isDWARF64())
+ InitialLength.TotalLength64 = Data.getU64(&Offset);
+}
+
void dumpDebugAbbrev(DWARFContextInMemory &DCtx, DWARFYAML::Data &Y) {
auto AbbrevSetPtr = DCtx.getDebugAbbrev();
if (AbbrevSetPtr) {
@@ -31,6 +38,8 @@ void dumpDebugAbbrev(DWARFContextInMemory &DCtx, DWARFYAML::Data &Y) {
DWARFYAML::AttributeAbbrev AttAbrv;
AttAbrv.Attribute = Attribute.Attr;
AttAbrv.Form = Attribute.Form;
+ if (AttAbrv.Form == dwarf::DW_FORM_implicit_const)
+ AttAbrv.Value = *Attribute.ByteSizeOrValue;
Abbrv.Attributes.push_back(AttAbrv);
}
Y.AbbrevDecls.push_back(Abbrv);
@@ -55,7 +64,7 @@ void dumpDebugARanges(DWARFContextInMemory &DCtx, DWARFYAML::Data &Y) {
while (Set.extract(ArangesData, &Offset)) {
DWARFYAML::ARange Range;
- Range.Length = Set.getHeader().Length;
+ Range.Length.setLength(Set.getHeader().Length);
Range.Version = Set.getHeader().Version;
Range.CuOffset = Set.getHeader().CuOffset;
Range.AddrSize = Set.getHeader().AddrSize;
@@ -74,11 +83,11 @@ void dumpPubSection(DWARFContextInMemory &DCtx, DWARFYAML::PubSection &Y,
StringRef Section) {
DataExtractor PubSectionData(Section, DCtx.isLittleEndian(), 0);
uint32_t Offset = 0;
- Y.Length = PubSectionData.getU32(&Offset);
+ dumpInitialLength(PubSectionData, Offset, Y.Length);
Y.Version = PubSectionData.getU16(&Offset);
Y.UnitOffset = PubSectionData.getU32(&Offset);
Y.UnitSize = PubSectionData.getU32(&Offset);
- while (Offset < Y.Length) {
+ while (Offset < Y.Length.getLength()) {
DWARFYAML::PubEntry NewEntry;
NewEntry.DieOffset = PubSectionData.getU32(&Offset);
if (Y.IsGNUStyle)
@@ -105,8 +114,10 @@ void dumpDebugPubSections(DWARFContextInMemory &DCtx, DWARFYAML::Data &Y) {
void dumpDebugInfo(DWARFContextInMemory &DCtx, DWARFYAML::Data &Y) {
for (const auto &CU : DCtx.compile_units()) {
DWARFYAML::Unit NewUnit;
- NewUnit.Length = CU->getLength();
+ NewUnit.Length.setLength(CU->getLength());
NewUnit.Version = CU->getVersion();
+ if(NewUnit.Version >= 5)
+ NewUnit.Type = (dwarf::UnitType)CU->getUnitType();
NewUnit.AbbrOffset = CU->getAbbreviations()->getOffset();
NewUnit.AddrSize = CU->getAddressByteSize();
for (auto DIE : CU->dies()) {
@@ -126,7 +137,7 @@ void dumpDebugInfo(DWARFContextInMemory &DCtx, DWARFYAML::Data &Y) {
DWARFYAML::FormValue NewValue;
NewValue.Value = 0xDEADBEEFDEADBEEF;
DWARFDie DIEWrapper(CU.get(), &DIE);
- auto FormValue = DIEWrapper.getAttributeValue(AttrSpec.Attr);
+ auto FormValue = DIEWrapper.find(AttrSpec.Attr);
if (!FormValue)
return;
auto Form = FormValue.getValue().getForm();
@@ -168,6 +179,8 @@ void dumpDebugInfo(DWARFContextInMemory &DCtx, DWARFYAML::Data &Y) {
case dwarf::DW_FORM_data8:
case dwarf::DW_FORM_sdata:
case dwarf::DW_FORM_udata:
+ case dwarf::DW_FORM_ref_sup4:
+ case dwarf::DW_FORM_ref_sup8:
if (auto Val = FormValue.getValue().getAsUnsignedConstant())
NewValue.Value = Val.getValue();
break;
@@ -189,7 +202,6 @@ void dumpDebugInfo(DWARFContextInMemory &DCtx, DWARFYAML::Data &Y) {
case dwarf::DW_FORM_GNU_strp_alt:
case dwarf::DW_FORM_line_strp:
case dwarf::DW_FORM_strp_sup:
- case dwarf::DW_FORM_ref_sup:
case dwarf::DW_FORM_GNU_str_index:
if (auto Val = FormValue.getValue().getAsCStringOffset())
NewValue.Value = Val.getValue();
@@ -228,19 +240,14 @@ void dumpDebugLines(DWARFContextInMemory &DCtx, DWARFYAML::Data &Y) {
if (!CUDIE)
continue;
if (auto StmtOffset =
- CUDIE.getAttributeValueAsSectionOffset(dwarf::DW_AT_stmt_list)) {
+ dwarf::toSectionOffset(CUDIE.find(dwarf::DW_AT_stmt_list))) {
DWARFYAML::LineTable DebugLines;
DataExtractor LineData(DCtx.getLineSection().Data, DCtx.isLittleEndian(),
CU->getAddressByteSize());
uint32_t Offset = *StmtOffset;
- uint64_t SizeOfPrologueLength = 4;
- DebugLines.TotalLength = LineData.getU32(&Offset);
- uint64_t LineTableLength = DebugLines.TotalLength;
- if (DebugLines.TotalLength == UINT32_MAX) {
- DebugLines.TotalLength64 = LineData.getU64(&Offset);
- LineTableLength = DebugLines.TotalLength64;
- SizeOfPrologueLength = 8;
- }
+ dumpInitialLength(LineData, Offset, DebugLines.Length);
+ uint64_t LineTableLength = DebugLines.Length.getLength();
+ uint64_t SizeOfPrologueLength = DebugLines.Length.isDWARF64() ? 8 : 4;
DebugLines.Version = LineData.getU16(&Offset);
DebugLines.PrologueLength =
LineData.getUnsigned(&Offset, SizeOfPrologueLength);