Index: clang/test/Driver/crash-report-crashfile.m =================================================================== --- clang/test/Driver/crash-report-crashfile.m +++ clang/test/Driver/crash-report-crashfile.m @@ -18,6 +18,7 @@ const int x = MODULE_MACRO; // CRASH_ENV: failing because environment variable 'FORCE_CLANG_DIAGNOSTICS_CRASH' is set +// CRASH_ENV: PLEASE submit a bug report to {{.*}} and include the crash backtrace, preprocessed source, and associated run script. // CRASH_ENV: Preprocessed source(s) and associated run script(s) are located at: // CRASH_ENV-NEXT: note: diagnostic msg: {{.*}}.m // CRASH_ENV-NEXT: note: diagnostic msg: {{.*}}.cache @@ -26,6 +27,7 @@ // CRASH_ENV-NEXT: note: diagnostic msg: {{.*}}Library/Logs/DiagnosticReports{{.*}} // CRASH_FLAG: failing because '-gen-reproducer' is used +// CRASH_FLAG: PLEASE submit a bug report to {{.*}} and include the crash backtrace, preprocessed source, and associated run script. // CRASH_FLAG: Preprocessed source(s) and associated run script(s) are located at: // CRASH_FLAG-NEXT: note: diagnostic msg: {{.*}}.m // CRASH_FLAG-NEXT: note: diagnostic msg: {{.*}}.cache Index: clang/test/Driver/crash-report-modules.m =================================================================== --- clang/test/Driver/crash-report-modules.m +++ clang/test/Driver/crash-report-modules.m @@ -19,6 +19,7 @@ @import simple; const int x = MODULE_MACRO; +// CHECK: PLEASE submit a bug report to {{.*}} and include the crash backtrace, preprocessed source, and associated run script. // CHECK: Preprocessed source(s) and associated run script(s) are located at: // CHECK-NEXT: note: diagnostic msg: {{.*}}.m // CHECK-NEXT: note: diagnostic msg: {{.*}}.cache Index: clang/test/Driver/crash-report-null.test =================================================================== --- clang/test/Driver/crash-report-null.test +++ clang/test/Driver/crash-report-null.test @@ -3,5 +3,6 @@ // FIXME: Investigating. "fatal error: file 'nul' modified since it was first processed" // XFAIL: windows-gnu +// CHECK: PLEASE submit a bug report to {{.*}} and include the crash backtrace, preprocessed source, and associated run script. // CHECK: Preprocessed source(s) and associated run script(s) are located at: // CHECK-NEXT: note: diagnostic msg: {{.*}}null-{{.*}}.c Index: clang/tools/driver/driver.cpp =================================================================== --- clang/tools/driver/driver.cpp +++ clang/tools/driver/driver.cpp @@ -511,6 +511,10 @@ for (const auto &J : C->getJobs()) if (const Command *C = dyn_cast(&J)) FailingCommands.push_back(std::make_pair(-1, C)); + + // Crash using abort. + llvm::CrashRecoveryContext CRC; + CRC.RunSafely([&]() { abort(); }); } for (const auto &P : FailingCommands) { Index: llvm/include/llvm/Support/CrashRecoveryContext.h =================================================================== --- llvm/include/llvm/Support/CrashRecoveryContext.h +++ llvm/include/llvm/Support/CrashRecoveryContext.h @@ -14,6 +14,10 @@ namespace llvm { class CrashRecoveryContextCleanup; +/// Replaces the generic bug report message that is output upon +/// a crash. +void setBugReportMsg(const char *Msg); + /// Crash recovery helper object. /// /// This class implements support for running operations in a safe context so Index: llvm/include/llvm/Support/PrettyStackTrace.h =================================================================== --- llvm/include/llvm/Support/PrettyStackTrace.h +++ llvm/include/llvm/Support/PrettyStackTrace.h @@ -37,10 +37,6 @@ /// \see PrettyStackTraceEntry void EnablePrettyStackTraceOnSigInfoForThisThread(bool ShouldEnable = true); - /// Replaces the generic bug report message that is output upon - /// a crash. - void setBugReportMsg(const char *Msg); - /// PrettyStackTraceEntry - This class is used to represent a frame of the /// "pretty" stack trace that is dumped when a program crashes. You can define /// subclasses of this and declare them on the program stack: when they are Index: llvm/lib/Support/CrashRecoveryContext.cpp =================================================================== --- llvm/lib/Support/CrashRecoveryContext.cpp +++ llvm/lib/Support/CrashRecoveryContext.cpp @@ -7,11 +7,13 @@ //===----------------------------------------------------------------------===// #include "llvm/Support/CrashRecoveryContext.h" +#include "llvm/Config/config.h" #include "llvm/Config/llvm-config.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/ManagedStatic.h" #include "llvm/Support/Signals.h" #include "llvm/Support/ThreadLocal.h" +#include "llvm/Support/raw_ostream.h" #include #include #if LLVM_ON_UNIX @@ -27,6 +29,10 @@ static ManagedStatic< sys::ThreadLocal > CurrentContext; +static const char *BugReportMsg = + "PLEASE submit a bug report to " BUG_REPORT_URL + " and include the crash backtrace.\n"; + struct CrashRecoveryContextImpl { // When threads are disabled, this links up all active // CrashRecoveryContextImpls. When threads are enabled there's one thread @@ -71,6 +77,8 @@ assert(!Failed && "Crash recovery context already failed!"); Failed = true; + errs() << BugReportMsg; + if (CRC->DumpStackAndCleanupOnFailure) sys::CleanupOnSignal(Context); @@ -86,6 +94,10 @@ }; } +void llvm::setBugReportMsg(const char *Msg) { + BugReportMsg = Msg; +} + static ManagedStatic gCrashRecoveryContextMutex; static bool gCrashRecoveryEnabled = false; Index: llvm/lib/Support/PrettyStackTrace.cpp =================================================================== --- llvm/lib/Support/PrettyStackTrace.cpp +++ llvm/lib/Support/PrettyStackTrace.cpp @@ -142,15 +142,9 @@ static CrashHandlerStringStorage crashHandlerStringStorage; #endif -static const char *BugReportMsg = - "PLEASE submit a bug report to " BUG_REPORT_URL - " and include the crash backtrace.\n"; - /// This callback is run if a fatal signal is delivered to the process, it /// prints the pretty stack trace. static void CrashHandler(void *) { - errs() << BugReportMsg ; - #ifndef __APPLE__ // On non-apple systems, just emit the crash stack trace to stderr. PrintCurStackTrace(errs()); @@ -202,12 +196,6 @@ #endif // ENABLE_BACKTRACES -void llvm::setBugReportMsg(const char *Msg) { -#if ENABLE_BACKTRACES - BugReportMsg = Msg; -#endif -} - PrettyStackTraceEntry::PrettyStackTraceEntry() { #if ENABLE_BACKTRACES // Handle SIGINFO first, because we haven't finished constructing yet.