-
- Downloads
diagnostics: capture backtraces in SARIF notifications [PR116602]
This patch makes the SARIF output's crash handler attempt to capture
a backtrace in JSON form within the notification's property bag. The
precise format of the property is subject to change, but, for example,
in one of the test cases I got output like this:
"properties": {"gcc/backtrace": {"frames": [{"pc": "0x7f39c610a32d",
"function": "pass_crash_test::execute(function*)",
"filename": "/home/david/gcc-newgit/src/gcc/testsuite/gcc.dg/plugin/crash_test_plugin.c",
"lineno": 98}]}}}],
The backtrace code is based on that in diagnostic.cc.
gcc/ChangeLog:
PR other/116602
* diagnostic-format-sarif.cc: Include "demangle.h" and
"backtrace.h".
(sarif_invocation::add_notification_for_ice): Add "backtrace"
param and pass it to ctor.
(sarif_ice_notification::sarif_ice_notification): Add "backtrace"
param and add it to property bag.
(bt_stop): New, taken from diagnostic.cc.
(struct bt_closure): New.
(bt_callback): New, adapted from diagnostic.cc.
(sarif_builder::make_stack_from_backtrace): New.
(sarif_builder::on_report_diagnostic): Attempt to get backtrace
and pass it to add_notification_for_ice.
gcc/testsuite/ChangeLog:
PR other/116602
* gcc.dg/plugin/crash-test-ice-in-header-sarif-2_1.py: Add check
for backtrace.
* gcc.dg/plugin/crash-test-ice-in-header-sarif-2_2.py: Likewise.
Signed-off-by:
David Malcolm <dmalcolm@redhat.com>
Showing
- gcc/diagnostic-format-sarif.cc 149 additions, 6 deletionsgcc/diagnostic-format-sarif.cc
- gcc/testsuite/gcc.dg/plugin/crash-test-ice-in-header-sarif-2_1.py 7 additions, 0 deletions...suite/gcc.dg/plugin/crash-test-ice-in-header-sarif-2_1.py
- gcc/testsuite/gcc.dg/plugin/crash-test-ice-in-header-sarif-2_2.py 7 additions, 0 deletions...suite/gcc.dg/plugin/crash-test-ice-in-header-sarif-2_2.py
Loading
Please register or sign in to comment