diff options
author | Martin Liska <mliska@suse.cz> | 2023-04-06 11:54:51 +0200 |
---|---|---|
committer | Martin Liska <mliska@suse.cz> | 2023-04-25 13:11:29 +0200 |
commit | 171fe0681ef91ecf29164d278ca5b064a6056f80 (patch) | |
tree | a3c8fcb2126373d995b6e8a86a42b0ddda71ce44 /gcc/gcov.cc | |
parent | dee5cef280d6c6da92b56cc0dc2158761c266992 (diff) | |
download | gcc-171fe0681ef91ecf29164d278ca5b064a6056f80.zip gcc-171fe0681ef91ecf29164d278ca5b064a6056f80.tar.gz gcc-171fe0681ef91ecf29164d278ca5b064a6056f80.tar.bz2 |
gcov: add info about "calls" to JSON output format
gcc/ChangeLog:
* doc/gcov.texi: Document the new "calls" field and document
the API bump. Mention also "block_ids" for lines.
* gcov.cc (output_intermediate_json_line): Output info about
calls and extend branches as well.
(generate_results): Bump version to 2.
(output_line_details): Use block ID instead of a non-sensual
index.
gcc/testsuite/ChangeLog:
* g++.dg/gcov/gcov-17.C: Add call to a noreturn function.
* g++.dg/gcov/test-gcov-17.py: Cover new format.
* lib/gcov.exp: Add options for gcov that emit the extra info.
Diffstat (limited to 'gcc/gcov.cc')
-rw-r--r-- | gcc/gcov.cc | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/gcc/gcov.cc b/gcc/gcov.cc index 2ec7248..d96b4f7 100644 --- a/gcc/gcov.cc +++ b/gcc/gcov.cc @@ -1113,9 +1113,17 @@ output_intermediate_json_line (json::array *object, lineo->set ("unexecuted_block", new json::literal (line->has_unexecuted_block)); + json::array *bb_ids = new json::array (); + for (const block_info *block : line->blocks) + bb_ids->append (new json::integer_number (block->id)); + lineo->set ("block_ids", bb_ids); + json::array *branches = new json::array (); lineo->set ("branches", branches); + json::array *calls = new json::array (); + lineo->set ("calls", calls); + vector<arc_info *>::const_iterator it; if (flag_branches) for (it = line->branches.begin (); it != line->branches.end (); @@ -1128,8 +1136,23 @@ output_intermediate_json_line (json::array *object, branch->set ("throw", new json::literal ((*it)->is_throw)); branch->set ("fallthrough", new json::literal ((*it)->fall_through)); + branch->set ("source_block_id", + new json::integer_number ((*it)->src->id)); + branch->set ("destination_block_id", + new json::integer_number ((*it)->dst->id)); branches->append (branch); } + else if ((*it)->is_call_non_return) + { + json::object *call = new json::object (); + gcov_type returns = (*it)->src->count - (*it)->count; + call->set ("source_block_id", + new json::integer_number ((*it)->src->id)); + call->set ("destination_block_id", + new json::integer_number ((*it)->dst->id)); + call->set ("returned", new json::integer_number (returns)); + calls->append (call); + } } object->append (lineo); @@ -1523,7 +1546,7 @@ generate_results (const char *file_name) gcov_intermediate_filename = get_gcov_intermediate_filename (file_name); json::object *root = new json::object (); - root->set ("format_version", new json::string ("1")); + root->set ("format_version", new json::string ("2")); root->set ("gcc_version", new json::string (version_string)); if (bbg_cwd != NULL) @@ -3060,9 +3083,7 @@ output_line_details (FILE *f, const line_info *line, unsigned line_num) if (flag_all_blocks) { arc_info *arc; - int ix, jx; - - ix = jx = 0; + int jx = 0; for (vector<block_info *>::const_iterator it = line->blocks.begin (); it != line->blocks.end (); it++) { @@ -3072,7 +3093,7 @@ output_line_details (FILE *f, const line_info *line, unsigned line_num) (*it)->exceptional, false, (*it)->count, line_num, "%%%%%", "$$$$$", 0); - fprintf (f, "-block %2d", ix++); + fprintf (f, "-block %d", (*it)->id); if (flag_verbose) fprintf (f, " (BB %u)", (*it)->id); fprintf (f, "\n"); |