comparison gcc/gcov.c @ 55:77e2b8dfacca gcc-4.4.5

update it from 4.4.3 to 4.5.0
author ryoma <e075725@ie.u-ryukyu.ac.jp>
date Fri, 12 Feb 2010 23:39:51 +0900
parents 3bfb6c00c1e0
children b7f97abdc517
comparison
equal deleted inserted replaced
52:c156f1bd5cd9 55:77e2b8dfacca
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
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
424 424
425 static void 425 static void
426 print_version (void) 426 print_version (void)
427 { 427 {
428 fnotice (stdout, "gcov %s%s\n", pkgversion_string, version_string); 428 fnotice (stdout, "gcov %s%s\n", pkgversion_string, version_string);
429 fprintf (stdout, "Copyright %s 2010 Free Software Foundation, Inc.\n", 429 fprintf (stdout, "Copyright %s 2009 Free Software Foundation, Inc.\n",
430 _("(C)")); 430 _("(C)"));
431 fnotice (stdout, 431 fnotice (stdout,
432 _("This is free software; see the source for copying conditions.\n" 432 _("This is free software; see the source for copying conditions.\n"
433 "There is NO warranty; not even for MERCHANTABILITY or \n" 433 "There is NO warranty; not even for MERCHANTABILITY or \n"
434 "FITNESS FOR A PARTICULAR PURPOSE.\n\n")); 434 "FITNESS FOR A PARTICULAR PURPOSE.\n\n"));
682 cptr = strrchr (name, '.'); 682 cptr = strrchr (name, '.');
683 if (cptr) 683 if (cptr)
684 *cptr = 0; 684 *cptr = 0;
685 685
686 length = strlen (name); 686 length = strlen (name);
687 687
688 bbg_file_name = XNEWVEC (char, length + strlen (GCOV_NOTE_SUFFIX) + 1); 688 bbg_file_name = XNEWVEC (char, length + strlen (GCOV_NOTE_SUFFIX) + 1);
689 strcpy (bbg_file_name, name); 689 strcpy (bbg_file_name, name);
690 strcpy (bbg_file_name + length, GCOV_NOTE_SUFFIX); 690 strcpy (bbg_file_name + length, GCOV_NOTE_SUFFIX);
691 691
692 da_file_name = XNEWVEC (char, length + strlen (GCOV_DATA_SUFFIX) + 1); 692 da_file_name = XNEWVEC (char, length + strlen (GCOV_DATA_SUFFIX) + 1);
719 src->name = xstrdup (file_name); 719 src->name = xstrdup (file_name);
720 src->coverage.name = src->name; 720 src->coverage.name = src->name;
721 src->index = source_index++; 721 src->index = source_index++;
722 src->next = sources; 722 src->next = sources;
723 sources = src; 723 sources = src;
724 724
725 if (!stat (file_name, &status)) 725 if (!stat (file_name, &status))
726 src->file_time = status.st_mtime; 726 src->file_time = status.st_mtime;
727 } 727 }
728 728
729 if (src->file_time > bbg_file_time) 729 if (src->file_time > bbg_file_time)
1041 { 1041 {
1042 char v[4], e[4]; 1042 char v[4], e[4];
1043 1043
1044 GCOV_UNSIGNED2STRING (v, version); 1044 GCOV_UNSIGNED2STRING (v, version);
1045 GCOV_UNSIGNED2STRING (e, GCOV_VERSION); 1045 GCOV_UNSIGNED2STRING (e, GCOV_VERSION);
1046 1046
1047 fnotice (stderr, "%s:version '%.4s', prefer version '%.4s'\n", 1047 fnotice (stderr, "%s:version '%.4s', prefer version '%.4s'\n",
1048 da_file_name, v, e); 1048 da_file_name, v, e);
1049 } 1049 }
1050 tag = gcov_read_unsigned (); 1050 tag = gcov_read_unsigned ();
1051 if (tag != bbg_stamp) 1051 if (tag != bbg_stamp)
1063 gcov_read_summary (&object_summary); 1063 gcov_read_summary (&object_summary);
1064 else if (tag == GCOV_TAG_PROGRAM_SUMMARY) 1064 else if (tag == GCOV_TAG_PROGRAM_SUMMARY)
1065 program_count++; 1065 program_count++;
1066 else if (tag == GCOV_TAG_FUNCTION) 1066 else if (tag == GCOV_TAG_FUNCTION)
1067 { 1067 {
1068 unsigned ident = gcov_read_unsigned (); 1068 {
1069 struct function_info *fn_n = functions; 1069 unsigned ident = gcov_read_unsigned ();
1070 1070 struct function_info *fn_n = functions;
1071 /* Try to find the function in the list. 1071
1072 To speed up the search, first start from the last function 1072 /* Try to find the function in the list.
1073 found. */ 1073 To speed up the search, first start from the last function
1074 for (fn = fn ? fn->next : NULL; ; fn = fn->next) 1074 found. */
1075 { 1075 for (fn = fn ? fn->next : NULL; ; fn = fn->next)
1076 if (fn) 1076 {
1077 ; 1077 if (fn)
1078 else if ((fn = fn_n)) 1078 ;
1079 fn_n = NULL; 1079 else if ((fn = fn_n))
1080 else 1080 fn_n = NULL;
1081 { 1081 else
1082 fnotice (stderr, "%s:unknown function '%u'\n", 1082 {
1083 da_file_name, ident); 1083 fnotice (stderr, "%s:unknown function '%u'\n",
1084 da_file_name, ident);
1085 break;
1086 }
1087 if (fn->ident == ident)
1084 break; 1088 break;
1085 } 1089 }
1086 if (fn->ident == ident) 1090 }
1087 break;
1088 }
1089 1091
1090 if (!fn) 1092 if (!fn)
1091 ; 1093 ;
1092 else if (gcov_read_unsigned () != fn->checksum) 1094 else if (gcov_read_unsigned () != fn->checksum)
1093 { 1095 {
1892 { 1894 {
1893 for (; fn && fn->line == line_num; fn = fn->line_next) 1895 for (; fn && fn->line == line_num; fn = fn->line_next)
1894 { 1896 {
1895 arc_t *arc = fn->blocks[fn->num_blocks - 1].pred; 1897 arc_t *arc = fn->blocks[fn->num_blocks - 1].pred;
1896 gcov_type return_count = fn->blocks[fn->num_blocks - 1].count; 1898 gcov_type return_count = fn->blocks[fn->num_blocks - 1].count;
1897 1899
1898 for (; arc; arc = arc->pred_next) 1900 for (; arc; arc = arc->pred_next)
1899 if (arc->fake) 1901 if (arc->fake)
1900 return_count -= arc->count; 1902 return_count -= arc->count;
1901 1903
1902 fprintf (gcov_file, "function %s", fn->name); 1904 fprintf (gcov_file, "function %s", fn->name);
1903 fprintf (gcov_file, " called %s", 1905 fprintf (gcov_file, " called %s",
1904 format_gcov (fn->blocks[0].count, 0, -1)); 1906 format_gcov (fn->blocks[0].count, 0, -1));
1905 fprintf (gcov_file, " returned %s", 1907 fprintf (gcov_file, " returned %s",
1906 format_gcov (return_count, fn->blocks[0].count, 0)); 1908 format_gcov (return_count, fn->blocks[0].count, 0));