[PATCH] D81672: [Driver] When forcing a crash call abort to get the correct diagnostic
John Brawn via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 11 10:28:09 PDT 2020
john.brawn created this revision.
john.brawn added reviewers: gbreynoo, jhenderson, probinson.
Herald added a project: clang.
Commit a945037e8fd0c30e250a62211469eea6765a36ae <https://reviews.llvm.org/rGa945037e8fd0c30e250a62211469eea6765a36ae> moved the printing of the "PLEASE submit a bug report" message to the crash handler, but that means we don't print it when forcing a crash using -gen-reproducer. Fix this by calling abort inside of a CrashRecoveryContext so we go through the crash handler.
Repository:
rG LLVM Github Monorepo
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
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<Command>(&J))
FailingCommands.push_back(std::make_pair(-1, C));
+
+ // Crash using abort.
+ llvm::CrashRecoveryContext CRC;
+ CRC.DumpStackAndCleanupOnFailure = true;
+ CRC.RunSafely([&]() { abort(); });
}
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: 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81672.270175.patch
Type: text/x-patch
Size: 2910 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200611/70172d79/attachment.bin>
More information about the cfe-commits
mailing list