[PATCH] D138334: Improve llvm-symbolizer search logic for symlink
jeffrey tan via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 21 09:42:38 PST 2022
yinghuitan updated this revision to Diff 476934.
yinghuitan added a comment.
Address review comments
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D138334/new/
https://reviews.llvm.org/D138334
Files:
llvm/lib/Support/Signals.cpp
Index: llvm/lib/Support/Signals.cpp
===================================================================
--- llvm/lib/Support/Signals.cpp
+++ llvm/lib/Support/Signals.cpp
@@ -156,8 +156,23 @@
LLVMSymbolizerPathOrErr = sys::findProgramByName(Path);
} else if (!Argv0.empty()) {
StringRef Parent = llvm::sys::path::parent_path(Argv0);
+ std::vector<StringRef> paths;
if (!Parent.empty())
- LLVMSymbolizerPathOrErr = sys::findProgramByName("llvm-symbolizer", Parent);
+ paths.push_back(Parent);
+
+ // If Argv0 is symlink we should resolve and add its real path's
+ // parent directory as well.
+ if (llvm::sys::fs::is_symlink_file(Argv0)) {
+ llvm::SmallString<128> Resolved;
+ if (!llvm::sys::fs::real_path(Argv0, Resolved)) {
+ Parent = llvm::sys::path::parent_path(Resolved);
+ if (!Parent.empty())
+ paths.push_back(Parent);
+ }
+ }
+
+ if (!paths.empty())
+ LLVMSymbolizerPathOrErr = sys::findProgramByName("llvm-symbolizer", paths);
}
if (!LLVMSymbolizerPathOrErr)
LLVMSymbolizerPathOrErr = sys::findProgramByName("llvm-symbolizer");
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D138334.476934.patch
Type: text/x-patch
Size: 1137 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221121/dc97efc0/attachment.bin>
More information about the llvm-commits
mailing list