From: Alexey Samsonov Date: Wed, 4 Nov 2015 00:30:26 +0000 (+0000) Subject: [LLVMSymbolize] Reduce indentation by using helper function. NFC. X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=3cdfe0ea1c92d8b7f8026188edf0a25a88dd18c2;p=oota-llvm.git [LLVMSymbolize] Reduce indentation by using helper function. NFC. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@252022 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/DebugInfo/Symbolize/Symbolize.h b/include/llvm/DebugInfo/Symbolize/Symbolize.h index 7871a2653a5..230dc759a97 100644 --- a/include/llvm/DebugInfo/Symbolize/Symbolize.h +++ b/include/llvm/DebugInfo/Symbolize/Symbolize.h @@ -70,6 +70,9 @@ private: ObjectFile *lookUpDsymFile(const std::string &Path, const MachOObjectFile *ExeObj, const std::string &ArchName); + ObjectFile *lookUpDebuglinkObject(const std::string &Path, + const ObjectFile *Obj, + const std::string &ArchName); /// \brief Returns pair of pointers to object and debug object. ErrorOr getOrCreateObjects(const std::string &Path, diff --git a/lib/DebugInfo/Symbolize/Symbolize.cpp b/lib/DebugInfo/Symbolize/Symbolize.cpp index b0e17cfd3ff..ba7d39cbdb3 100644 --- a/lib/DebugInfo/Symbolize/Symbolize.cpp +++ b/lib/DebugInfo/Symbolize/Symbolize.cpp @@ -244,6 +244,28 @@ ObjectFile *LLVMSymbolizer::lookUpDsymFile(const std::string &ExePath, return nullptr; } +ObjectFile *LLVMSymbolizer::lookUpDebuglinkObject(const std::string &Path, + const ObjectFile *Obj, + const std::string &ArchName) { + std::string DebuglinkName; + uint32_t CRCHash; + std::string DebugBinaryPath; + if (!getGNUDebuglinkContents(Obj, DebuglinkName, CRCHash)) + return nullptr; + if (!findDebugBinary(Path, DebuglinkName, CRCHash, DebugBinaryPath)) + return nullptr; + ErrorOr> DebugBinaryOrErr = + createBinary(DebugBinaryPath); + if (!DebugBinaryOrErr) + return nullptr; + OwningBinary &DB = DebugBinaryOrErr.get(); + auto DbgObjOrErr = getObjectFileFromBinary(DB.getBinary(), ArchName); + if (!DbgObjOrErr) + return nullptr; + addOwningBinary(std::move(DB)); + return DbgObjOrErr.get(); +} + ErrorOr LLVMSymbolizer::getOrCreateObjects(const std::string &Path, const std::string &ArchName) { @@ -273,27 +295,8 @@ LLVMSymbolizer::getOrCreateObjects(const std::string &Path, if (auto MachObj = dyn_cast(Obj)) DbgObj = lookUpDsymFile(Path, MachObj, ArchName); - // Try to locate the debug binary using .gnu_debuglink section. - if (!DbgObj) { - std::string DebuglinkName; - uint32_t CRCHash; - std::string DebugBinaryPath; - if (getGNUDebuglinkContents(Obj, DebuglinkName, CRCHash) && - findDebugBinary(Path, DebuglinkName, CRCHash, DebugBinaryPath)) { - ErrorOr> DebugBinaryOrErr = - createBinary(DebugBinaryPath); - if (DebugBinaryOrErr) { - OwningBinary &DB = DebugBinaryOrErr.get(); - auto DbgObjOrErr = getObjectFileFromBinary(DB.getBinary(), ArchName); - if (DbgObjOrErr) { - DbgObj = DbgObjOrErr.get(); - assert(DbgObj != nullptr); - addOwningBinary(std::move(DB)); - } - } - } - } - + if (!DbgObj) + DbgObj = lookUpDebuglinkObject(Path, Obj, ArchName); if (!DbgObj) DbgObj = Obj; ObjectPair Res = std::make_pair(Obj, DbgObj);