[llvm] r252022 - [LLVMSymbolize] Reduce indentation by using helper function. NFC.

Alexey Samsonov via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 3 16:30:27 PST 2015


Author: samsonov
Date: Tue Nov  3 18:30:26 2015
New Revision: 252022

URL: http://llvm.org/viewvc/llvm-project?rev=252022&view=rev
Log:
[LLVMSymbolize] Reduce indentation by using helper function. NFC.

Modified:
    llvm/trunk/include/llvm/DebugInfo/Symbolize/Symbolize.h
    llvm/trunk/lib/DebugInfo/Symbolize/Symbolize.cpp

Modified: llvm/trunk/include/llvm/DebugInfo/Symbolize/Symbolize.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/Symbolize/Symbolize.h?rev=252022&r1=252021&r2=252022&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/Symbolize/Symbolize.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/Symbolize/Symbolize.h Tue Nov  3 18:30:26 2015
@@ -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<ObjectPair> getOrCreateObjects(const std::string &Path,

Modified: llvm/trunk/lib/DebugInfo/Symbolize/Symbolize.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/Symbolize/Symbolize.cpp?rev=252022&r1=252021&r2=252022&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/Symbolize/Symbolize.cpp (original)
+++ llvm/trunk/lib/DebugInfo/Symbolize/Symbolize.cpp Tue Nov  3 18:30:26 2015
@@ -244,6 +244,28 @@ ObjectFile *LLVMSymbolizer::lookUpDsymFi
   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<OwningBinary<Binary>> DebugBinaryOrErr =
+      createBinary(DebugBinaryPath);
+  if (!DebugBinaryOrErr)
+    return nullptr;
+  OwningBinary<Binary> &DB = DebugBinaryOrErr.get();
+  auto DbgObjOrErr = getObjectFileFromBinary(DB.getBinary(), ArchName);
+  if (!DbgObjOrErr)
+    return nullptr;
+  addOwningBinary(std::move(DB));
+  return DbgObjOrErr.get();
+}
+
 ErrorOr<LLVMSymbolizer::ObjectPair>
 LLVMSymbolizer::getOrCreateObjects(const std::string &Path,
                                    const std::string &ArchName) {
@@ -273,27 +295,8 @@ LLVMSymbolizer::getOrCreateObjects(const
 
   if (auto MachObj = dyn_cast<const MachOObjectFile>(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<OwningBinary<Binary>> DebugBinaryOrErr =
-          createBinary(DebugBinaryPath);
-      if (DebugBinaryOrErr) {
-        OwningBinary<Binary> &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);




More information about the llvm-commits mailing list