From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26370 invoked by alias); 28 Apr 2017 09:31:42 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 26180 invoked by uid 89); 28 Apr 2017 09:31:41 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.2 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_SOFTFAIL autolearn=ham version=3.3.2 spammy=6966, 7287, HX-detected-operating-system:timestamps, 8109 X-HELO: eggs.gnu.org Received: from eggs.gnu.org (HELO eggs.gnu.org) (208.118.235.92) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 28 Apr 2017 09:31:38 +0000 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d42FU-0002fW-AD for gcc-patches@gcc.gnu.org; Fri, 28 Apr 2017 05:31:39 -0400 Received: from mx2.suse.de ([195.135.220.15]:44975 helo=mx1.suse.de) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d42FT-0002eX-W7 for gcc-patches@gcc.gnu.org; Fri, 28 Apr 2017 05:31:36 -0400 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 7AFA2AC65 for ; Fri, 28 Apr 2017 09:31:33 +0000 (UTC) Resent-From: =?UTF-8?Q?Martin_Li=c5=a1ka?= Resent-To: GCC Patches Resent-Date: Fri, 28 Apr 2017 11:31:32 +0200 Resent-Message-ID: Resent-User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 Message-Id: <9d9bfc7d95539ba96a86d7f94b9b828b60729810.1493371589.git.mliska@suse.cz> In-Reply-To: References: From: marxin Date: Fri, 28 Apr 2017 09:31:00 -0000 Subject: [PATCH 4/8] Introduce new option -w which shows verbose informations. To: gcc-patches@gcc.gnu.org Cc: hubicka@ucw.cz, nathan@acm.org X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy] X-Received-From: 195.135.220.15 X-IsSubscribed: yes X-SW-Source: 2017-04/txt/msg01461.txt.bz2 gcc/ChangeLog: 2017-04-26 Martin Liska * 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