diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2021-07-29 20:15:26 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2021-07-29 20:15:26 +0000 |
| commit | 344a3780b2e33f6ca763666c380202b18aab72a3 (patch) | |
| tree | f0b203ee6eb71d7fdd792373e3c81eb18d6934dd /llvm/lib/Support/Signals.cpp | |
| parent | b60736ec1405bb0a8dd40989f67ef4c93da068ab (diff) | |
vendor/llvm-project/llvmorg-13-init-16847-g88e66fa60ae5vendor/llvm-project/llvmorg-12.0.1-rc2-0-ge7dac564cd0evendor/llvm-project/llvmorg-12.0.1-0-gfed41342a82f
Diffstat (limited to 'llvm/lib/Support/Signals.cpp')
| -rw-r--r-- | llvm/lib/Support/Signals.cpp | 38 |
1 files changed, 32 insertions, 6 deletions
diff --git a/llvm/lib/Support/Signals.cpp b/llvm/lib/Support/Signals.cpp index 29be4df95954..dd4dded4cd1d 100644 --- a/llvm/lib/Support/Signals.cpp +++ b/llvm/lib/Support/Signals.cpp @@ -12,6 +12,9 @@ //===----------------------------------------------------------------------===// #include "llvm/Support/Signals.h" + +#include "DebugOptions.h" + #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringRef.h" #include "llvm/Config/llvm-config.h" @@ -39,10 +42,33 @@ using namespace llvm; // Use explicit storage to avoid accessing cl::opt in a signal handler. static bool DisableSymbolicationFlag = false; -static cl::opt<bool, true> - DisableSymbolication("disable-symbolication", - cl::desc("Disable symbolizing crash backtraces."), - cl::location(DisableSymbolicationFlag), cl::Hidden); +static ManagedStatic<std::string> CrashDiagnosticsDirectory; +namespace { +struct CreateDisableSymbolication { + static void *call() { + return new cl::opt<bool, true>( + "disable-symbolication", + cl::desc("Disable symbolizing crash backtraces."), + cl::location(DisableSymbolicationFlag), cl::Hidden); + } +}; +struct CreateCrashDiagnosticsDir { + static void *call() { + return new cl::opt<std::string, true>( + "crash-diagnostics-dir", cl::value_desc("directory"), + cl::desc("Directory for crash diagnostic files."), + cl::location(*CrashDiagnosticsDirectory), cl::Hidden); + } +}; +} // namespace +void llvm::initSignalsOptions() { + static ManagedStatic<cl::opt<bool, true>, CreateDisableSymbolication> + DisableSymbolication; + static ManagedStatic<cl::opt<std::string, true>, CreateCrashDiagnosticsDir> + CrashDiagnosticsDir; + *DisableSymbolication; + *CrashDiagnosticsDir; +} constexpr char DisableSymbolizationEnv[] = "LLVM_DISABLE_SYMBOLIZATION"; constexpr char LLVMSymbolizerPathEnv[] = "LLVM_SYMBOLIZER_PATH"; @@ -160,8 +186,8 @@ static bool printSymbolizedStackTrace(StringRef Argv0, void **StackTrace, } } - Optional<StringRef> Redirects[] = {StringRef(InputFile), - StringRef(OutputFile), StringRef("")}; + Optional<StringRef> Redirects[] = {InputFile.str(), OutputFile.str(), + StringRef("")}; StringRef Args[] = {"llvm-symbolizer", "--functions=linkage", "--inlining", #ifdef _WIN32 // Pass --relative-address on Windows so that we don't |
