https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117943
Bug ID: 117943 Summary: sarif-replay can fail to quote source code Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: sarif-replay Assignee: dmalcolm at gcc dot gnu.org Reporter: dmalcolm at gcc dot gnu.org Target Milestone: --- See e.g. gcc/testsuite/sarif-replay.dg/2.1.0-valid/signal-1.c.sarif The source code is printed when run from the same path as when the .sarif was originally captured: $ LD_LIBRARY_PATH=. ./sarif-replay -fjson-comments ../../src/gcc/testsuite/sarif-replay.dg/2.1.0-valid/signal-1.c.sarif In function 'custom_logger': ../../src/gcc/testsuite/gcc.dg/analyzer/signal-1.c:13:3: warning: call to ‘fprintf’ from within signal handler [-Wanalyzer-unsafe-call-within-signal-handler] 13 | fprintf(stderr, "LOG: %s", msg); /* { dg-warning "call to 'fprintf' from within signal handler" } */ | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 'main': event 1 │ │ 21 | int main(int argc, const char *argv) │ | ^~~~~ │ | | │ | (1) entry to ‘main’ │ 'main': event 2 │ │ 25 | signal(SIGINT, handler); /* { dg-message "registering 'handler' as signal handler" } */ │ | ^~~~~~~~~~~~~~~~~~~~~~~~ │ | | │ | (2) registering ‘handler’ as signal handler │ event 3 │ │GNU C17: │ (3): later on, when the signal is delivered to the process │ └──> 'handler': event 4 │ │ 16 | static void handler(int signum) │ | ^~~~~~~~ │ | | │ | (4) entry to ‘handler’ │ 'handler': event 5 │ │ 18 | custom_logger("got signal"); │ | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ │ | | │ | (5) calling ‘custom_logger’ from ‘handler’ │ └──> 'custom_logger': event 6 │ │ 11 | void custom_logger(const char *msg) │ | ^~~~~~~~~~~~~~ │ | | │ | (6) entry to ‘custom_logger’ │ 'custom_logger': event 7 │ │ 13 | fprintf(stderr, "LOG: %s", msg); /* { dg-warning "call to 'fprintf' from within signal handler" } */ │ | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ │ | | │ | (7) call to ‘fprintf’ from within signal handler │ ...but not if run from another directory, which happens during the DejaGnu tests: $ LD_LIBRARY_PATH=../.. ../../sarif-replay -fjson-comments ../../../../src/gcc/testsuite/sarif-replay.dg/2.1.0-valid/signal-1.c.sarif In function 'custom_logger': ../../src/gcc/testsuite/gcc.dg/analyzer/signal-1.c:13:3: warning: call to ‘fprintf’ from within signal handler [-Wanalyzer-unsafe-call-within-signal-handler] 'main': event 1 │ │ 'main': event 2 │ │ event 3 │ │GNU C17: │ (3): later on, when the signal is delivered to the process │ └──> 'handler': event 4 │ │ 'handler': event 5 │ │ └──> 'custom_logger': event 6 │ │ 'custom_logger': event 7 │ │ We should probably make use of: * originalUriBaseIds and uriBaseId (which we could potentially use to find the correct path when running on the same machine) * artifact contents where present (which would avoid looking for the file in the first place)