public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: marxin <mliska@suse.cz>
To: gcc-patches@gcc.gnu.org
Cc: hubicka@ucw.cz,    nathan@acm.org
Subject: [PATCH 4/8] Introduce new option -w which shows verbose informations.
Date: Fri, 28 Apr 2017 09:31:00 -0000	[thread overview]
Message-ID: <9d9bfc7d95539ba96a86d7f94b9b828b60729810.1493371589.git.mliska@suse.cz> (raw)
In-Reply-To: <cover.1493371589.git.mliska@suse.cz>

gcc/ChangeLog:

2017-04-26  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.
---
 gcc/doc/gcov.texi |  4 ++++
 gcc/gcov.c        | 38 ++++++++++++++++++++++++++++++--------
 2 files changed, 34 insertions(+), 8 deletions(-)

diff --git a/gcc/doc/gcov.texi b/gcc/doc/gcov.texi
index d728444e1e7..2b4101018a2 100644
--- a/gcc/doc/gcov.texi
+++ b/gcc/doc/gcov.texi
@@ -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
 would have been used otherwise.
 
+@item -w
+@itemx --verbose
+Print verbose informations related to basic blocks and arcs.
+
 @end table
 
 @command{gcov} should be run with the current directory the same as that
diff --git a/gcc/gcov.c b/gcc/gcov.c
index 7400cdee110..6163d7d6dee 100644
--- a/gcc/gcov.c
+++ b/gcc/gcov.c
@@ -137,6 +137,8 @@ typedef struct block_info
   gcov_type num_succ;
   gcov_type num_pred;
 
+  unsigned id;
+
   /* Block execution count.  */
   gcov_type count;
   unsigned count_valid : 1;
@@ -366,6 +368,10 @@ static int flag_long_names = 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
    that contain line number information.  */
 
@@ -696,6 +702,7 @@ print_usage (int error_p)
   fnotice (file, "  -s, --source-prefix DIR         Source prefix to elide\n");
   fnotice (file, "  -u, --unconditional-branches    Show unconditional branch counts too\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, "\nFor bug reporting instructions, please see:\n%s.\n",
 	   bug_report_url);
@@ -721,6 +728,7 @@ static const struct option options[] =
 {
   { "help",                 no_argument,       NULL, 'h' },
   { "version",              no_argument,       NULL, 'v' },
+  { "verbose",              no_argument,       NULL, 'w' },
   { "all-blocks",           no_argument,       NULL, 'a' },
   { "branch-probabilities", no_argument,       NULL, 'b' },
   { "branch-counts",        no_argument,       NULL, 'c' },
@@ -747,7 +755,7 @@ process_args (int argc, char **argv)
 {
   int opt;
 
-  const char *opts = "abcdfhilmno:prs:uvx";
+  const char *opts = "abcdfhilmno:prs:uvwx";
   while ((opt = getopt_long (argc, argv, opts, options, NULL)) != -1)
     {
       switch (opt)
@@ -802,6 +810,9 @@ process_args (int argc, char **argv)
 	case 'x':
 	  flag_hash_filenames = 1;
 	  break;
+	case 'w':
+	  flag_verbose = 1;
+	  break;
 	case 'v':
 	  print_version ();
 	  /* print_version will exit.  */
@@ -1371,6 +1382,7 @@ read_graph_file (void)
       else if (fn && tag == GCOV_TAG_ARCS)
 	{
 	  unsigned src = gcov_read_unsigned ();
+	  fn->blocks[src].id = src;
 	  unsigned num_dests = GCOV_TAG_ARCS_NUM (length);
 	  block_t *src_blk = &fn->blocks[src];
 	  unsigned mark_catches = 0;
@@ -2395,12 +2407,17 @@ output_branch_count (FILE *gcov_file, int ix, const arc_t *arc)
   else if (!arc->is_unconditional)
     {
       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),
 		 arc->fall_through ? " (fallthrough)"
 		 : arc->is_throw ? " (throw)" : "");
       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)
     {
@@ -2537,11 +2554,16 @@ output_lines (FILE *gcov_file, const source_t *src)
 	       block = block->chain)
 	    {
 	      if (!block->is_call_return)
-		fprintf (gcov_file, "%9s:%5u-block %2d\n",
-			 !line->exists ? "-" : block->count
-			 ? format_gcov (block->count, 0, -1)
-			 : block->exceptional ? "%%%%%" : "$$$$$",
-			 line_num, ix++);
+		{
+		  fprintf (gcov_file, "%9s:%5u-block %2d",
+			   !line->exists ? "-" : block->count
+			   ? format_gcov (block->count, 0, -1)
+			   : block->exceptional ? "%%%%%" : "$$$$$",
+			   line_num, ix++);
+		  if (flag_verbose)
+		    fprintf (gcov_file, " (BB %u)", block->id);
+		  fprintf (gcov_file, "\n");
+		}
 	      if (flag_branches)
 		for (arc = block->succ; arc; arc = arc->succ_next)
 		  jx += output_branch_count (gcov_file, jx, arc);
-- 
2.12.2


  parent reply	other threads:[~2017-04-28  9:31 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-28  9:31 [PATCH 0/8] GCOV improvements marxin
2017-04-28  9:31 ` [PATCH 6/8] Fix format_gcov to not print misleading values (PR gcov-profile/53915) marxin
2017-04-28 11:38   ` Nathan Sidwell
2017-04-28  9:31 ` [PATCH 1/8] gcno file: do not stream block flags (PR gcov-profile/80031) marxin
2017-04-28 11:48   ` Nathan Sidwell
2017-04-28  9:31 ` marxin [this message]
2017-04-28 11:41   ` [PATCH 4/8] Introduce new option -w which shows verbose informations Nathan Sidwell
2017-04-28  9:31 ` [PATCH 5/8] Make gcno more precise about BBs really belonging to a line (PR gcov-profile/79891) marxin
2017-04-28 11:47   ` Nathan Sidwell
2017-04-28 13:06     ` Martin Liška
2017-04-28  9:31 ` [PATCH 2/8] Remove .gcno file when compilation does not success (PR driver/56469) marxin
2017-04-28 12:00   ` Nathan Sidwell
2017-04-28 10:58 ` [PATCH 7/8] Sort options of gcov, gcov-dump and gcov-tool both in --help and documentation marxin
2017-04-28 11:32   ` Nathan Sidwell
2017-04-28 11:25 ` [PATCH 8/8] Enhance documentation of gcov marxin
2017-04-28 11:35   ` Nathan Sidwell
2017-04-29  3:20   ` Martin Sebor
2018-07-22  8:40     ` Gerald Pfeifer
2017-04-28 11:26 ` [PATCH 3/8] Simplify representation of locations of a block marxin
2017-04-28 11:57   ` Nathan Sidwell
2017-04-28 16:40     ` Martin Sebor
2017-04-28 17:48       ` Nathan Sidwell
2017-05-02 15:38         ` [PATCH] Fix documentation and a ctor in gcov.c Martin Liška
2017-05-03 13:20           ` Nathan Sidwell
2017-04-28 19:13       ` [PATCH 3/8] Simplify representation of locations of a block Pedro Alves
2017-04-28 19:46         ` Martin Sebor
2017-04-28 20:07         ` Pedro Alves
2017-04-28 12:03 ` [PATCH 0/8] GCOV improvements Nathan Sidwell
2017-04-28 12:16   ` Martin Liška
2017-04-29 16:31     ` Gerald Pfeifer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9d9bfc7d95539ba96a86d7f94b9b828b60729810.1493371589.git.mliska@suse.cz \
    --to=mliska@suse.cz \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=hubicka@ucw.cz \
    --cc=nathan@acm.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).