[llvm] r189250 - llvm-symbolizer: use real path when looking for debug binary location

Alexey Samsonov samsonov at google.com
Mon Aug 26 11:12:03 PDT 2013


Author: samsonov
Date: Mon Aug 26 13:12:03 2013
New Revision: 189250

URL: http://llvm.org/viewvc/llvm-project?rev=189250&view=rev
Log:
llvm-symbolizer: use real path when looking for debug binary location

Modified:
    llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.cpp

Modified: llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.cpp?rev=189250&r1=189249&r2=189250&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.cpp (original)
+++ llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.cpp Mon Aug 26 13:12:03 2013
@@ -13,6 +13,7 @@
 
 #include "LLVMSymbolize.h"
 #include "llvm/ADT/STLExtras.h"
+#include "llvm/Config/config.h"
 #include "llvm/Object/MachO.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/Compression.h"
@@ -22,6 +23,7 @@
 #include "llvm/Support/Path.h"
 
 #include <sstream>
+#include <stdlib.h>
 
 namespace llvm {
 namespace symbolize {
@@ -228,7 +230,14 @@ static bool checkFileCRC(StringRef Path,
 static bool findDebugBinary(const std::string &OrigPath,
                             const std::string &DebuglinkName, uint32_t CRCHash,
                             std::string &Result) {
-  SmallString<16> OrigDir(OrigPath);
+  std::string OrigRealPath = OrigPath;
+#if defined(HAVE_REALPATH)
+  if (char *RP = realpath(OrigPath.c_str(), NULL)) {
+    OrigRealPath = RP;
+    free(RP);
+  }
+#endif
+  SmallString<16> OrigDir(OrigRealPath);
   llvm::sys::path::remove_filename(OrigDir);
   SmallString<16> DebugPath = OrigDir;
   // Try /path/to/original_binary/debuglink_name
@@ -238,7 +247,7 @@ static bool findDebugBinary(const std::s
     return true;
   }
   // Try /path/to/original_binary/.debug/debuglink_name
-  DebugPath = OrigPath;
+  DebugPath = OrigRealPath;
   llvm::sys::path::append(DebugPath, ".debug", DebuglinkName);
   if (checkFileCRC(DebugPath, CRCHash)) {
     Result = DebugPath.str();





More information about the llvm-commits mailing list