This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] gcov: display progress indication



Hello,


this patch adds the support for the command line flag '-d' (and the expanded version '--display-progress') in the gcov command line. When present, this flag causes gcov to display its progression, writing one message of the form

"Processing file n out of N"

for each file.

This is useful when processing a big number of files in one call. This is also useful for high-level tools (for examples IDEs) which hide the actual call to gcov and would like to display a progress bar to the user.

This was tested on x86-linux.

Nicolas



2008-12-18 Nicolas Setton <setton@adacore.com>

	* gcov.c (main): Display progress indication when the flag '-d'
	(or the equivalent '--display-progress') is passed on the command
	line. Document this in the usage information.
	* gcov.texi: Document.

*** gcc/gcov.c.original	Fri Dec 19 12:39:30 2008
--- gcc/gcov.c	Fri Dec 19 12:40:39 2008
*************** static int flag_unconditional = 0;
*** 297,302 ****
--- 297,307 ----

static int flag_gcov_file = 1;

+ /* Output progress indication if this is true. This is off by default
+ and can be turned on by the -d option. */
+
+ static int flag_display_progress = 0;
+
/* For included files, make the gcov output file name include the name
of the input source file. For example, if x.h is included in a.c,
then the output file name is a.c##x.h.gcov instead of x.h.gcov. */
*************** int
*** 355,360 ****
--- 360,366 ----
main (int argc, char **argv)
{
int argno;
+ int first_arg;


    /* Unlock the stdio streams.  */
    unlock_std_streams ();
*************** main (int argc, char **argv)
*** 371,378 ****
    if (argc - argno > 1)
      multiple_files = 1;

    for (; argno != argc; argno++)
!     process_file (argv[argno]);

generate_results (multiple_files ? NULL : argv[argc - 1]);

--- 377,391 ----
    if (argc - argno > 1)
      multiple_files = 1;

+   first_arg = argno;
+
    for (; argno != argc; argno++)
!     {
!       if (flag_display_progress)
!         printf("Processing file %d out of %d\n",
!                argno - first_arg + 1, argc - first_arg);
!       process_file (argv[argno]);
!     }

generate_results (multiple_files ? NULL : argv[argc - 1]);

*************** print_usage (int error_p)
*** 415,420 ****
--- 428,434 ----
fnotice (file, " -o, --object-directory DIR|FILE Search for object files in DIR or called FILE\n");
fnotice (file, " -p, --preserve-paths Preserve all pathname components\n");
fnotice (file, " -u, --unconditional-branches Show unconditional branch counts too\n");
+ fnotice (file, " -d, --display-progress Display progress information\n");
fnotice (file, "\nFor bug reporting instructions, please see:\n%s. \n",
bug_report_url);
exit (status);
*************** static const struct option options[] =
*** 449,454 ****
--- 463,469 ----
{ "object-directory", required_argument, NULL, 'o' },
{ "object-file", required_argument, NULL, 'o' },
{ "unconditional-branches", no_argument, NULL, 'u' },
+ { "display-progress", no_argument, NULL, 'd' },
{ 0, 0, 0, 0 }
};


*************** process_args (int argc, char **argv)
*** 459,465 ****
  {
    int opt;

! while ((opt = getopt_long (argc, argv, "abcfhlno:puv", options, NULL)) != -1)
{
switch (opt)
{
--- 474,480 ----
{
int opt;


! while ((opt = getopt_long (argc, argv, "abcdfhlno:puv", options, NULL)) != -1)
{
switch (opt)
{
*************** process_args (int argc, char **argv)
*** 493,498 ****
--- 508,516 ----
case 'u':
flag_unconditional = 1;
break;
+ case 'd':
+ flag_display_progress = 1;
+ break;
case 'v':
print_version ();
/* print_version will exit. */
*** gcc/doc/gcov.texi.original Fri Dec 19 15:38:11 2008
--- gcc/doc/gcov.texi Fri Dec 19 15:40:32 2008
*************** gcov [@option{-v}|@option{--version}] [@
*** 130,135 ****
--- 130,136 ----
[@option{-f}|@option{--function-summaries}]
[@option{-o}|@option{--object-directory} @var{directory|file}] @var{sourcefiles}
[@option{-u}|@option{--unconditional-branches}]
+ [@option{-d}|@option{--display-progress}]
@c man end
@c man begin SEEALSO
gpl(7), gfdl(7), fsf-funding(7), gcc(1) and the Info entry for @file{gcc}.
*************** option is not supplied, it defaults to t
*** 211,216 ****
--- 212,221 ----
When branch probabilities are given, include those of unconditional branches.
Unconditional branches are normally not interesting.


+ @item -d
+ @itemx --display-progress
+ Display the progress on the standard output.
+
  @end table

@command{gcov} should be run with the current directory the same as that


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]