[PATCH] D81672: [Driver] When forcing a crash print the bug report message

2020-06-29 Thread John Brawn via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGce1fa201af77: [Driver] When forcing a crash print the bug 
report message (authored by john.brawn).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81672

Files:
  clang/test/Driver/crash-report-crashfile.m
  clang/test/Driver/crash-report-modules.m
  clang/test/Driver/crash-report-null.test
  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
@@ -33,6 +33,10 @@
 
 using namespace llvm;
 
+static const char *BugReportMsg =
+"PLEASE submit a bug report to " BUG_REPORT_URL
+" and include the crash backtrace.\n";
+
 // If backtrace support is not enabled, compile out support for pretty stack
 // traces.  This has the secondary effect of not requiring thread local storage
 // when backtrace support is disabled.
@@ -142,10 +146,6 @@
 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 *) {
@@ -203,9 +203,11 @@
 #endif // ENABLE_BACKTRACES
 
 void llvm::setBugReportMsg(const char *Msg) {
-#if ENABLE_BACKTRACES
   BugReportMsg = Msg;
-#endif
+}
+
+const char *llvm::getBugReportMsg() {
+  return BugReportMsg;
 }
 
 PrettyStackTraceEntry::PrettyStackTraceEntry() {
Index: llvm/include/llvm/Support/PrettyStackTrace.h
===
--- llvm/include/llvm/Support/PrettyStackTrace.h
+++ llvm/include/llvm/Support/PrettyStackTrace.h
@@ -41,6 +41,9 @@
   /// a crash.
   void setBugReportMsg(const char *Msg);
 
+  /// Get the bug report message that will be output upon a crash.
+  const char *getBugReportMsg();
+
   /// 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
@@ -511,6 +511,11 @@
   for (const auto &J : C->getJobs())
 if (const Command *C = dyn_cast(&J))
   FailingCommands.push_back(std::make_pair(-1, C));
+
+  // Print the bug report message that would be printed if we did actually
+  // crash, but only if we're crashing due to FORCE_CLANG_DIAGNOSTICS_CRASH.
+  if (::getenv("FORCE_CLANG_DIAGNOSTICS_CRASH"))
+llvm::dbgs() << llvm::getBugReportMsg();
 }
 
 for (const auto &P : FailingCommands) {
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/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-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

[PATCH] D81672: [Driver] When forcing a crash print the bug report message

2020-06-29 Thread James Henderson via Phabricator via cfe-commits
jhenderson accepted this revision.
jhenderson added a comment.

Latest version LGTM too.


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

https://reviews.llvm.org/D81672



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D81672: [Driver] When forcing a crash print the bug report message

2020-06-26 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay accepted this revision.
MaskRay added a comment.

Thanks!


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

https://reviews.llvm.org/D81672



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D81672: [Driver] When forcing a crash print the bug report message

2020-06-26 Thread John Brawn via Phabricator via cfe-commits
john.brawn updated this revision to Diff 273816.
john.brawn edited the summary of this revision.
john.brawn added a comment.

Don't print the diagnostic with -gen-reproducer.


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

https://reviews.llvm.org/D81672

Files:
  clang/test/Driver/crash-report-crashfile.m
  clang/test/Driver/crash-report-modules.m
  clang/test/Driver/crash-report-null.test
  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
@@ -33,6 +33,10 @@
 
 using namespace llvm;
 
+static const char *BugReportMsg =
+"PLEASE submit a bug report to " BUG_REPORT_URL
+" and include the crash backtrace.\n";
+
 // If backtrace support is not enabled, compile out support for pretty stack
 // traces.  This has the secondary effect of not requiring thread local storage
 // when backtrace support is disabled.
@@ -142,10 +146,6 @@
 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 *) {
@@ -203,9 +203,11 @@
 #endif // ENABLE_BACKTRACES
 
 void llvm::setBugReportMsg(const char *Msg) {
-#if ENABLE_BACKTRACES
   BugReportMsg = Msg;
-#endif
+}
+
+const char *llvm::getBugReportMsg() {
+  return BugReportMsg;
 }
 
 PrettyStackTraceEntry::PrettyStackTraceEntry() {
Index: llvm/include/llvm/Support/PrettyStackTrace.h
===
--- llvm/include/llvm/Support/PrettyStackTrace.h
+++ llvm/include/llvm/Support/PrettyStackTrace.h
@@ -41,6 +41,9 @@
   /// a crash.
   void setBugReportMsg(const char *Msg);
 
+  /// Get the bug report message that will be output upon a crash.
+  const char *getBugReportMsg();
+
   /// 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
@@ -511,6 +511,11 @@
   for (const auto &J : C->getJobs())
 if (const Command *C = dyn_cast(&J))
   FailingCommands.push_back(std::make_pair(-1, C));
+
+  // Print the bug report message that would be printed if we did actually
+  // crash, but only if we're crashing due to FORCE_CLANG_DIAGNOSTICS_CRASH.
+  if (::getenv("FORCE_CLANG_DIAGNOSTICS_CRASH"))
+llvm::dbgs() << llvm::getBugReportMsg();
 }
 
 for (const auto &P : FailingCommands) {
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/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-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
___
cfe-commits mailing list
cfe-com

[PATCH] D81672: [Driver] When forcing a crash print the bug report message

2020-06-26 Thread John Brawn via Phabricator via cfe-commits
john.brawn marked an inline comment as done.
john.brawn added inline comments.



Comment at: clang/tools/driver/driver.cpp:515
+
+  llvm::dbgs() << llvm::getBugReportMsg();
 }

MaskRay wrote:
> john.brawn wrote:
> > MaskRay wrote:
> > > Why ` llvm::dbgs() << llvm::getBugReportMsg();` when -gen-reproducer is 
> > > specified? The user requests to generate a reproduce file, but this does 
> > > not suggest that clang has a bug. Dumping an URL is not very appropriate.
> > Emitting the bug report message is primarily for when 
> > FORCE_CLANG_DIAGNOSTICS_CRASH is set (because we can get here either due to 
> > that or -gen-reproducer). I could adjust this to only emit the message when 
> > that is set if you'd like? Though either way we get the "PLEASE ATTACH THE 
> > FOLLOWING FILES TO THE BUG REPORT:" message.
> When `FORCE_CLANG_DIAGNOSTICS_CRASH` is set or `-gen-reproducer` is 
> specified, I feel that a URL or "PLEASE ATTACH THE FOLLOWING FILES TO THE BUG 
> REPORT" is not very appropriate because this is not a real crash..
FORCE_CLANG_DIAGNOSTICS_CRASH exists exactly to test the diagnostics (at least 
according to 681e4b8d962ed848d2bd443642e53909af53a6cd which added it) so we 
should be emitting it them. I'll adjust it to not do so when using 
-gen-reproducer.



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

https://reviews.llvm.org/D81672



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D81672: [Driver] When forcing a crash print the bug report message

2020-06-25 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/tools/driver/driver.cpp:515
+
+  llvm::dbgs() << llvm::getBugReportMsg();
 }

john.brawn wrote:
> MaskRay wrote:
> > Why ` llvm::dbgs() << llvm::getBugReportMsg();` when -gen-reproducer is 
> > specified? The user requests to generate a reproduce file, but this does 
> > not suggest that clang has a bug. Dumping an URL is not very appropriate.
> Emitting the bug report message is primarily for when 
> FORCE_CLANG_DIAGNOSTICS_CRASH is set (because we can get here either due to 
> that or -gen-reproducer). I could adjust this to only emit the message when 
> that is set if you'd like? Though either way we get the "PLEASE ATTACH THE 
> FOLLOWING FILES TO THE BUG REPORT:" message.
When `FORCE_CLANG_DIAGNOSTICS_CRASH` is set or `-gen-reproducer` is specified, 
I feel that a URL or "PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT" is 
not very appropriate because this is not a real crash..


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

https://reviews.llvm.org/D81672



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D81672: [Driver] When forcing a crash print the bug report message

2020-06-25 Thread John Brawn via Phabricator via cfe-commits
john.brawn marked an inline comment as done.
john.brawn added inline comments.



Comment at: clang/tools/driver/driver.cpp:515
+
+  llvm::dbgs() << llvm::getBugReportMsg();
 }

MaskRay wrote:
> Why ` llvm::dbgs() << llvm::getBugReportMsg();` when -gen-reproducer is 
> specified? The user requests to generate a reproduce file, but this does not 
> suggest that clang has a bug. Dumping an URL is not very appropriate.
Emitting the bug report message is primarily for when 
FORCE_CLANG_DIAGNOSTICS_CRASH is set (because we can get here either due to 
that or -gen-reproducer). I could adjust this to only emit the message when 
that is set if you'd like? Though either way we get the "PLEASE ATTACH THE 
FOLLOWING FILES TO THE BUG REPORT:" message.


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

https://reviews.llvm.org/D81672



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D81672: [Driver] When forcing a crash print the bug report message

2020-06-23 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/tools/driver/driver.cpp:515
+
+  llvm::dbgs() << llvm::getBugReportMsg();
 }

Why ` llvm::dbgs() << llvm::getBugReportMsg();` when -gen-reproducer is 
specified? The user requests to generate a reproduce file, but this does not 
suggest that clang has a bug. Dumping an URL is not very appropriate.


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

https://reviews.llvm.org/D81672



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D81672: [Driver] When forcing a crash print the bug report message

2020-06-23 Thread John Brawn via Phabricator via cfe-commits
john.brawn marked an inline comment as done.
john.brawn added inline comments.



Comment at: llvm/lib/Support/PrettyStackTrace.cpp:36
 
+static const char *BugReportMsg =
+"PLEASE submit a bug report to " BUG_REPORT_URL

MaskRay wrote:
> This variable is mutable. Please use `const char BugReportMsg[]`
It needs to be mutable because it is set by llvm::setBugReportMsg.


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

https://reviews.llvm.org/D81672



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D81672: [Driver] When forcing a crash print the bug report message

2020-06-23 Thread James Henderson via Phabricator via cfe-commits
jhenderson accepted this revision.
jhenderson added a comment.
This revision is now accepted and ready to land.

LGTM, but wait for others too, please.


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

https://reviews.llvm.org/D81672



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D81672: [Driver] When forcing a crash print the bug report message

2020-06-22 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: llvm/lib/Support/PrettyStackTrace.cpp:36
 
+static const char *BugReportMsg =
+"PLEASE submit a bug report to " BUG_REPORT_URL

This variable is mutable. Please use `const char BugReportMsg[]`


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

https://reviews.llvm.org/D81672



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D81672: [Driver] When forcing a crash print the bug report message

2020-06-22 Thread John Brawn via Phabricator via cfe-commits
john.brawn updated this revision to Diff 272471.
john.brawn retitled this revision from "[Driver] When forcing a crash call 
abort to get the correct diagnostic" to "[Driver] When forcing a crash print 
the bug report message".
john.brawn edited the summary of this revision.
john.brawn added a comment.

Print the bug report message when forcing a crash, but also have the message 
available even with LLVM_ENABLE_BACKTRACES=OFF.


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

https://reviews.llvm.org/D81672

Files:
  clang/test/Driver/crash-report-crashfile.m
  clang/test/Driver/crash-report-modules.m
  clang/test/Driver/crash-report-null.test
  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
@@ -33,6 +33,10 @@
 
 using namespace llvm;
 
+static const char *BugReportMsg =
+"PLEASE submit a bug report to " BUG_REPORT_URL
+" and include the crash backtrace.\n";
+
 // If backtrace support is not enabled, compile out support for pretty stack
 // traces.  This has the secondary effect of not requiring thread local storage
 // when backtrace support is disabled.
@@ -142,10 +146,6 @@
 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 *) {
@@ -203,9 +203,11 @@
 #endif // ENABLE_BACKTRACES
 
 void llvm::setBugReportMsg(const char *Msg) {
-#if ENABLE_BACKTRACES
   BugReportMsg = Msg;
-#endif
+}
+
+const char *llvm::getBugReportMsg() {
+  return BugReportMsg;
 }
 
 PrettyStackTraceEntry::PrettyStackTraceEntry() {
Index: llvm/include/llvm/Support/PrettyStackTrace.h
===
--- llvm/include/llvm/Support/PrettyStackTrace.h
+++ llvm/include/llvm/Support/PrettyStackTrace.h
@@ -41,6 +41,9 @@
   /// a crash.
   void setBugReportMsg(const char *Msg);
 
+  /// Get the bug report message that will be output upon a crash.
+  const char *getBugReportMsg();
+
   /// 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
@@ -511,6 +511,8 @@
   for (const auto &J : C->getJobs())
 if (const Command *C = dyn_cast(&J))
   FailingCommands.push_back(std::make_pair(-1, C));
+
+  llvm::dbgs() << llvm::getBugReportMsg();
 }
 
 for (const auto &P : FailingCommands) {
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/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-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: