[PATCH] D74324: Tools emit the bug report URL on crash

Owen Reynolds via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 19 08:37:37 PDT 2020


gbreynoo updated this revision to Diff 251392.
gbreynoo added a comment.

After Paul's comment, a custom message can now be used to replace the generic one.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D74324/new/

https://reviews.llvm.org/D74324

Files:
  clang/lib/Driver/Driver.cpp
  clang/tools/driver/driver.cpp
  llvm/include/llvm/Support/PrettyStackTrace.h
  llvm/lib/Support/PrettyStackTrace.cpp


Index: llvm/lib/Support/PrettyStackTrace.cpp
===================================================================
--- llvm/lib/Support/PrettyStackTrace.cpp
+++ llvm/lib/Support/PrettyStackTrace.cpp
@@ -142,9 +142,21 @@
 static CrashHandlerStringStorage crashHandlerStringStorage;
 #endif
 
+static const char* customBugReportMsg;
+
+void llvm::SetCustomBugReportMsg (const char* msg) {
+    customBugReportMsg = msg;
+}
+
 /// This callback is run if a fatal signal is delivered to the process, it
 /// prints the pretty stack trace.
 static void CrashHandler(void *) {
+  if (customBugReportMsg)
+    errs() << customBugReportMsg;
+  else
+    errs() << "PLEASE submit a bug report to " BUG_REPORT_URL
+              " and include the crash backtrace\n";
+
 #ifndef __APPLE__
   // On non-apple systems, just emit the crash stack trace to stderr.
   PrintCurStackTrace(errs());
Index: llvm/include/llvm/Support/PrettyStackTrace.h
===================================================================
--- llvm/include/llvm/Support/PrettyStackTrace.h
+++ llvm/include/llvm/Support/PrettyStackTrace.h
@@ -37,6 +37,10 @@
   /// \see PrettyStackTraceEntry
   void EnablePrettyStackTraceOnSigInfoForThisThread(bool ShouldEnable = true);
 
+  /// Replaces the generic bug report message that is output upon
+  /// a crash.
+  void SetCustomBugReportMsg(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: clang/tools/driver/driver.cpp
===================================================================
--- clang/tools/driver/driver.cpp
+++ clang/tools/driver/driver.cpp
@@ -38,6 +38,7 @@
 #include "llvm/Support/Host.h"
 #include "llvm/Support/InitLLVM.h"
 #include "llvm/Support/Path.h"
+#include "llvm/Support/PrettyStackTrace.h"
 #include "llvm/Support/Process.h"
 #include "llvm/Support/Program.h"
 #include "llvm/Support/Regex.h"
@@ -342,6 +343,9 @@
 int main(int argc_, const char **argv_) {
   noteBottomOfStack();
   llvm::InitLLVM X(argc_, argv_);
+  llvm::SetCustomBugReportMsg("PLEASE submit a bug report to " BUG_REPORT_URL
+                              " and include the crash backtrace, preprocessed "
+                              "source, and associated run script.\n");
   SmallVector<const char *, 256> argv(argv_, argv_ + argc_);
 
   if (llvm::sys::Process::FixupStandardFileDescriptors())
Index: clang/lib/Driver/Driver.cpp
===================================================================
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -1267,10 +1267,6 @@
   // Print the version of the compiler.
   PrintVersion(C, llvm::errs());
 
-  Diag(clang::diag::note_drv_command_failed_diag_msg)
-      << "PLEASE submit a bug report to " BUG_REPORT_URL " and include the "
-         "crash backtrace, preprocessed source, and associated run script.";
-
   // Suppress driver output and emit preprocessor output to temp file.
   Mode = CPPMode;
   CCGenDiagnostics = true;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D74324.251392.patch
Type: text/x-patch
Size: 3117 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200319/1f2fd863/attachment.bin>


More information about the llvm-commits mailing list