summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorSean Silva <chisophugis@gmail.com>2019-04-15 22:07:56 +0000
committerSean Silva <chisophugis@gmail.com>2019-04-15 22:07:56 +0000
commitde68a375181f4e831f4d558a75508e0426ba7327 (patch)
tree7482b26e96a7e34a569d24f4ca311242b428598b /llvm/lib
parent800a0c3e4b0655ba23afe40ff1d21bc531158bfc (diff)
downloadbcm5719-llvm-de68a375181f4e831f4d558a75508e0426ba7327.tar.gz
bcm5719-llvm-de68a375181f4e831f4d558a75508e0426ba7327.zip
Only use argv[0] as the main executable name if it exists.
Under some environments, argv[0] doesn't hold a valid file name, but sys::fs::getMainExecutable will find the main executable properly. This patch tweaks the logic to fall back to sys::fs::getMainExecutable in more situations. Differential Revision: https://reviews.llvm.org/D60730 llvm-svn: 358455
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Support/Signals.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/llvm/lib/Support/Signals.cpp b/llvm/lib/Support/Signals.cpp
index 570b18f9a20..173a07f009d 100644
--- a/llvm/lib/Support/Signals.cpp
+++ b/llvm/lib/Support/Signals.cpp
@@ -131,8 +131,8 @@ static bool printSymbolizedStackTrace(StringRef Argv0, void **StackTrace,
// If we don't know argv0 or the address of main() at this point, try
// to guess it anyway (it's possible on some platforms).
std::string MainExecutableName =
- Argv0.empty() ? sys::fs::getMainExecutable(nullptr, nullptr)
- : (std::string)Argv0;
+ sys::fs::exists(Argv0) ? (std::string)Argv0
+ : sys::fs::getMainExecutable(nullptr, nullptr);
BumpPtrAllocator Allocator;
StringSaver StrPool(Allocator);
std::vector<const char *> Modules(Depth, nullptr);
OpenPOWER on IntegriCloud