Commit a945037e8fd0c30e250a62211469eea6765a36ae 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 FORCE_CLANG_DIAGNOSTICS_CRASH. Fix this by adding a function to get the bug report message and printing it when forcing a crash.
Details
Diff Detail
Event Timeline
This seems sensible to me, but I have zero experience with the CrashRecoveryContext class. It might be best to get someone who has more knowledge of it to look at it.
clang/tools/driver/driver.cpp | ||
---|---|---|
518 | The only concern I have is that a unrelated call stack will be printed. |
clang/tools/driver/driver.cpp | ||
---|---|---|
518 | I had a go at doing that, but then realised that currently the bug report message only exists, and is only printed, when llvm is built with LLVM_ENABLE_BACKTRACES=ON which I don't think is what we want. I've instead adjusted things so that the bug report message is printed in CrashRecoveryContext instead of in the backtrace handler, which also means we can get the message without the backtrace here. |
Moved BugReportMsg printing into CrashRecoveryContext, and stopped printing of backtrace when forcing a crash.
But that won't work when compiling & crashing with -fno-integrated-cc1, would it? (or if building with cmake ... -DCLANG_SPAWN_CC1=1). In that case, normal crashes (not -gen-reproducer) won't go through the CrashRecoveryContext.
Try running:
$ CCC_OVERRIDE_OPTIONS=+-fno-integrated-cc1 $ py your_build_folder/bin/llvm-lit.py -vv -a clang/test/Driver/crash-report.c
See if the commands issued by the test display the "PLEASE submit a bug report" message.
If I'm following it correctly (I could easily not be), the latest version of the patch will also no longer print the bug report submission message for crashes in other parts of LLVM, not just clang, which was rather the motivation of @gbreynoo's recent changes.
Print the bug report message when forcing a crash, but also have the message available even with LLVM_ENABLE_BACKTRACES=OFF.
llvm/lib/Support/PrettyStackTrace.cpp | ||
---|---|---|
36 ↗ | (On Diff #272471) | This variable is mutable. Please use const char BugReportMsg[] |
llvm/lib/Support/PrettyStackTrace.cpp | ||
---|---|---|
36 ↗ | (On Diff #272471) | It needs to be mutable because it is set by llvm::setBugReportMsg. |
clang/tools/driver/driver.cpp | ||
---|---|---|
515 | 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. |
clang/tools/driver/driver.cpp | ||
---|---|---|
515 | 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. |
clang/tools/driver/driver.cpp | ||
---|---|---|
515 | 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...... |
clang/tools/driver/driver.cpp | ||
---|---|---|
515 | 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. |
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.