[llvm] r352916 - [DebugInfo] Don't use realpath when looking up debug binary locations.
Jordan Rupprecht via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 1 13:04:16 PST 2019
Author: rupprecht
Date: Fri Feb 1 13:04:16 2019
New Revision: 352916
URL: http://llvm.org/viewvc/llvm-project?rev=352916&view=rev
Log:
[DebugInfo] Don't use realpath when looking up debug binary locations.
Summary:
Using realpath makes assumptions about build systems that do not always hold true. The debug binary referred to from the .gnu_debuglink should exist in the same directory (or in a .debug directory, etc.), but the files may only exist as symlinks to a differently named files elsewhere, and using realpath causes that lookup to fail.
This was added in r189250, and this is basically a revert + regression test case.
Reviewers: dblaikie, samsonov, jhenderson
Reviewed By: dblaikie
Subscribers: llvm-commits, hiraditya
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D57609
Added:
llvm/trunk/test/DebugInfo/symbolize-gnu-debuglink-no-realpath.test
Modified:
llvm/trunk/lib/DebugInfo/Symbolize/Symbolize.cpp
Modified: llvm/trunk/lib/DebugInfo/Symbolize/Symbolize.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/Symbolize/Symbolize.cpp?rev=352916&r1=352915&r2=352916&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/Symbolize/Symbolize.cpp (original)
+++ llvm/trunk/lib/DebugInfo/Symbolize/Symbolize.cpp Fri Feb 1 13:04:16 2019
@@ -16,7 +16,6 @@
#include "llvm/ADT/STLExtras.h"
#include "llvm/BinaryFormat/COFF.h"
-#include "llvm/Config/config.h"
#include "llvm/DebugInfo/DWARF/DWARFContext.h"
#include "llvm/DebugInfo/PDB/PDB.h"
#include "llvm/DebugInfo/PDB/PDBContext.h"
@@ -33,7 +32,6 @@
#include "llvm/Support/Path.h"
#include <algorithm>
#include <cassert>
-#include <cstdlib>
#include <cstring>
#if defined(_MSC_VER)
@@ -168,14 +166,7 @@ bool checkFileCRC(StringRef Path, uint32
bool findDebugBinary(const std::string &OrigPath,
const std::string &DebuglinkName, uint32_t CRCHash,
std::string &Result) {
- std::string OrigRealPath = OrigPath;
-#if defined(HAVE_REALPATH)
- if (char *RP = realpath(OrigPath.c_str(), nullptr)) {
- OrigRealPath = RP;
- free(RP);
- }
-#endif
- SmallString<16> OrigDir(OrigRealPath);
+ SmallString<16> OrigDir(OrigPath);
llvm::sys::path::remove_filename(OrigDir);
SmallString<16> DebugPath = OrigDir;
// Try /path/to/original_binary/debuglink_name
Added: llvm/trunk/test/DebugInfo/symbolize-gnu-debuglink-no-realpath.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/symbolize-gnu-debuglink-no-realpath.test?rev=352916&view=auto
==============================================================================
--- llvm/trunk/test/DebugInfo/symbolize-gnu-debuglink-no-realpath.test (added)
+++ llvm/trunk/test/DebugInfo/symbolize-gnu-debuglink-no-realpath.test Fri Feb 1 13:04:16 2019
@@ -0,0 +1,17 @@
+# REQUIRES: shell
+# Ensure that no realpath assumptions are made about .gnu_debuglink paths.
+
+# Copy inputs to some other location with arbitrary names, with the original
+# filenames just being symlinks to the copies. Real files go in the "real" dir,
+# symlinks (with original names) go in "syms".
+RUN: rm -rf %t/real %t/syms
+RUN: mkdir %t/real %t/syms
+RUN: cp %p/Inputs/dwarfdump-test.elf-x86-64 %t/real/prog
+RUN: cp %p/Inputs/dwarfdump-test.elf-x86-64.debuglink %t/real/link
+RUN: ln -s %t/real/prog %t/syms/dwarfdump-test.elf-x86-64
+RUN: ln -s %t/real/link %t/syms/dwarfdump-test.elf-x86-64.debuglink
+
+RUN: llvm-symbolizer --obj=%t/syms/dwarfdump-test.elf-x86-64.debuglink 0x40113f | FileCheck %s
+
+CHECK: main
+CHECK-NEXT: /tmp/dbginfo{{[/\\]}}dwarfdump-test.cc:16
More information about the llvm-commits
mailing list