From 3738635a11dfeb0cb5247b0a08a2564430aa145a Mon Sep 17 00:00:00 2001 From: Sean Silva Date: Mon, 15 Apr 2019 22:07:56 +0000 Subject: [PATCH] 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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@358455 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Support/Signals.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Support/Signals.cpp b/lib/Support/Signals.cpp index 570b18f9a20..173a07f009d 100644 --- a/lib/Support/Signals.cpp +++ b/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 Modules(Depth, nullptr); -- 2.40.0