From: Paul Robinson Date: Tue, 23 Mar 2021 17:45:37 +0000 (-0700) Subject: Pass -fcrash-diagnostics-dir along to LLVM X-Git-Tag: llvmorg-14-init~10331 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=04b3c8c52c549ee57e69a1b23484b8c4109f83b8;p=platform%2Fupstream%2Fllvm.git Pass -fcrash-diagnostics-dir along to LLVM This allows frontend and backend diagnostic files to all go into the same place. Have it control the Windows (mini-)dump location. Differential Revision: https://reviews.llvm.org/D99199 --- diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index aaf6f83..22f4ad1 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -5156,6 +5156,14 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, if (D.CCGenDiagnostics) CmdArgs.push_back("-disable-pragma-debug-crash"); + // Allow backend to put its diagnostic files in the same place as frontend + // crash diagnostics files. + if (Args.hasArg(options::OPT_fcrash_diagnostics_dir)) { + StringRef Dir = Args.getLastArgValue(options::OPT_fcrash_diagnostics_dir); + CmdArgs.push_back("-mllvm"); + CmdArgs.push_back(Args.MakeArgString("-crash-diagnostics-dir=" + Dir)); + } + bool UseSeparateSections = isUseSeparateSections(Triple); if (Args.hasFlag(options::OPT_ffunction_sections, diff --git a/clang/test/Driver/crash-diagnostics-dir-2.c b/clang/test/Driver/crash-diagnostics-dir-2.c new file mode 100644 index 0000000..432a889 --- /dev/null +++ b/clang/test/Driver/crash-diagnostics-dir-2.c @@ -0,0 +1,5 @@ +// RUN: %clang -### -fcrash-diagnostics-dir=mydumps -c %s 2>&1 \ +// RUN: | FileCheck %s --check-prefix=OPTION +// OPTION: "-crash-diagnostics-dir=mydumps" +// RUN: %clang -### -c %s 2>&1 | FileCheck %s --check-prefix=NOOPTION +// NOOPTION-NOT: "-crash-diagnostics-dir diff --git a/llvm/lib/Support/Signals.cpp b/llvm/lib/Support/Signals.cpp index 29be4df..5aa1a9e 100644 --- a/llvm/lib/Support/Signals.cpp +++ b/llvm/lib/Support/Signals.cpp @@ -43,6 +43,11 @@ static cl::opt DisableSymbolication("disable-symbolication", cl::desc("Disable symbolizing crash backtraces."), cl::location(DisableSymbolicationFlag), cl::Hidden); +static std::string CrashDiagnosticsDirectory; +static cl::opt + CrashDiagnosticsDir("crash-diagnostics-dir", cl::value_desc("directory"), + cl::desc("Directory for crash diagnostic files."), + cl::location(CrashDiagnosticsDirectory), cl::Hidden); constexpr char DisableSymbolizationEnv[] = "LLVM_DISABLE_SYMBOLIZATION"; constexpr char LLVMSymbolizerPathEnv[] = "LLVM_SYMBOLIZER_PATH"; diff --git a/llvm/lib/Support/Windows/Signals.inc b/llvm/lib/Support/Windows/Signals.inc index 3758582..df5fcb1 100644 --- a/llvm/lib/Support/Windows/Signals.inc +++ b/llvm/lib/Support/Windows/Signals.inc @@ -766,16 +766,18 @@ WriteWindowsDumpFile(PMINIDUMP_EXCEPTION_INFORMATION ExceptionInfo) { if (!GetDumpType(DefaultLocalDumpsKey, DumpType)) DumpType = MiniDumpNormal; - // Look to see if a dump location is specified in the registry; first with the + // Look to see if a dump location is specified on the command line. If not, + // look to see if a dump location is specified in the registry; first with the // app-specific key and failing that with the global key. If none are found // we'll just create the dump file in the default temporary file location // (GetDumpFolder will return false either if the key is NULL or if there is // no valid DumpFolder value at its location). bool ExplicitDumpDirectorySet = true; - SmallString DumpDirectory; - if (!GetDumpFolder(AppSpecificKey, DumpDirectory)) - if (!GetDumpFolder(DefaultLocalDumpsKey, DumpDirectory)) - ExplicitDumpDirectorySet = false; + SmallString DumpDirectory(CrashDiagnosticsDirectory); + if (DumpDirectory.empty()) + if (!GetDumpFolder(AppSpecificKey, DumpDirectory)) + if (!GetDumpFolder(DefaultLocalDumpsKey, DumpDirectory)) + ExplicitDumpDirectorySet = false; int FD; SmallString DumpPath;