For cases where sarif-replay can't find the source, text output with -fdiagnostics-path-format=inline-events and HTML output both lead to the event locations and messages in replayed execution paths not being printed at all.
Fixed thusly.
Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu.
Pushed to trunk as r16-6966-g67d4031d3525c1.
gcc/ChangeLog:
PR diagnostics/122622
* diagnostics/paths-output.cc: Include "diagnostics/file-cache.h".
(event_range::print_as_text): Generalize the fallback logic for
special locations to also cover the case where source-printing
will fail, and show the location for that case.
(event_range::print_as_html): Likewise.
(event_range::can_print_source_p): New.
gcc/testsuite/ChangeLog:
PR diagnostics/122622
* sarif-replay.dg/2.1.0-valid/missing-source-pr122622-check-html.py:
New test script.
* sarif-replay.dg/2.1.0-valid/missing-source-pr122622.sarif: New
test.
* sarif-replay.dg/2.1.0-valid/spec-example-4.sarif: Update
expected output to reflect showing event locations and text.
* sarif-replay.dg/2.1.0-valid/tutorial-example.sarif: Likewise.
Signed-off-by: David Malcolm <[email protected]>
---
gcc/diagnostics/paths-output.cc | 94 +++-
.../missing-source-pr122622-check-html.py | 30 ++
.../2.1.0-valid/missing-source-pr122622.sarif | 506 ++++++++++++++++++
.../2.1.0-valid/spec-example-4.sarif | 6 +-
.../2.1.0-valid/tutorial-example.sarif | 6 +-
5 files changed, 615 insertions(+), 27 deletions(-)
create mode 100644
gcc/testsuite/sarif-replay.dg/2.1.0-valid/missing-source-pr122622-check-html.py
create mode 100644
gcc/testsuite/sarif-replay.dg/2.1.0-valid/missing-source-pr122622.sarif
diff --git a/gcc/diagnostics/paths-output.cc b/gcc/diagnostics/paths-output.cc
index 43902e49b8d..a89b3a46f74 100644
--- a/gcc/diagnostics/paths-output.cc
+++ b/gcc/diagnostics/paths-output.cc
@@ -30,6 +30,7 @@ along with GCC; see the file COPYING3. If not see
#include "diagnostics/paths.h"
#include "gcc-rich-location.h"
#include "diagnostics/color.h"
+#include "diagnostics/file-cache.h"
#include "diagnostics/event-id.h"
#include "diagnostics/source-printing-effects.h"
#include "pretty-print-markup.h"
@@ -616,18 +617,24 @@ struct event_range
}
}
- /* If we have an UNKNOWN_LOCATION (or BUILTINS_LOCATION) as the
- primary location for an event, diagnostic_show_locus won't print
- anything.
-
- In particular the label for the event won't get printed.
- Fail more gracefully in this case by showing the event
- index and text, at no particular location. */
- if (get_pure_location (initial_loc) <= BUILTINS_LOCATION)
+ /* Ideally we will print events as labelled ranges within the
+ quoted source. But if there is no source, or we can't find it,
+ we need a fallback, or the events won't show up. Fail more
+ gracefully in this case by showing the event index and text. */
+ if (!can_print_source_p (dc))
{
for (unsigned i = m_start_idx; i <= m_end_idx; i++)
{
const event &iter_event = m_path.get_event (i);
+ location_t event_loc = iter_event.get_location ();
+ if (get_pure_location (event_loc) > BUILTINS_LOCATION)
+ {
+ // TODO: this implicitly uses "line_table"
+ gcc_assert (line_table);
+ expanded_location exploc (expand_location (event_loc));
+
+ pp_string (&pp, text_output.get_location_text (exploc).get ());
+ }
diagnostic_event_id_t event_id (i);
pp_printf (&pp, " %@: ", &event_id);
iter_event.print_desc (pp);
@@ -674,25 +681,46 @@ struct event_range
}
}
- /* If we have an UNKNOWN_LOCATION (or BUILTINS_LOCATION) as the
- primary location for an event, diagnostic_show_locus_as_html won't print
- anything.
-
- In particular the label for the event won't get printed.
- Fail more gracefully in this case by showing the event
- index and text, at no particular location. */
- if (get_pure_location (initial_loc) <= BUILTINS_LOCATION)
+ /* Ideally we will print events as labelled ranges within the
+ quoted source. But if there is no source, or we can't find it,
+ we need a fallback, or the events won't show up. Fail more
+ gracefully in this case by showing the event index and text. */
+ if (!can_print_source_p (dc))
{
for (unsigned i = m_start_idx; i <= m_end_idx; i++)
{
const event &iter_event = m_path.get_event (i);
- diagnostic_event_id_t event_id (i);
- pretty_printer pp;
- pp_printf (&pp, " %@: ", &event_id);
- iter_event.print_desc (pp);
+
+ xml::auto_print_element p (xp, "p");
+
if (event_label_writer)
event_label_writer->begin_label ();
- xp.add_text_from_pp (pp);
+
+ location_t event_loc = iter_event.get_location ();
+ if (get_pure_location (event_loc) > BUILTINS_LOCATION)
+ {
+ // TODO: this implicitly uses "line_table"
+ gcc_assert (line_table);
+ expanded_location exploc (expand_location (event_loc));
+
+ location_print_policy policy (dc);
+ policy.print_html_span_start (dc, xp, exploc);
+ }
+ {
+ diagnostic_event_id_t event_id (i);
+ pretty_printer pp;
+ pp_printf (&pp, " %@: ", &event_id);
+ xp.push_tag_with_class ("span", "event-id");
+ xp.add_text_from_pp (pp);
+ xp.pop_tag ("span");
+ }
+ {
+ pretty_printer pp;
+ iter_event.print_desc (pp);
+ xp.push_tag_with_class ("span", "event-text");
+ xp.add_text_from_pp (pp);
+ xp.pop_tag ("span");
+ }
if (event_label_writer)
event_label_writer->end_label ();
}
@@ -721,6 +749,30 @@ struct event_range
hash_map<int_hash<int, -1, -2>,
per_source_line_info> m_source_line_info_map;
bool m_show_event_links;
+
+private:
+ /* Return true if we can print source code for the primary location
+ for the initial event.
+
+ If we can't then the labels won't be printed, and thus we'll have
+ to fall back to printing the events directly for them to be
+ printed. */
+ bool can_print_source_p (diagnostics::context &dc) const
+ {
+ location_t initial_loc = m_initial_event.get_location ();
+ if (get_pure_location (initial_loc) <= BUILTINS_LOCATION)
+ return false;
+
+ // TODO: this implicitly uses "line_table"
+ expanded_location exploc (expand_location (initial_loc));
+
+ auto line_content
+ = dc.get_file_cache ().get_source_line (exploc.file, exploc.line);
+ if (!line_content)
+ return false;
+
+ return true;
+ }
};
/* A struct for grouping together the events in a path into
diff --git
a/gcc/testsuite/sarif-replay.dg/2.1.0-valid/missing-source-pr122622-check-html.py
b/gcc/testsuite/sarif-replay.dg/2.1.0-valid/missing-source-pr122622-check-html.py
new file mode 100644
index 00000000000..8b45488ad19
--- /dev/null
+++
b/gcc/testsuite/sarif-replay.dg/2.1.0-valid/missing-source-pr122622-check-html.py
@@ -0,0 +1,30 @@
+from htmltest import *
+
+import pytest
+
[email protected](scope='function', autouse=True)
+def html_tree():
+ return html_tree_from_env()
+
+def test_generated_html(html_tree):
+ root = html_tree.getroot ()
+ assert root.tag == make_tag('html')
+
+ head = root.find('xhtml:head', ns)
+ assert head is not None
+
+ diag = get_diag_by_index(html_tree, 0)
+
+ exec_path = diag.find("./xhtml:div[@id='execution-path']", ns)
+ assert exec_path is not None
+
+ label = exec_path.find('xhtml:label', ns)
+ assert label.text == 'Execution path with 18 events'
+
+ final_event = exec_path.find(".//xhtml:span[@id='gcc-diag-0-event-17']",
ns)
+ assert (ET.tostring(final_event, method='html').rstrip()
+ == (b'<html:span xmlns:html="http://www.w3.org/1999/xhtml"
class="event" id="gcc-diag-0-event-17">'
+ b'<html:span
class="location">../test/create_cert_test.c:118:3:</html:span>'
+ b'<html:span class="event-id"> (18): </html:span>'
+ b'<html:span class="event-text">‘ext_str’ leaks
here; was allocated at (13)</html:span>'
+ b'</html:span>'))
diff --git
a/gcc/testsuite/sarif-replay.dg/2.1.0-valid/missing-source-pr122622.sarif
b/gcc/testsuite/sarif-replay.dg/2.1.0-valid/missing-source-pr122622.sarif
new file mode 100644
index 00000000000..b007419f07b
--- /dev/null
+++ b/gcc/testsuite/sarif-replay.dg/2.1.0-valid/missing-source-pr122622.sarif
@@ -0,0 +1,506 @@
+/* { dg-additional-options
"-fdiagnostics-add-output=experimental-html:file=missing-source-pr122622.sarif.html,javascript=no"
} */
+
+{"$schema":
"https://docs.oasis-open.org/sarif/sarif/v2.1.0/errata01/os/schemas/sarif-schema-2.1.0.json",
+ "version": "2.1.0",
+ "runs": [{"tool": {"driver": {"name": "GNU C17",
+ "fullName": "GNU C17 (GCC) version 16.0.0
20250914 (experimental) (x86_64-pc-linux-gnu)",
+ "version": "16.0.0 20250914 (experimental)",
+ "informationUri": "https://gcc.gnu.org/gcc-16/",
+ "rules": [{"id": "-Wanalyzer-malloc-leak",
+ "helpUri":
"https://gcc.gnu.org/onlinedocs/gcc/Static-Analyzer-Options.html#index-Wanalyzer-malloc-leak"}]}},
+ "taxonomies": [{"name": "CWE",
+ "version": "4.7",
+ "organization": "MITRE",
+ "shortDescription": {"text": "The MITRE Common
Weakness Enumeration"},
+ "taxa": [{"id": "401",
+ "helpUri":
"https://cwe.mitre.org/data/definitions/401.html"}]}],
+ "invocations": [{"arguments":
["/opt/gcc-latest/libexec/gcc/x86_64-pc-linux-gnu/16.0.0/cc1",
+ "-quiet",
+ "-I",
+ "create_cert_test.p",
+ "-I",
+ ".",
+ "-I",
+ "..",
+ "-D",
+ "_FILE_OFFSET_BITS=64",
+ "-D",
+ "G_LOG_USE_STRUCTURED",
+ "../test/create_cert_test.c",
+ "-quiet",
+ "-dumpbase",
+ "create_cert_test.c",
+ "-dumpbase-ext",
+ ".c",
+ "-m64",
+ "-mtune=generic",
+ "-march=x86-64-v2",
+ "-O2",
+ "-Wno-unknown-pragmas",
+ "-std=gnu17",
+ "-flto=auto",
+ "-ffat-lto-objects",
+ "-fexceptions",
+ "-fstack-protector-strong",
+ "-fasynchronous-unwind-tables",
+ "-fstack-clash-protection",
+ "-fcf-protection=full",
+ "-fno-omit-frame-pointer",
+ "-fanalyzer",
+
"-fdiagnostics-path-format=separate-events",
+ "-fno-diagnostics-show-caret",
+ "-fno-lto",
+
"-fdiagnostics-text-art-charset=none",
+
"-fdiagnostics-set-output=sarif:file=/builddir/gcc-results/452-M3DZ.sarif",
+ "-o",
+ "/tmp/ccMq3Jbf.s"],
+ "workingDirectory": {"uri":
"/builddir/build/BUILD/sscg-4.0.0-build/sscg-sscg-4.0.0/redhat-linux-build"},
+ "startTimeUtc": "2025-10-28T20:31:29Z",
+ "executionSuccessful": true,
+ "toolExecutionNotifications": [],
+ "endTimeUtc": "2025-10-28T20:31:30Z"}],
+ "originalUriBaseIds": {"PWD": {"uri":
"file:///builddir/build/BUILD/sscg-4.0.0-build/sscg-sscg-4.0.0/redhat-linux-build/"}},
+ "artifacts": [{"location": {"uri": "../test/create_cert_test.c",
+ "uriBaseId": "PWD"},
+ "sourceLanguage": "c",
+ "roles": ["analysisTarget",
+ "tracedFile"]},
+ {"location": {"uri": "/usr/include/openssl/evp.h"},
+ "sourceLanguage": "c"},
+ {"location": {"uri": "/usr/include/openssl/x509.h"},
+ "sourceLanguage": "c"}],
+ "results": [{"ruleId": "-Wanalyzer-malloc-leak",
+ "taxa": [{"id": "401",
+ "toolComponent": {"name": "cwe"}}],
+ "properties": {"gcc/analyzer/saved_diagnostic/sm":
"malloc",
+ "gcc/analyzer/saved_diagnostic/enode":
590,
+ "gcc/analyzer/saved_diagnostic/snode":
189,
+ "gcc/analyzer/saved_diagnostic/stmt":
"BIO_read (_20, ext_str_27, ext_len_25);",
+ "gcc/analyzer/saved_diagnostic/var":
"ext_str_27",
+ "gcc/analyzer/saved_diagnostic/sval":
"&HEAP_ALLOCATED_REGION(275)",
+ "gcc/analyzer/saved_diagnostic/state":
"nonnull ({free})",
+ "gcc/analyzer/saved_diagnostic/idx": 0,
+
"gcc/analyzer/saved_diagnostic/duplicates": [{"properties":
{"gcc/analyzer/saved_diagnostic/sm": "malloc",
+
"gcc/analyzer/saved_diagnostic/enode": 590,
+
"gcc/analyzer/saved_diagnostic/snode": 189,
+
"gcc/analyzer/saved_diagnostic/stmt": "BIO_read (_20,
ext_str_27, ext_len_25);",
+
"gcc/analyzer/saved_diagnostic/var": "ext_str_27",
+
"gcc/analyzer/saved_diagnostic/sval":
"&HEAP_ALLOCATED_REGION(275)",
+
"gcc/analyzer/saved_diagnostic/state": "nonnull ({free})",
+
"gcc/analyzer/saved_diagnostic/idx": 1,
+
"gcc/analyzer/pending_diagnostic/kind": "malloc_leak"}}],
+ "gcc/analyzer/pending_diagnostic/kind":
"malloc_leak"},
+ "level": "warning",
+ "message": {"text": "leak of ‘ext_str’"},
+ "locations": [{"physicalLocation":
{"artifactLocation": {"uri": "../test/create_cert_test.c",
+
"uriBaseId": "PWD"},
+ "region":
{"startLine": 118,
+
"startColumn": 3,
+
"endColumn": 35},
+ "contextRegion":
{"startLine": 118,
+
"snippet": {"text": " BIO_read (bio, ext_str, ext_len);\n"}}},
+ "logicalLocations": [{"index": 0,
+
"fullyQualifiedName": "verify_name_constraints"}]}],
+ "codeFlows": [{"threadFlows": [{"id": "main",
+ "locations":
[{"properties": {"gcc/analyzer/checker_event/emission_id": "(1)",
+
"gcc/analyzer/checker_event/kind": "start_cfg_edge",
+
"gcc/analyzer/superedge_event/superedge": {"kind": "SUPEREDGE_CFG_EDGE",
+
"src_idx": 174,
+
"dst_idx": 177,
+
"desc": "false (flags
FALSE_VALUE | EXECUTABLE)"}},
+
"location": {"physicalLocation": {"artifactLocation": {"uri":
"../test/create_cert_test.c",
+
"uriBaseId": "PWD"},
+
"region": {"startLine": 61,
+
"startColumn": 6,
+
"endColumn": 7},
+
"contextRegion": {"startLine": 61,
+
"snippet": {"text": " if (ext_idx
< 0)\n"}}},
+
"logicalLocations": [{"index": 0,
+
"fullyQualifiedName": "verify_name_constraints"}],
+
"message": {"text": "following ‘false’ branch..."}},
+
"kinds": ["branch",
+
"false"],
+
"nestingLevel": 1,
+
"executionOrder": 1},
+
{"properties": {"gcc/analyzer/checker_event/emission_id": "(2)",
+
"gcc/analyzer/checker_event/kind": "end_cfg_edge",
+
"gcc/analyzer/superedge_event/superedge": {"kind": "SUPEREDGE_CFG_EDGE",
+
"src_idx": 174,
+
"dst_idx": 177,
+
"desc": "false (flags
FALSE_VALUE | EXECUTABLE)"}},
+
"location": {"physicalLocation": {"artifactLocation": {"uri":
"../test/create_cert_test.c",
+
"uriBaseId": "PWD"},
+
"region": {"startLine": 69,
+
"startColumn": 26,
+
"endColumn": 54},
+
"contextRegion": {"startLine": 69,
+
"snippet": {"text": "
name_constraints_ext = X509_get_ext (x509, ext_idx);\n"}}},
+
"logicalLocations": [{"index": 0,
+
"fullyQualifiedName": "verify_name_constraints"}],
+
"message": {"text": "...to here"}},
+
"kinds": ["branch",
+
"false"],
+
"nestingLevel": 1,
+
"executionOrder": 2},
+
{"properties": {"gcc/analyzer/checker_event/emission_id": "(3)",
+
"gcc/analyzer/checker_event/kind": "start_cfg_edge",
+
"gcc/analyzer/superedge_event/superedge": {"kind": "SUPEREDGE_CFG_EDGE",
+
"src_idx": 177,
+
"dst_idx": 179,
+
"desc": "false (flags
FALSE_VALUE | EXECUTABLE)"}},
+
"location": {"physicalLocation": {"artifactLocation": {"uri":
"../test/create_cert_test.c",
+
"uriBaseId": "PWD"},
+
"region": {"startLine": 70,
+
"startColumn": 6,
+
"endColumn": 7},
+
"contextRegion": {"startLine": 70,
+
"snippet": {"text": " if
(!name_constraints_ext)\n"}}},
+
"logicalLocations": [{"index": 0,
+
"fullyQualifiedName": "verify_name_constraints"}],
+
"message": {"text": "following ‘false’ branch..."}},
+
"kinds": ["branch",
+
"false"],
+
"nestingLevel": 1,
+
"executionOrder": 3},
+
{"properties": {"gcc/analyzer/checker_event/emission_id": "(4)",
+
"gcc/analyzer/checker_event/kind": "end_cfg_edge",
+
"gcc/analyzer/superedge_event/superedge": {"kind": "SUPEREDGE_CFG_EDGE",
+
"src_idx": 177,
+
"dst_idx": 179,
+
"desc": "false (flags
FALSE_VALUE | EXECUTABLE)"}},
+
"location": {"physicalLocation": {"artifactLocation": {"uri":
"../test/create_cert_test.c",
+
"uriBaseId": "PWD"},
+
"region": {"startLine": 77,
+
"startColumn": 14,
+
"endColumn": 60},
+
"contextRegion": {"startLine": 77,
+
"snippet": {"text": " ext_data =
X509_EXTENSION_get_data (name_constraints_ext);\n"}}},
+
"logicalLocations": [{"index": 0,
+
"fullyQualifiedName": "verify_name_constraints"}],
+
"message": {"text": "...to here"}},
+
"kinds": ["branch",
+
"false"],
+
"nestingLevel": 1,
+
"executionOrder": 4},
+
{"properties": {"gcc/analyzer/checker_event/emission_id": "(5)",
+
"gcc/analyzer/checker_event/kind": "start_cfg_edge",
+
"gcc/analyzer/superedge_event/superedge": {"kind": "SUPEREDGE_CFG_EDGE",
+
"src_idx": 179,
+
"dst_idx": 181,
+
"desc": "false (flags
FALSE_VALUE | EXECUTABLE)"}},
+
"location": {"physicalLocation": {"artifactLocation": {"uri":
"../test/create_cert_test.c",
+
"uriBaseId": "PWD"},
+
"region": {"startLine": 78,
+
"startColumn": 6,
+
"endColumn": 7},
+
"contextRegion": {"startLine": 78,
+
"snippet": {"text": " if
(!ext_data)\n"}}},
+
"logicalLocations": [{"index": 0,
+
"fullyQualifiedName": "verify_name_constraints"}],
+
"message": {"text": "following ‘false’ branch..."}},
+
"kinds": ["branch",
+
"false"],
+
"nestingLevel": 1,
+
"executionOrder": 5},
+
{"properties": {"gcc/analyzer/checker_event/emission_id": "(6)",
+
"gcc/analyzer/checker_event/kind": "end_cfg_edge",
+
"gcc/analyzer/superedge_event/superedge": {"kind": "SUPEREDGE_CFG_EDGE",
+
"src_idx": 179,
+
"dst_idx": 181,
+
"desc": "false (flags
FALSE_VALUE | EXECUTABLE)"}},
+
"location": {"physicalLocation": {"artifactLocation": {"uri":
"../test/create_cert_test.c",
+
"uriBaseId": "PWD"},
+
"region": {"startLine": 85,
+
"startColumn": 9,
+
"endColumn": 31},
+
"contextRegion": {"startLine": 85,
+
"snippet": {"text": " bio =
BIO_new (BIO_s_mem ());\n"}}},
+
"logicalLocations": [{"index": 0,
+
"fullyQualifiedName": "verify_name_constraints"}],
+
"message": {"text": "...to here"}},
+
"kinds": ["branch",
+
"false"],
+
"nestingLevel": 1,
+
"executionOrder": 6},
+
{"properties": {"gcc/analyzer/checker_event/emission_id": "(7)",
+
"gcc/analyzer/checker_event/kind": "start_cfg_edge",
+
"gcc/analyzer/superedge_event/superedge": {"kind": "SUPEREDGE_CFG_EDGE",
+
"src_idx": 181,
+
"dst_idx": 183,
+
"desc": "false (flags
FALSE_VALUE | EXECUTABLE)"}},
+
"location": {"physicalLocation": {"artifactLocation": {"uri":
"../test/create_cert_test.c",
+
"uriBaseId": "PWD"},
+
"region": {"startLine": 86,
+
"startColumn": 6,
+
"endColumn": 7},
+
"contextRegion": {"startLine": 86,
+
"snippet": {"text": " if
(!bio)\n"}}},
+
"logicalLocations": [{"index": 0,
+
"fullyQualifiedName": "verify_name_constraints"}],
+
"message": {"text": "following ‘false’ branch..."}},
+
"kinds": ["branch",
+
"false"],
+
"nestingLevel": 1,
+
"executionOrder": 7},
+
{"properties": {"gcc/analyzer/checker_event/emission_id": "(8)",
+
"gcc/analyzer/checker_event/kind": "end_cfg_edge",
+
"gcc/analyzer/superedge_event/superedge": {"kind": "SUPEREDGE_CFG_EDGE",
+
"src_idx": 181,
+
"dst_idx": 183,
+
"desc": "false (flags
FALSE_VALUE | EXECUTABLE)"}},
+
"location": {"physicalLocation": {"artifactLocation": {"uri":
"../test/create_cert_test.c",
+
"uriBaseId": "PWD"},
+
"region": {"startLine": 93,
+
"startColumn": 8,
+
"endColumn": 58},
+
"contextRegion": {"startLine": 93,
+
"snippet": {"text": " if
(!X509V3_EXT_print (bio, name_constraints_ext, 0, 0))\n"}}},
+
"logicalLocations": [{"index": 0,
+
"fullyQualifiedName": "verify_name_constraints"}],
+
"message": {"text": "...to here"}},
+
"kinds": ["branch",
+
"false"],
+
"nestingLevel": 1,
+
"executionOrder": 8},
+
{"properties": {"gcc/analyzer/checker_event/emission_id": "(9)",
+
"gcc/analyzer/checker_event/kind": "start_cfg_edge",
+
"gcc/analyzer/superedge_event/superedge": {"kind": "SUPEREDGE_CFG_EDGE",
+
"src_idx": 183,
+
"dst_idx": 185,
+
"desc": "false (flags
FALSE_VALUE | EXECUTABLE)"}},
+
"location": {"physicalLocation": {"artifactLocation": {"uri":
"../test/create_cert_test.c",
+
"uriBaseId": "PWD"},
+
"region": {"startLine": 93,
+
"startColumn": 6,
+
"endColumn": 7},
+
"contextRegion": {"startLine": 93,
+
"snippet": {"text": " if
(!X509V3_EXT_print (bio, name_constraints_ext, 0, 0))\n"}}},
+
"logicalLocations": [{"index": 0,
+
"fullyQualifiedName": "verify_name_constraints"}],
+
"message": {"text": "following ‘false’ branch..."}},
+
"kinds": ["branch",
+
"false"],
+
"nestingLevel": 1,
+
"executionOrder": 9},
+
{"properties": {"gcc/analyzer/checker_event/emission_id": "(10)",
+
"gcc/analyzer/checker_event/kind": "end_cfg_edge",
+
"gcc/analyzer/superedge_event/superedge": {"kind": "SUPEREDGE_CFG_EDGE",
+
"src_idx": 183,
+
"dst_idx": 185,
+
"desc": "false (flags
FALSE_VALUE | EXECUTABLE)"}},
+
"location": {"physicalLocation": {"artifactLocation": {"uri":
"../test/create_cert_test.c",
+
"uriBaseId": "PWD"},
+
"region": {"startLine": 101,
+
"startColumn": 13,
+
"endColumn": 14},
+
"contextRegion": {"startLine": 101,
+
"snippet": {"text": " ext_len =
BIO_pending (bio);\n"}}},
+
"logicalLocations": [{"index": 0,
+
"fullyQualifiedName": "verify_name_constraints"}],
+
"message": {"text": "...to here"},
+
"id": 0,
+
"relationships": [{"target": 1,
+
"kinds": ["isIncludedBy"]}]},
+
"kinds": ["branch",
+
"false"],
+
"nestingLevel": 1,
+
"executionOrder": 10},
+
{"properties": {"gcc/analyzer/checker_event/emission_id": "(11)",
+
"gcc/analyzer/checker_event/kind": "start_cfg_edge",
+
"gcc/analyzer/superedge_event/superedge": {"kind": "SUPEREDGE_CFG_EDGE",
+
"src_idx": 185,
+
"dst_idx": 187,
+
"desc": "false (flags
FALSE_VALUE | EXECUTABLE)"}},
+
"location": {"physicalLocation": {"artifactLocation": {"uri":
"../test/create_cert_test.c",
+
"uriBaseId": "PWD"},
+
"region": {"startLine": 102,
+
"startColumn": 6,
+
"endColumn": 7},
+
"contextRegion": {"startLine": 102,
+
"snippet": {"text": " if (ext_len
<= 0)\n"}}},
+
"logicalLocations": [{"index": 0,
+
"fullyQualifiedName": "verify_name_constraints"}],
+
"message": {"text": "following ‘false’ branch (when ‘ext_len > 0’)..."}},
+
"kinds": ["branch",
+
"false"],
+
"nestingLevel": 1,
+
"executionOrder": 11},
+
{"properties": {"gcc/analyzer/checker_event/emission_id": "(12)",
+
"gcc/analyzer/checker_event/kind": "end_cfg_edge",
+
"gcc/analyzer/superedge_event/superedge": {"kind": "SUPEREDGE_CFG_EDGE",
+
"src_idx": 185,
+
"dst_idx": 187,
+
"desc": "false (flags
FALSE_VALUE | EXECUTABLE)"}},
+
"location": {"physicalLocation": {"artifactLocation": {"uri":
"../test/create_cert_test.c",
+
"uriBaseId": "PWD"},
+
"region": {"startLine": 109,
+
"startColumn": 21,
+
"endColumn": 32},
+
"contextRegion": {"startLine": 109,
+
"snippet": {"text": " ext_str =
malloc (ext_len + 1);\n"}}},
+
"logicalLocations": [{"index": 0,
+
"fullyQualifiedName": "verify_name_constraints"}],
+
"message": {"text": "...to here"}},
+
"kinds": ["branch",
+
"false"],
+
"nestingLevel": 1,
+
"executionOrder": 12},
+
{"properties": {"gcc/analyzer/checker_event/emission_id": "(13)",
+
"gcc/analyzer/checker_event/kind": "state_change"},
+
"location": {"physicalLocation": {"artifactLocation": {"uri":
"../test/create_cert_test.c",
+
"uriBaseId": "PWD"},
+
"region": {"startLine": 109,
+
"startColumn": 13,
+
"endColumn": 33},
+
"contextRegion": {"startLine": 109,
+
"snippet": {"text": " ext_str =
malloc (ext_len + 1);\n"}}},
+
"logicalLocations": [{"index": 0,
+
"fullyQualifiedName": "verify_name_constraints"}],
+
"message": {"text": "allocated here"}},
+
"kinds": ["acquire",
+
"memory"],
+
"nestingLevel": 1,
+
"executionOrder": 13},
+
{"properties": {"gcc/analyzer/checker_event/emission_id": "(14)",
+
"gcc/analyzer/checker_event/kind": "state_change"},
+
"location": {"physicalLocation": {"artifactLocation": {"uri":
"../test/create_cert_test.c",
+
"uriBaseId": "PWD"},
+
"region": {"startLine": 110,
+
"startColumn": 6,
+
"endColumn": 7},
+
"contextRegion": {"startLine": 110,
+
"snippet": {"text": " if
(!ext_str)\n"}}},
+
"logicalLocations": [{"index": 0,
+
"fullyQualifiedName": "verify_name_constraints"}],
+
"message": {"text": "assuming ‘ext_str’ is non-NULL"}},
+
"nestingLevel": 1,
+
"executionOrder": 14},
+
{"properties": {"gcc/analyzer/checker_event/emission_id": "(15)",
+
"gcc/analyzer/checker_event/kind": "start_cfg_edge",
+
"gcc/analyzer/superedge_event/superedge": {"kind": "SUPEREDGE_CFG_EDGE",
+
"src_idx": 187,
+
"dst_idx": 189,
+
"desc": "false (flags
FALSE_VALUE | EXECUTABLE)"}},
+
"location": {"physicalLocation": {"artifactLocation": {"uri":
"../test/create_cert_test.c",
+
"uriBaseId": "PWD"},
+
"region": {"startLine": 110,
+
"startColumn": 6,
+
"endColumn": 7},
+
"contextRegion": {"startLine": 110,
+
"snippet": {"text": " if
(!ext_str)\n"}}},
+
"logicalLocations": [{"index": 0,
+
"fullyQualifiedName": "verify_name_constraints"}],
+
"message": {"text": "following ‘false’ branch (when ‘ext_str’ is
non-NULL)..."}},
+
"kinds": ["branch",
+
"false"],
+
"nestingLevel": 1,
+
"executionOrder": 15},
+
{"properties": {"gcc/analyzer/checker_event/emission_id": "(16)",
+
"gcc/analyzer/checker_event/kind": "end_cfg_edge",
+
"gcc/analyzer/superedge_event/superedge": {"kind": "SUPEREDGE_CFG_EDGE",
+
"src_idx": 187,
+
"dst_idx": 189,
+
"desc": "false (flags
FALSE_VALUE | EXECUTABLE)"}},
+
"location": {"physicalLocation": {"artifactLocation": {"uri":
"../test/create_cert_test.c",
+
"uriBaseId": "PWD"},
+
"region": {"startLine": 118,
+
"startColumn": 3,
+
"endColumn": 35},
+
"contextRegion": {"startLine": 118,
+
"snippet": {"text": " BIO_read
(bio, ext_str, ext_len);\n"}}},
+
"logicalLocations": [{"index": 0,
+
"fullyQualifiedName": "verify_name_constraints"}],
+
"message": {"text": "...to here"}},
+
"kinds": ["branch",
+
"false"],
+
"nestingLevel": 1,
+
"executionOrder": 16},
+
{"properties": {"gcc/analyzer/checker_event/emission_id": "(17)",
+
"gcc/analyzer/checker_event/kind": "throw"},
+
"location": {"physicalLocation": {"artifactLocation": {"uri":
"../test/create_cert_test.c",
+
"uriBaseId": "PWD"},
+
"region": {"startLine": 118,
+
"startColumn": 3,
+
"endColumn": 35},
+
"contextRegion": {"startLine": 118,
+
"snippet": {"text": " BIO_read
(bio, ext_str, ext_len);\n"}}},
+
"logicalLocations": [{"index": 0,
+
"fullyQualifiedName": "verify_name_constraints"}],
+
"message": {"text": "if ‘BIO_read’ throws an exception..."}},
+
"nestingLevel": 1,
+
"executionOrder": 17},
+
{"properties": {"gcc/analyzer/checker_event/emission_id": "(18)",
+
"gcc/analyzer/checker_event/kind": "warning"},
+
"location": {"physicalLocation": {"artifactLocation": {"uri":
"../test/create_cert_test.c",
+
"uriBaseId": "PWD"},
+
"region": {"startLine": 118,
+
"startColumn": 3,
+
"endColumn": 35},
+
"contextRegion": {"startLine": 118,
+
"snippet": {"text": " BIO_read
(bio, ext_str, ext_len);\n"}}},
+
"logicalLocations": [{"index": 0,
+
"fullyQualifiedName": "verify_name_constraints"}],
+
"message": {"text": "‘ext_str’ leaks here; was allocated at
[(13)](sarif:/runs/0/results/0/codeFlows/0/threadFlows/0/locations/12)"}},
+
"kinds": ["danger"],
+
"nestingLevel": 1,
+
"executionOrder": 18}]}]}],
+ "relatedLocations": [{"physicalLocation":
{"artifactLocation": {"uri": "/usr/include/openssl/evp.h"},
+ "region":
{"startLine": 30},
+
"contextRegion": {"startLine": 30,
+
"snippet": {"text": "# include <openssl/bio.h>\n"}}},
+ "relationships": [{"target": 0,
+ "kinds":
["includes"]},
+ {"target": 2,
+ "kinds":
["isIncludedBy"]}],
+ "id": 1},
+ {"physicalLocation":
{"artifactLocation": {"uri": "/usr/include/openssl/x509.h"},
+ "region":
{"startLine": 29},
+
"contextRegion": {"startLine": 29,
+
"snippet": {"text": "# include <openssl/evp.h>\n"}}},
+ "relationships": [{"target": 1,
+ "kinds":
["includes"]},
+ {"target": 3,
+ "kinds":
["isIncludedBy"]}],
+ "id": 2},
+ {"physicalLocation":
{"artifactLocation": {"uri": "../test/create_cert_test.c",
+
"uriBaseId": "PWD"},
+ "region":
{"startLine": 38},
+
"contextRegion": {"startLine": 38,
+
"snippet": {"text": "#include <openssl/x509.h>\n"}}},
+ "relationships": [{"target": 2,
+ "kinds":
["includes"]}],
+ "id": 3}]}],
+ "logicalLocations": [{"name": "verify_name_constraints",
+ "fullyQualifiedName":
"verify_name_constraints",
+ "decoratedName": "verify_name_constraints",
+ "kind": "function",
+ "index": 0}]}]}
+
+/* { dg-begin-multiline-output "" }
+In function 'verify_name_constraints':
+../test/create_cert_test.c:118:3: warning: leak of ‘ext_str’
[-Wanalyzer-malloc-leak]
+......
+ 'verify_name_constraints': events 1-18
+../test/create_cert_test.c:61:6: (1): following ‘false’ branch...
+../test/create_cert_test.c:69:26: (2): ...to here
+../test/create_cert_test.c:70:6: (3): following ‘false’ branch...
+../test/create_cert_test.c:77:14: (4): ...to here
+../test/create_cert_test.c:78:6: (5): following ‘false’ branch...
+../test/create_cert_test.c:85:9: (6): ...to here
+../test/create_cert_test.c:86:6: (7): following ‘false’ branch...
+../test/create_cert_test.c:93:8: (8): ...to here
+../test/create_cert_test.c:93:6: (9): following ‘false’ branch...
+../test/create_cert_test.c:101:13: (10): ...to here
+../test/create_cert_test.c:102:6: (11): following ‘false’ branch (when
‘ext_len > 0’)...
+../test/create_cert_test.c:109:21: (12): ...to here
+../test/create_cert_test.c:109:13: (13): allocated here
+../test/create_cert_test.c:110:6: (14): assuming ‘ext_str’ is non-NULL
+../test/create_cert_test.c:110:6: (15): following ‘false’ branch (when
‘ext_str’ is non-NULL)...
+../test/create_cert_test.c:118:3: (16): ...to here
+../test/create_cert_test.c:118:3: (17): if ‘BIO_read’ throws an exception...
+../test/create_cert_test.c:118:3: (18): ‘ext_str’ leaks here; was allocated at
(13)
+ { dg-end-multiline-output "" } */
+
+/* Use a Python script to verify various properties about the generated
+ .html file:
+ { dg-final { run-html-pytest missing-source-pr122622.sarif
"2.1.0-valid/missing-source-pr122622-check-html.py" } } */
diff --git a/gcc/testsuite/sarif-replay.dg/2.1.0-valid/spec-example-4.sarif
b/gcc/testsuite/sarif-replay.dg/2.1.0-valid/spec-example-4.sarif
index c0f0fd50e0e..a28e41e1409 100644
--- a/gcc/testsuite/sarif-replay.dg/2.1.0-valid/spec-example-4.sarif
+++ b/gcc/testsuite/sarif-replay.dg/2.1.0-valid/spec-example-4.sarif
@@ -750,10 +750,10 @@
In function 'collections::list::add':
collections/list.h:15:9: error: Variable "ptr" was used without being
initialized. It was declared here. [C2001]
'add': events 1-3
-......
+collections/list.h:15: (1): Variable "ptr" declared.
+collections/list.h:15: (2):
+collections/list.h:25: (3): Uninitialized variable "ptr" passed to method
"add_core".
{ dg-end-multiline-output "" } */
/* { dg-begin-multiline-output "" }
collections/list.h:8:5: note: Variable "ptr" was declared here.
{ dg-end-multiline-output "" } */
-
-// TODO: what's up with the events?
diff --git a/gcc/testsuite/sarif-replay.dg/2.1.0-valid/tutorial-example.sarif
b/gcc/testsuite/sarif-replay.dg/2.1.0-valid/tutorial-example.sarif
index 73b879dab28..db220e85c8f 100644
--- a/gcc/testsuite/sarif-replay.dg/2.1.0-valid/tutorial-example.sarif
+++ b/gcc/testsuite/sarif-replay.dg/2.1.0-valid/tutorial-example.sarif
@@ -107,11 +107,11 @@
bad-eval-with-code-flow.py:10: warning: Use of tainted variable 'raw_input' in
the insecure function 'eval'. [PY2335]
events 1-2
|
+ |bad-eval-with-code-flow.py:5: (1):
+ |bad-eval-with-code-flow.py:6: (2):
|
+--> event 3
|
+ |bad-eval-with-code-flow.py:10: (3):
|
{ dg-end-multiline-output "" } */
-
-// TODO: show path even when we can't find the source
-// TODO: show path when we can find the source
\ No newline at end of file
--
2.26.3
