diff --git a/llvm/tools/obj2yaml/dwarf2yaml.cpp b/llvm/tools/obj2yaml/dwarf2yaml.cpp --- a/llvm/tools/obj2yaml/dwarf2yaml.cpp +++ b/llvm/tools/obj2yaml/dwarf2yaml.cpp @@ -26,7 +26,7 @@ InitialLength.TotalLength64 = Data.getU64(&Offset); } -void dumpDebugAbbrev(DWARFContext &DCtx, DWARFYAML::Data &Y) { +Error dumpDebugAbbrev(DWARFContext &DCtx, DWARFYAML::Data &Y) { auto AbbrevSetPtr = DCtx.getDebugAbbrev(); if (AbbrevSetPtr) { for (auto AbbrvDeclSet : *AbbrevSetPtr) { @@ -48,15 +48,19 @@ } } } + + return Error::success(); } -void dumpDebugStrings(DWARFContext &DCtx, DWARFYAML::Data &Y) { +Error dumpDebugStrings(DWARFContext &DCtx, DWARFYAML::Data &Y) { StringRef RemainingTable = DCtx.getDWARFObj().getStrSection(); while (RemainingTable.size() > 0) { auto SymbolPair = RemainingTable.split('\0'); RemainingTable = SymbolPair.second; Y.DebugStrings.push_back(SymbolPair.first); } + + return Error::success(); } Error dumpDebugARanges(DWARFContext &DCtx, DWARFYAML::Data &Y) { @@ -142,7 +146,7 @@ return Y; } -void dumpDebugPubSections(DWARFContext &DCtx, DWARFYAML::Data &Y) { +Error dumpDebugPubSections(DWARFContext &DCtx, DWARFYAML::Data &Y) { const DWARFObject &D = DCtx.getDWARFObj(); const DWARFSection PubNames = D.getPubnamesSection(); @@ -162,9 +166,11 @@ if (!GNUPubTypes.Data.empty()) // TODO: Test dumping .debug_gnu_pubtypes section. Y.GNUPubTypes = dumpPubSection(DCtx, GNUPubTypes, /*IsGNUStyle=*/true); + + return Error::success(); } -void dumpDebugInfo(DWARFContext &DCtx, DWARFYAML::Data &Y) { +Error dumpDebugInfo(DWARFContext &DCtx, DWARFYAML::Data &Y) { for (const auto &CU : DCtx.compile_units()) { DWARFYAML::Unit NewUnit; NewUnit.Format = CU->getFormat(); @@ -193,7 +199,7 @@ DWARFDie DIEWrapper(CU.get(), &DIE); auto FormValue = DIEWrapper.find(AttrSpec.Attr); if (!FormValue) - return; + return Error::success(); auto Form = FormValue.getValue().getForm(); bool indirect = false; do { @@ -276,6 +282,8 @@ } Y.CompileUnits.push_back(NewUnit); } + + return Error::success(); } bool dumpFileEntry(DataExtractor &Data, uint64_t &Offset, @@ -289,7 +297,7 @@ return true; } -void dumpDebugLines(DWARFContext &DCtx, DWARFYAML::Data &Y) { +Error dumpDebugLines(DWARFContext &DCtx, DWARFYAML::Data &Y) { for (const auto &CU : DCtx.compile_units()) { auto CUDIE = CU->getUnitDIE(); if (!CUDIE) @@ -404,17 +412,24 @@ Y.DebugLines.push_back(DebugLines); } } + + return Error::success(); } llvm::Error dwarf2yaml(DWARFContext &DCtx, DWARFYAML::Data &Y) { - dumpDebugAbbrev(DCtx, Y); - dumpDebugStrings(DCtx, Y); + if (Error E = dumpDebugAbbrev(DCtx, Y)) + return E; + if (Error E = dumpDebugStrings(DCtx, Y)) + return E; if (Error E = dumpDebugARanges(DCtx, Y)) return E; if (Error E = dumpDebugRanges(DCtx, Y)) return E; - dumpDebugPubSections(DCtx, Y); - dumpDebugInfo(DCtx, Y); - dumpDebugLines(DCtx, Y); + if (Error E = dumpDebugPubSections(DCtx, Y)) + return E; + if (Error E = dumpDebugInfo(DCtx, Y)) + return E; + if (Error E = dumpDebugLines(DCtx, Y)) + return E; return ErrorSuccess(); }