Commit 9b9d6370 by Martin Liska Committed by Martin Liska

Introduce new option -w which shows verbose informations.

2017-04-28  Martin Liska  <mliska@suse.cz>

	* gcov.c (process_args): Handle new argument 'w'.
	(read_graph_file): Assign ID to BBs.
	(output_branch_count): Display BB # if verbose flag is set.
	(output_lines): Likewise for arcs.
	(print_usage): Add '--verbose' option help.
	* doc/gcov.texi: Document --verbose (-w) option.

From-SVN: r247373
parent 0790260e
2017-04-28 Martin Liska <mliska@suse.cz> 2017-04-28 Martin Liska <mliska@suse.cz>
* gcov.c (process_args): Handle new argument 'w'.
(read_graph_file): Assign ID to BBs.
(output_branch_count): Display BB # if verbose flag is set.
(output_lines): Likewise for arcs.
(print_usage): Add '--verbose' option help.
* doc/gcov.texi: Document --verbose (-w) option.
2017-04-28 Martin Liska <mliska@suse.cz>
* gcov.c (struct block_location_info): New struct. * gcov.c (struct block_location_info): New struct.
(process_file): Fill up the new structure. (process_file): Fill up the new structure.
(read_graph_file): Replace usage of encoding by the newly added (read_graph_file): Replace usage of encoding by the newly added
......
...@@ -289,6 +289,10 @@ where the @var{source-file} component is the final filename part and ...@@ -289,6 +289,10 @@ where the @var{source-file} component is the final filename part and
the @var{md5} component is calculated from the full mangled name that the @var{md5} component is calculated from the full mangled name that
would have been used otherwise. would have been used otherwise.
@item -w
@itemx --verbose
Print verbose informations related to basic blocks and arcs.
@end table @end table
@command{gcov} should be run with the current directory the same as that @command{gcov} should be run with the current directory the same as that
......
...@@ -140,6 +140,8 @@ typedef struct block_info ...@@ -140,6 +140,8 @@ typedef struct block_info
gcov_type num_succ; gcov_type num_succ;
gcov_type num_pred; gcov_type num_pred;
unsigned id;
/* Block execution count. */ /* Block execution count. */
gcov_type count; gcov_type count;
unsigned count_valid : 1; unsigned count_valid : 1;
...@@ -369,6 +371,10 @@ static int flag_long_names = 0; ...@@ -369,6 +371,10 @@ static int flag_long_names = 0;
static int flag_hash_filenames = 0; static int flag_hash_filenames = 0;
/* Print verbose informations. */
static int flag_verbose = 0;
/* Output count information for every basic block, not merely those /* Output count information for every basic block, not merely those
that contain line number information. */ that contain line number information. */
...@@ -700,6 +706,7 @@ print_usage (int error_p) ...@@ -700,6 +706,7 @@ print_usage (int error_p)
fnotice (file, " -s, --source-prefix DIR Source prefix to elide\n"); fnotice (file, " -s, --source-prefix DIR Source prefix to elide\n");
fnotice (file, " -u, --unconditional-branches Show unconditional branch counts too\n"); fnotice (file, " -u, --unconditional-branches Show unconditional branch counts too\n");
fnotice (file, " -v, --version Print version number, then exit\n"); fnotice (file, " -v, --version Print version number, then exit\n");
fnotice (file, " -w, --verbose Print verbose informations\n");
fnotice (file, " -x, --hash-filenames Hash long pathnames\n"); fnotice (file, " -x, --hash-filenames Hash long pathnames\n");
fnotice (file, "\nFor bug reporting instructions, please see:\n%s.\n", fnotice (file, "\nFor bug reporting instructions, please see:\n%s.\n",
bug_report_url); bug_report_url);
...@@ -725,6 +732,7 @@ static const struct option options[] = ...@@ -725,6 +732,7 @@ static const struct option options[] =
{ {
{ "help", no_argument, NULL, 'h' }, { "help", no_argument, NULL, 'h' },
{ "version", no_argument, NULL, 'v' }, { "version", no_argument, NULL, 'v' },
{ "verbose", no_argument, NULL, 'w' },
{ "all-blocks", no_argument, NULL, 'a' }, { "all-blocks", no_argument, NULL, 'a' },
{ "branch-probabilities", no_argument, NULL, 'b' }, { "branch-probabilities", no_argument, NULL, 'b' },
{ "branch-counts", no_argument, NULL, 'c' }, { "branch-counts", no_argument, NULL, 'c' },
...@@ -751,7 +759,7 @@ process_args (int argc, char **argv) ...@@ -751,7 +759,7 @@ process_args (int argc, char **argv)
{ {
int opt; int opt;
const char *opts = "abcdfhilmno:prs:uvx"; const char *opts = "abcdfhilmno:prs:uvwx";
while ((opt = getopt_long (argc, argv, opts, options, NULL)) != -1) while ((opt = getopt_long (argc, argv, opts, options, NULL)) != -1)
{ {
switch (opt) switch (opt)
...@@ -806,6 +814,9 @@ process_args (int argc, char **argv) ...@@ -806,6 +814,9 @@ process_args (int argc, char **argv)
case 'x': case 'x':
flag_hash_filenames = 1; flag_hash_filenames = 1;
break; break;
case 'w':
flag_verbose = 1;
break;
case 'v': case 'v':
print_version (); print_version ();
/* print_version will exit. */ /* print_version will exit. */
...@@ -1375,6 +1386,7 @@ read_graph_file (void) ...@@ -1375,6 +1386,7 @@ read_graph_file (void)
else if (fn && tag == GCOV_TAG_ARCS) else if (fn && tag == GCOV_TAG_ARCS)
{ {
unsigned src = gcov_read_unsigned (); unsigned src = gcov_read_unsigned ();
fn->blocks[src].id = src;
unsigned num_dests = GCOV_TAG_ARCS_NUM (length); unsigned num_dests = GCOV_TAG_ARCS_NUM (length);
block_t *src_blk = &fn->blocks[src]; block_t *src_blk = &fn->blocks[src];
unsigned mark_catches = 0; unsigned mark_catches = 0;
...@@ -2399,12 +2411,17 @@ output_branch_count (FILE *gcov_file, int ix, const arc_t *arc) ...@@ -2399,12 +2411,17 @@ output_branch_count (FILE *gcov_file, int ix, const arc_t *arc)
else if (!arc->is_unconditional) else if (!arc->is_unconditional)
{ {
if (arc->src->count) if (arc->src->count)
fnotice (gcov_file, "branch %2d taken %s%s\n", ix, fnotice (gcov_file, "branch %2d taken %s%s", ix,
format_gcov (arc->count, arc->src->count, -flag_counts), format_gcov (arc->count, arc->src->count, -flag_counts),
arc->fall_through ? " (fallthrough)" arc->fall_through ? " (fallthrough)"
: arc->is_throw ? " (throw)" : ""); : arc->is_throw ? " (throw)" : "");
else else
fnotice (gcov_file, "branch %2d never executed\n", ix); fnotice (gcov_file, "branch %2d never executed", ix);
if (flag_verbose)
fnotice (gcov_file, " (BB %d)", arc->dst->id);
fnotice (gcov_file, "\n");
} }
else if (flag_unconditional && !arc->dst->is_call_return) else if (flag_unconditional && !arc->dst->is_call_return)
{ {
...@@ -2541,11 +2558,16 @@ output_lines (FILE *gcov_file, const source_t *src) ...@@ -2541,11 +2558,16 @@ output_lines (FILE *gcov_file, const source_t *src)
block = block->chain) block = block->chain)
{ {
if (!block->is_call_return) if (!block->is_call_return)
fprintf (gcov_file, "%9s:%5u-block %2d\n", {
!line->exists ? "-" : block->count fprintf (gcov_file, "%9s:%5u-block %2d",
? format_gcov (block->count, 0, -1) !line->exists ? "-" : block->count
: block->exceptional ? "%%%%%" : "$$$$$", ? format_gcov (block->count, 0, -1)
line_num, ix++); : block->exceptional ? "%%%%%" : "$$$$$",
line_num, ix++);
if (flag_verbose)
fprintf (gcov_file, " (BB %u)", block->id);
fprintf (gcov_file, "\n");
}
if (flag_branches) if (flag_branches)
for (arc = block->succ; arc; arc = arc->succ_next) for (arc = block->succ; arc; arc = arc->succ_next)
jx += output_branch_count (gcov_file, jx, arc); jx += output_branch_count (gcov_file, jx, arc);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment