diff options
author | Ian Lance Taylor <iant@golang.org> | 2023-06-21 11:04:04 -0700 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2023-06-21 11:04:04 -0700 |
commit | 97e31a0a2a2d2273687fcdb4e5416aab1a2186e1 (patch) | |
tree | d5c1cae4de436a0fe54a5f0a2a197d309f3d654c /gcc/gcov.cc | |
parent | 6612f4f8cb9b0d5af18ec69ad04e56debc3e6ced (diff) | |
parent | 577223aebc7acdd31e62b33c1682fe54a622ae27 (diff) | |
download | gcc-97e31a0a2a2d2273687fcdb4e5416aab1a2186e1.zip gcc-97e31a0a2a2d2273687fcdb4e5416aab1a2186e1.tar.gz gcc-97e31a0a2a2d2273687fcdb4e5416aab1a2186e1.tar.bz2 |
Merge from trunk revision 577223aebc7acdd31e62b33c1682fe54a622ae27.
Diffstat (limited to 'gcc/gcov.cc')
-rw-r--r-- | gcc/gcov.cc | 34 |
1 files changed, 29 insertions, 5 deletions
diff --git a/gcc/gcov.cc b/gcc/gcov.cc index 2ec7248..2fad6aa 100644 --- a/gcc/gcov.cc +++ b/gcc/gcov.cc @@ -58,6 +58,8 @@ using namespace std; #include "gcov-io.h" #include "gcov-io.cc" +#define GCOV_JSON_FORMAT_VERSION "2" + /* The gcno file is generated by -ftest-coverage option. The gcda file is generated by a program compiled with -fprofile-arcs. Their formats are documented in gcov-io.h. */ @@ -964,6 +966,7 @@ static void print_version (void) { fnotice (stdout, "gcov %s%s\n", pkgversion_string, version_string); + fnotice (stdout, "JSON format version: %s\n", GCOV_JSON_FORMAT_VERSION); fprintf (stdout, "Copyright %s 2023 Free Software Foundation, Inc.\n", _("(C)")); fnotice (stdout, @@ -1113,9 +1116,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 +1139,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 +1549,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 (GCOV_JSON_FORMAT_VERSION)); root->set ("gcc_version", new json::string (version_string)); if (bbg_cwd != NULL) @@ -3060,9 +3086,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 +3096,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"); |