Skip to content
Snippets Groups Projects
Commit 69b2d523 authored by David Malcolm's avatar David Malcolm
Browse files

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: default avatarDavid Malcolm <dmalcolm@redhat.com>
parent d826b638
No related branches found
No related tags found
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment