From 21f2955bb289bffe61f68a8b0726bbec24216214 Mon Sep 17 00:00:00 2001 From: Luke Cheeseman Date: Fri, 28 Sep 2018 13:37:27 +0000 Subject: Reapply changes reverted by r343235 - Add fix so that all code paths that create DWARFContext with an ObjectFile initialise the target architecture in the context - Add an assert that the Arch is known in the Dwarf CallFrameString method llvm-svn: 343317 --- llvm/lib/DebugInfo/DWARF/DWARFContext.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'llvm/lib/DebugInfo/DWARF/DWARFContext.cpp') diff --git a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp index 5d9f5a328ae..70eed19de58 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp @@ -725,7 +725,7 @@ const DWARFDebugFrame *DWARFContext::getDebugFrame() { // http://lists.dwarfstd.org/htdig.cgi/dwarf-discuss-dwarfstd.org/2011-December/001173.html DWARFDataExtractor debugFrameData(DObj->getDebugFrameSection(), isLittleEndian(), DObj->getAddressSize()); - DebugFrame.reset(new DWARFDebugFrame(false /* IsEH */)); + DebugFrame.reset(new DWARFDebugFrame(Arch, false /* IsEH */)); DebugFrame->parse(debugFrameData); return DebugFrame.get(); } @@ -736,7 +736,7 @@ const DWARFDebugFrame *DWARFContext::getEHFrame() { DWARFDataExtractor debugFrameData(DObj->getEHFrameSection(), isLittleEndian(), DObj->getAddressSize()); - DebugFrame.reset(new DWARFDebugFrame(true /* IsEH */)); + DebugFrame.reset(new DWARFDebugFrame(Arch, true /* IsEH */)); DebugFrame->parse(debugFrameData); return DebugFrame.get(); } @@ -1571,7 +1571,11 @@ DWARFContext::create(const object::ObjectFile &Obj, const LoadedObjectInfo *L, function_ref HandleError, std::string DWPName) { auto DObj = llvm::make_unique(Obj, L, HandleError); - return llvm::make_unique(std::move(DObj), std::move(DWPName)); + std::unique_ptr Ctx = + llvm::make_unique(std::move(DObj), std::move(DWPName)); + logAllUnhandledErrors(Ctx->loadArchitectureInfo(Obj), errs(), + Obj.getFileName() + ": "); + return Ctx; } std::unique_ptr @@ -1582,9 +1586,11 @@ DWARFContext::create(const StringMap> &Sections, return llvm::make_unique(std::move(DObj), ""); } -Error DWARFContext::loadRegisterInfo(const object::ObjectFile &Obj) { +Error DWARFContext::loadArchitectureInfo(const object::ObjectFile &Obj) { // Detect the architecture from the object file. We usually don't need OS // info to lookup a target and create register info. + Arch = Triple::ArchType(Obj.getArch()); + Triple TT; TT.setArch(Triple::ArchType(Obj.getArch())); TT.setVendor(Triple::UnknownVendor); -- cgit v1.2.3