From f5d39c3d74dc91f2faf190114251226cc1f8b433 Mon Sep 17 00:00:00 2001 From: Nathan Sidwell Date: Mon, 21 Mar 2005 12:31:10 +0000 Subject: [PATCH] re PR other/20564 (gcov default behaviour changed) PR other/20564 * gcov.c (output_lines): Only output function block summary when outputting branch information. * doc/gcov.texi: Document format of preamble and additional block information lines. From-SVN: r96788 --- gcc/ChangeLog | 10 +++++++++- gcc/doc/gcov.texi | 32 ++++++++++++++++++++++++++------ gcc/gcov.c | 9 ++++++--- 3 files changed, 41 insertions(+), 10 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2fc3d9404b7..2e947eaed20 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2005-03-21 Nathan Sidwell + + PR other/20564 + * gcov.c (output_lines): Only output function block summary when + outputting branch information. + * doc/gcov.texi: Document format of preamble and additional block + information lines. + 2005-03-21 Richard Sandiford * libgcc2.h (LIBGCC2_HAS_SF_MODE): New macro. @@ -240,7 +248,6 @@ scale_bbs_frequencies_int. * tree-ssa-loop-ch.c (copy_loop_headers): Fix profiling info. ->>>>>>> 2.7929 2005-03-18 Kazu Hirata * config/m32r/m32r-protos.h: Remove the prototypes for @@ -488,6 +495,7 @@ (arc_rodata_string, TARGET_OPTIONS): Delete. * config/arc/arc.opt: New file. +>>>>>>> 2.7930 2005-03-17 Richard Henderson * doc/extend.texi (Weak Pragmas): New section. diff --git a/gcc/doc/gcov.texi b/gcc/doc/gcov.texi index 3278a4b5a97..bfe4a3d204e 100644 --- a/gcc/doc/gcov.texi +++ b/gcc/doc/gcov.texi @@ -207,7 +207,7 @@ option is not supplied, it defaults to the current directory. @item -u @itemx --unconditional-branches -When branch counts are given, include those of unconditional branches. +When branch probabilities are given, include those of unconditional branches. Unconditional branches are normally not interesting. @end table @@ -232,9 +232,27 @@ program source code. The format is Additional block information may succeed each line, when requested by command line option. The @var{execution_count} is @samp{-} for lines -containing no code and @samp{#####} for lines which were never -executed. Some lines of information at the start have @var{line_number} -of zero. +containing no code and @samp{#####} for lines which were never executed. +Some lines of information at the start have @var{line_number} of zero. + +The preamble lines are of the form + +@smallexample +-:0:@var{tag}:@var{value} +@end smallexample + +The ordering and number of these preamble lines will be augmented as +@command{gcov} development progresses --- do not rely on them remaining +unchanged. Use @var{tag} to locate a particular preamble line. + +The additional block information is of the form + +@smallexample +@var{tag} @var{information} +@end smallexample + +The @var{information} is human readable, but designed to be simple +enough for machine parsing too. When printing percentages, 0% and 100% are only printed when the values are @emph{exactly} 0% and 100% respectively. Other values which would @@ -278,7 +296,6 @@ Here is a sample: -: 1:#include -: 2: -: 3:int main (void) -function main called 1 returned 1 blocks executed 75% 1: 4:@{ 1: 5: int i, total; -: 6: @@ -307,7 +324,6 @@ counts, and the output looks like this: -: 1:#include -: 2: -: 3:int main (void) -function main called 1 returned 1 blocks executed 75% 1: 4:@{ 1: 4-block 0 1: 5: int i, total; @@ -390,6 +406,10 @@ call 0 called 1 returned 100% -: 17:@} @end smallexample +For each function, a line is printed showing how many times the function +is called, how many times it returns and what percentage of the +function's blocks were executed. + For each basic block, a line is printed after the last line of the basic block describing the branch or call that ends the basic block. There can be multiple branches and calls listed for a single source line if there diff --git a/gcc/gcov.c b/gcc/gcov.c index ee4d6b9aa80..6675a06b60e 100644 --- a/gcc/gcov.c +++ b/gcc/gcov.c @@ -1774,7 +1774,7 @@ output_lines (FILE *gcov_file, const source_t *src) const line_t *line; /* current line info ptr. */ char string[STRING_SIZE]; /* line buffer. */ char const *retval = ""; /* status of source file reading. */ - function_t *fn = src->functions; + function_t *fn = NULL; fprintf (gcov_file, "%9s:%5d:Source:%s\n", "-", 0, src->name); fprintf (gcov_file, "%9s:%5d:Graph:%s\n", "-", 0, bbg_file_name); @@ -1803,6 +1803,9 @@ output_lines (FILE *gcov_file, const source_t *src) } } + if (flag_branches) + fn = src->functions; + for (line_num = 1, line = &src->lines[line_num]; line_num < src->num_lines; line_num++, line++) { @@ -1810,11 +1813,11 @@ output_lines (FILE *gcov_file, const source_t *src) { arc_t *arc = fn->blocks[fn->num_blocks - 1].pred; gcov_type return_count = fn->blocks[fn->num_blocks - 1].count; - + for (; arc; arc = arc->pred_next) if (arc->fake) return_count -= arc->count; - + fprintf (gcov_file, "function %s", fn->name); fprintf (gcov_file, " called %s", format_gcov (fn->blocks[0].count, 0, -1)); -- 2.30.2