comparison gcc/gcov.c @ 67:f6334be47118

update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
author nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
date Tue, 22 Mar 2011 17:18:12 +0900
parents b7f97abdc517
children 04ced10e8804
comparison
equal deleted inserted replaced
65:65488c3d617d 67:f6334be47118
1 /* Gcov.c: prepend line execution counts and branch probabilities to a 1 /* Gcov.c: prepend line execution counts and branch probabilities to a
2 source file. 2 source file.
3 Copyright (C) 1990, 1991, 1992, 1993, 1994, 1996, 1997, 1998, 1999, 3 Copyright (C) 1990, 1991, 1992, 1993, 1994, 1996, 1997, 1998, 1999,
4 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 4 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
5 Free Software Foundation, Inc. 5 Free Software Foundation, Inc.
6 Contributed by James E. Wilson of Cygnus Support. 6 Contributed by James E. Wilson of Cygnus Support.
7 Mangled by Bob Manson of Cygnus Support. 7 Mangled by Bob Manson of Cygnus Support.
8 Mangled further by Nathan Sidwell <nathan@codesourcery.com> 8 Mangled further by Nathan Sidwell <nathan@codesourcery.com>
9 9
294 294
295 /* Output a gcov file if this is true. This is on by default, and can 295 /* Output a gcov file if this is true. This is on by default, and can
296 be turned off by the -n option. */ 296 be turned off by the -n option. */
297 297
298 static int flag_gcov_file = 1; 298 static int flag_gcov_file = 1;
299
300 /* Output progress indication if this is true. This is off by default
301 and can be turned on by the -d option. */
302
303 static int flag_display_progress = 0;
299 304
300 /* For included files, make the gcov output file name include the name 305 /* For included files, make the gcov output file name include the name
301 of the input source file. For example, if x.h is included in a.c, 306 of the input source file. For example, if x.h is included in a.c,
302 then the output file name is a.c##x.h.gcov instead of x.h.gcov. */ 307 then the output file name is a.c##x.h.gcov instead of x.h.gcov. */
303 308
353 358
354 int 359 int
355 main (int argc, char **argv) 360 main (int argc, char **argv)
356 { 361 {
357 int argno; 362 int argno;
363 int first_arg;
358 364
359 /* Unlock the stdio streams. */ 365 /* Unlock the stdio streams. */
360 unlock_std_streams (); 366 unlock_std_streams ();
361 367
362 gcc_init_libintl (); 368 gcc_init_libintl ();
369 print_usage (true); 375 print_usage (true);
370 376
371 if (argc - argno > 1) 377 if (argc - argno > 1)
372 multiple_files = 1; 378 multiple_files = 1;
373 379
380 first_arg = argno;
381
374 for (; argno != argc; argno++) 382 for (; argno != argc; argno++)
375 process_file (argv[argno]); 383 {
384 if (flag_display_progress)
385 printf("Processing file %d out of %d\n",
386 argno - first_arg + 1, argc - first_arg);
387 process_file (argv[argno]);
388 }
376 389
377 generate_results (multiple_files ? NULL : argv[argc - 1]); 390 generate_results (multiple_files ? NULL : argv[argc - 1]);
378 391
379 release_structures (); 392 release_structures ();
380 393
413 source files\n"); 426 source files\n");
414 fnotice (file, " -f, --function-summaries Output summaries for each function\n"); 427 fnotice (file, " -f, --function-summaries Output summaries for each function\n");
415 fnotice (file, " -o, --object-directory DIR|FILE Search for object files in DIR or called FILE\n"); 428 fnotice (file, " -o, --object-directory DIR|FILE Search for object files in DIR or called FILE\n");
416 fnotice (file, " -p, --preserve-paths Preserve all pathname components\n"); 429 fnotice (file, " -p, --preserve-paths Preserve all pathname components\n");
417 fnotice (file, " -u, --unconditional-branches Show unconditional branch counts too\n"); 430 fnotice (file, " -u, --unconditional-branches Show unconditional branch counts too\n");
431 fnotice (file, " -d, --display-progress Display progress information\n");
418 fnotice (file, "\nFor bug reporting instructions, please see:\n%s.\n", 432 fnotice (file, "\nFor bug reporting instructions, please see:\n%s.\n",
419 bug_report_url); 433 bug_report_url);
420 exit (status); 434 exit (status);
421 } 435 }
422 436
424 438
425 static void 439 static void
426 print_version (void) 440 print_version (void)
427 { 441 {
428 fnotice (stdout, "gcov %s%s\n", pkgversion_string, version_string); 442 fnotice (stdout, "gcov %s%s\n", pkgversion_string, version_string);
429 fprintf (stdout, "Copyright %s 2010 Free Software Foundation, Inc.\n", 443 fprintf (stdout, "Copyright %s 2011 Free Software Foundation, Inc.\n",
430 _("(C)")); 444 _("(C)"));
431 fnotice (stdout, 445 fnotice (stdout,
432 _("This is free software; see the source for copying conditions.\n" 446 _("This is free software; see the source for copying conditions.\n"
433 "There is NO warranty; not even for MERCHANTABILITY or \n" 447 "There is NO warranty; not even for MERCHANTABILITY or \n"
434 "FITNESS FOR A PARTICULAR PURPOSE.\n\n")); 448 "FITNESS FOR A PARTICULAR PURPOSE.\n\n"));
447 { "function-summaries", no_argument, NULL, 'f' }, 461 { "function-summaries", no_argument, NULL, 'f' },
448 { "preserve-paths", no_argument, NULL, 'p' }, 462 { "preserve-paths", no_argument, NULL, 'p' },
449 { "object-directory", required_argument, NULL, 'o' }, 463 { "object-directory", required_argument, NULL, 'o' },
450 { "object-file", required_argument, NULL, 'o' }, 464 { "object-file", required_argument, NULL, 'o' },
451 { "unconditional-branches", no_argument, NULL, 'u' }, 465 { "unconditional-branches", no_argument, NULL, 'u' },
466 { "display-progress", no_argument, NULL, 'd' },
452 { 0, 0, 0, 0 } 467 { 0, 0, 0, 0 }
453 }; 468 };
454 469
455 /* Process args, return index to first non-arg. */ 470 /* Process args, return index to first non-arg. */
456 471
457 static int 472 static int
458 process_args (int argc, char **argv) 473 process_args (int argc, char **argv)
459 { 474 {
460 int opt; 475 int opt;
461 476
462 while ((opt = getopt_long (argc, argv, "abcfhlno:puv", options, NULL)) != -1) 477 while ((opt = getopt_long (argc, argv, "abcdfhlno:puv", options, NULL)) != -1)
463 { 478 {
464 switch (opt) 479 switch (opt)
465 { 480 {
466 case 'a': 481 case 'a':
467 flag_all_blocks = 1; 482 flag_all_blocks = 1;
491 flag_preserve_paths = 1; 506 flag_preserve_paths = 1;
492 break; 507 break;
493 case 'u': 508 case 'u':
494 flag_unconditional = 1; 509 flag_unconditional = 1;
495 break; 510 break;
511 case 'd':
512 flag_display_progress = 1;
513 break;
496 case 'v': 514 case 'v':
497 print_version (); 515 print_version ();
498 /* print_version will exit. */ 516 /* print_version will exit. */
499 default: 517 default:
500 print_usage (true); 518 print_usage (true);