diff --git a/gprof/ChangeLog-2009 b/gprof/ChangeLog-2009 index e1e7bd4351..2661719b41 100644 --- a/gprof/ChangeLog-2009 +++ b/gprof/ChangeLog-2009 @@ -177,7 +177,7 @@ 2009-02-12 Ken Werner - * corefile.c (core_create_function_syms): Remove "" and + * corefile.c (core_create_function_syms): Remove "" and "" sentinels. * gprof.c: Likewise. * cg_print.c (cg_print_function_ordering): Likewise. diff --git a/gprof/Makefile.am b/gprof/Makefile.am index 71a90f7f94..0ab85c0f38 100644 --- a/gprof/Makefile.am +++ b/gprof/Makefile.am @@ -6,12 +6,12 @@ # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. -# +# # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -# +# # You should have received a copy of the GNU General Public License # along with this program; see the file COPYING3. If not see # . diff --git a/gprof/Makefile.in b/gprof/Makefile.in index 1a26c0e7f5..bbee5285c9 100644 --- a/gprof/Makefile.in +++ b/gprof/Makefile.in @@ -22,12 +22,12 @@ # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. -# +# # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -# +# # You should have received a copy of the GNU General Public License # along with this program; see the file COPYING3. If not see # . diff --git a/gprof/README b/gprof/README index 3f2b45f41b..accd0d9709 100644 --- a/gprof/README +++ b/gprof/README @@ -1,7 +1,7 @@ README for GPROF -This is the GNU profiler. It is distributed with other "binary -utilities" which should be in ../binutils. See ../binutils/README for +This is the GNU profiler. It is distributed with other "binary +utilities" which should be in ../binutils. See ../binutils/README for more general notes, including where to send bug reports. This file documents the changes and new features available with this @@ -118,7 +118,7 @@ Here are some examples: dots. In such cases, it is necessary to add a leading colon to the name. For example, ":.mul" selects function ".mul". - + main.c:main Selects function "main" in file "main.c". main.c:134 Selects line 134 in file "main.c". @@ -195,7 +195,7 @@ Short Form: Long Form: option is specified multiple times, the flat profile includes symbols selected by the union of all symspecs. - + -P[symspec] --no-flat-profile[=symspec] Suppress output in the flat profile. If given without an argument, the flat profile is suppressed diff --git a/gprof/basic_blocks.c b/gprof/basic_blocks.c index 8f77437b65..d508867461 100644 --- a/gprof/basic_blocks.c +++ b/gprof/basic_blocks.c @@ -282,7 +282,7 @@ print_exec_counts () for (i = 0; i < len; ++i) { sym = sorted_bbs [i]; - + if (sym->ncalls > 0 || ! ignore_zeros) { /* FIXME: This only works if bfd_vma is unsigned long. */ diff --git a/gprof/configure.ac b/gprof/configure.ac index 01a0887163..7a4dbc75e9 100644 --- a/gprof/configure.ac +++ b/gprof/configure.ac @@ -6,12 +6,12 @@ dnl This file is free software; you can redistribute it and/or modify dnl it under the terms of the GNU General Public License as published by dnl the Free Software Foundation; either version 3 of the License, or dnl (at your option) any later version. -dnl +dnl dnl This program is distributed in the hope that it will be useful, dnl but WITHOUT ANY WARRANTY; without even the implied warranty of dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the dnl GNU General Public License for more details. -dnl +dnl dnl You should have received a copy of the GNU General Public License dnl along with this program; see the file COPYING3. If not see dnl . diff --git a/gprof/flat_bl.m b/gprof/flat_bl.m index 678b92a8b8..1e5f220c82 100644 --- a/gprof/flat_bl.m +++ b/gprof/flat_bl.m @@ -11,13 +11,13 @@ seconds function alone. This is the major sort for this calls the number of times this function was invoked, if this function is profiled, else blank. - + self the average number of milliseconds spent in this ms/call function per call, if this function is profiled, else blank. total the average number of milliseconds spent in this -ms/call function and its descendents per call, if this +ms/call function and its descendents per call, if this function is profiled, else blank. name the name of the function. This is the minor sort diff --git a/gprof/gmon.h b/gprof/gmon.h index be670ffc44..762f97030d 100644 --- a/gprof/gmon.h +++ b/gprof/gmon.h @@ -53,11 +53,11 @@ #define GMONVERSION 0x00051879 /* Size of the old BSD gmon header */ -#define GMON_HDRSIZE_OLDBSD_32 (4 + 4 + 4) +#define GMON_HDRSIZE_OLDBSD_32 (4 + 4 + 4) /* FIXME: Checking host compiler defines here means that we can't use a cross gprof alpha OSF. */ -#if defined(__alpha__) && defined (__osf__) +#if defined(__alpha__) && defined (__osf__) #define GMON_HDRSIZE_OLDBSD_64 (8 + 8 + 4 + 4) #else #define GMON_HDRSIZE_OLDBSD_64 (8 + 8 + 4) diff --git a/gprof/gmon_io.c b/gprof/gmon_io.c index 5148275586..ac9f7afb42 100644 --- a/gprof/gmon_io.c +++ b/gprof/gmon_io.c @@ -499,7 +499,7 @@ gmon_out_read (const char *filename) hist_scale = (double)((tmp.high_pc - tmp.low_pc) / sizeof (UNIT)) / hist_num_bins; histograms->sample = (int *) xmalloc (hist_num_bins * sizeof (int)); - memset (histograms->sample, 0, + memset (histograms->sample, 0, hist_num_bins * sizeof (int)); } @@ -532,7 +532,7 @@ gmon_out_read (const char *filename) done (1); } - histograms->sample[i] + histograms->sample[i] += bfd_get_16 (core_bfd, (bfd_byte *) raw_bin_count); } @@ -671,7 +671,7 @@ gmon_out_write (const char *filename) case ptr_64bit: hdrsize = GMON_HDRSIZE_OLDBSD_64; /* FIXME: Checking host compiler defines here means that we can't - use a cross gprof alpha OSF. */ + use a cross gprof alpha OSF. */ #if defined(__alpha__) && defined (__osf__) padsize = 4; #endif @@ -683,7 +683,7 @@ gmon_out_write (const char *filename) old BSD and 4.4BSD formats. */ if (gmon_io_write_vma (ofp, histograms->lowpc) || gmon_io_write_vma (ofp, histograms->highpc) - || gmon_io_write_32 (ofp, histograms->num_bins + || gmon_io_write_32 (ofp, histograms->num_bins * sizeof (UNIT) + hdrsize)) { perror (filename); diff --git a/gprof/gprof.c b/gprof/gprof.c index 6415c30d6a..4df99751a3 100644 --- a/gprof/gprof.c +++ b/gprof/gprof.c @@ -612,7 +612,7 @@ This program is free software. This program has absolutely no warranty.\n")); if (output_style & STYLE_FLAT_PROFILE) { /* Print the flat profile. */ - hist_print (); + hist_print (); } if (cg && (output_style & STYLE_CALL_GRAPH)) @@ -620,20 +620,20 @@ This program is free software. This program has absolutely no warranty.\n")); if (!bsd_style_output) { /* Print the dynamic profile. */ - cg_print (cg); + cg_print (cg); } cg_print_index (); } if (output_style & STYLE_EXEC_COUNTS) print_exec_counts (); - + if (output_style & STYLE_ANNOTATED_SOURCE) print_annotated_source (); - + if (output_style & STYLE_FUNCTION_ORDER) cg_print_function_ordering (); - + if (output_style & STYLE_FILE_ORDER) cg_print_file_ordering (); diff --git a/gprof/gprof.texi b/gprof/gprof.texi index e2939f7021..3056f4a86b 100644 --- a/gprof/gprof.texi +++ b/gprof/gprof.texi @@ -38,7 +38,7 @@ section entitled ``GNU Free Documentation License''. @titlepage @title GNU gprof -@subtitle The @sc{gnu} Profiler +@subtitle The @sc{gnu} Profiler @ifset VERSION_PACKAGE @subtitle @value{VERSION_PACKAGE} @end ifset @@ -110,14 +110,14 @@ in the section entitled ``GNU Free Documentation License''. @smallexample @c man begin SYNOPSIS -gprof [ -[abcDhilLrsTvwxyz] ] [ -[ACeEfFJnNOpPqQZ][@var{name}] ] +gprof [ -[abcDhilLrsTvwxyz] ] [ -[ACeEfFJnNOpPqQZ][@var{name}] ] [ -I @var{dirs} ] [ -d[@var{num}] ] [ -k @var{from/to} ] [ -m @var{min-count} ] [ -R @var{map_file} ] [ -t @var{table-length} ] - [ --[no-]annotated-source[=@var{name}] ] + [ --[no-]annotated-source[=@var{name}] ] [ --[no-]exec-counts[=@var{name}] ] [ --[no-]flat-profile[=@var{name}] ] [ --[no-]graph[=@var{name}] ] - [ --[no-]time=@var{name}] [ --all-lines ] [ --brief ] - [ --debug[=@var{level}] ] [ --function-ordering ] + [ --[no-]time=@var{name}] [ --all-lines ] [ --brief ] + [ --debug[=@var{level}] ] [ --function-ordering ] [ --file-ordering @var{map_file} ] [ --directory-path=@var{dirs} ] [ --display-unused-functions ] [ --file-format=@var{name} ] [ --file-info ] [ --help ] [ --line ] [ --inline-file-names ] @@ -132,14 +132,14 @@ gprof [ -[abcDhilLrsTvwxyz] ] [ -[ACeEfFJnNOpPqQZ][@var{name}] ] @end smallexample @c man begin DESCRIPTION -@code{gprof} produces an execution profile of C, Pascal, or Fortran77 -programs. The effect of called routines is incorporated in the profile +@code{gprof} produces an execution profile of C, Pascal, or Fortran77 +programs. The effect of called routines is incorporated in the profile of each caller. The profile data is taken from the call graph profile file (@file{gmon.out} default) which is created by programs that are compiled with the @samp{-pg} option of @code{cc}, @code{pc}, and @code{f77}. The @samp{-pg} option also links in versions of the library routines -that are compiled for profiling. @code{Gprof} reads the given object +that are compiled for profiling. @code{Gprof} reads the given object file (the default is @code{a.out}) and establishes the relation between its symbol table and the call graph profile from @file{gmon.out}. If more than one profile file is specified, the @code{gprof} @@ -184,7 +184,7 @@ the namelist and text space. @item @file{gmon.out} dynamic call graph and profile. @item @file{gmon.sum} -summarized dynamic call graph and profile. +summarized dynamic call graph and profile. @end table @c man end @@ -303,8 +303,8 @@ graph data you will still be able to see the time samples: Flat profile: Each sample counts as 0.01 seconds. - % cumulative self self total - time seconds seconds calls Ts/call Ts/call name + % cumulative self self total + time seconds seconds calls Ts/call Ts/call name 44.12 0.07 0.07 zazLoop 35.29 0.14 0.06 main 20.59 0.17 0.04 bazMillion @@ -644,9 +644,9 @@ first line. This behavior is similar to @code{tcov}'s @samp{-a}. @itemx --no-demangle These options control whether C++ symbol names should be demangled when printing output. The default is to demangle symbols. The -@code{--no-demangle} option may be used to turn off demangling. Different -compilers have different mangling styles. The optional demangling style -argument can be used to choose an appropriate demangling style for your +@code{--no-demangle} option may be used to turn off demangling. Different +compilers have different mangling styles. The optional demangling style +argument can be used to choose an appropriate demangling style for your compiler. @end table @@ -663,7 +663,7 @@ names are not listed as global, and which are not visible outside the file/function/block where they were defined.) Time spent in these functions, calls to/from them, etc., will all be attributed to the function that was loaded directly before it in the executable file. -@c This is compatible with Unix @code{gprof}, but a bad idea. +@c This is compatible with Unix @code{gprof}, but a bad idea. This option affects both the flat profile and the call graph. @item -c @@ -732,8 +732,8 @@ not to propagate times for symbols matching @var{symspec}. @item -S@var{filename} @itemx --external-symbol-table=@var{filename} The @samp{-S} option causes @code{gprof} to read an external symbol table -file, such as @file{/proc/kallsyms}, rather than read the symbol table -from the given object file (the default is @code{a.out}). This is useful +file, such as @file{/proc/kallsyms}, rather than read the symbol table +from the given object file (the default is @code{a.out}). This is useful for profiling kernel modules. @item -z @@ -799,7 +799,7 @@ children@dots{}) in the call graph. The function will still be listed as a child of any functions that call it, but its index number will be shown as @samp{[not printed]}. More than one @samp{-e} option may be given; only one @var{function_name} may be indicated with each @samp{-e} -option. +option. @item -E @var{function_name} The @code{-E @var{function}} option works like the @code{-e} option, but @@ -813,7 +813,7 @@ The @samp{-f @var{function}} option causes @code{gprof} to limit the call graph to the function @var{function_name} and its children (and their children@dots{}). More than one @samp{-f} option may be given; only one @var{function_name} may be indicated with each @samp{-f} -option. +option. @item -F @var{function_name} The @samp{-F @var{function}} option works like the @code{-f} option, but @@ -933,8 +933,8 @@ This is part of a flat profile for a small program: Flat profile: Each sample counts as 0.01 seconds. - % cumulative self self total - time seconds seconds calls ms/call ms/call name + % cumulative self self total + time seconds seconds calls ms/call ms/call name 33.34 0.02 0.02 7208 0.00 0.00 open 16.67 0.03 0.01 244 0.04 0.12 offtime 16.67 0.04 0.01 8 1.25 1.25 memccpy @@ -1087,7 +1087,7 @@ function and the following lines describe its subroutines (also called The entries are sorted by time spent in the function and its subroutines. -The internal profiling function @code{mcount} (@pxref{Flat Profile, ,The +The internal profiling function @code{mcount} (@pxref{Flat Profile, ,The Flat Profile}) is never mentioned in the call graph. @menu @@ -1449,8 +1449,8 @@ Note that @code{ct_init} accounted for four histogram hits, and Flat profile: Each sample counts as 0.01 seconds. - % cumulative self self total - time seconds seconds calls us/call us/call name + % cumulative self self total + time seconds seconds calls us/call us/call name 30.77 0.13 0.04 6335 6.31 6.31 ct_init @@ -1482,8 +1482,8 @@ from line 385, and 6525 calls from 387. Flat profile: Each sample counts as 0.01 seconds. - % cumulative self - time seconds seconds calls name + % cumulative self + time seconds seconds calls name 7.69 0.10 0.01 ct_init (trees.c:349) 7.69 0.11 0.01 ct_init (trees.c:351) 7.69 0.12 0.01 ct_init (trees.c:382) @@ -1576,9 +1576,9 @@ annotated source listing for a sample @code{gzip} run: unsigned n; 2 ->@{ register ulg c; - + static ulg crc = (ulg)0xffffffffL; - + 2 -> if (s == NULL) @{ 1 -> c = 0xffffffffL; 1 -> @} else @{ @@ -1885,7 +1885,7 @@ more overhead than kernel-based profiling. Also, due to the added delay required to deliver the signal, this method is less accurate as well. -A special startup routine allocates memory for the histogram and +A special startup routine allocates memory for the histogram and either calls @code{profil()} or sets up a clock signal handler. This routine (@code{monstartup}) can be invoked in several ways. @@ -2099,7 +2099,7 @@ When multiple profile data files (or files with multiple histogram records) are read, the memory ranges of each pair of histogram records must be either equal, or non-overlapping. For each pair of histogram records, the resolution (memory region size divided by the number of -bins) must be the same. The time unit must be the same for all +bins) must be the same. The time unit must be the same for all histogram records. If the above containts are met, all histograms for the same memory range are merged. diff --git a/gprof/hist.c b/gprof/hist.c index 058ef3f33a..404c3629a1 100644 --- a/gprof/hist.c +++ b/gprof/hist.c @@ -80,14 +80,14 @@ SItab[] = /* Reads just the header part of histogram record into *RECORD from IFP. FILENAME is the name of IFP and - is provided for formatting error messages only. + is provided for formatting error messages only. If FIRST is non-zero, sets global variables HZ, HIST_DIMENSION, HIST_DIMENSION_ABBREV, HIST_SCALE. If FIRST is zero, checks that the new histogram is compatible with already-set values of those variables and emits an error if that's not so. */ static void -read_histogram_header (histogram *record, +read_histogram_header (histogram *record, FILE *ifp, const char *filename, int first) { @@ -109,7 +109,7 @@ read_histogram_header (histogram *record, done (1); } - n_hist_scale = (double)((record->highpc - record->lowpc) / sizeof (UNIT)) + n_hist_scale = (double)((record->highpc - record->lowpc) / sizeof (UNIT)) / record->num_bins; if (first) @@ -124,13 +124,13 @@ read_histogram_header (histogram *record, hz = profrate; memcpy (hist_dimension, n_hist_dimension, 15); hist_dimension_abbrev = n_hist_dimension_abbrev; - hist_scale = n_hist_scale; + hist_scale = n_hist_scale; } else { if (strncmp (n_hist_dimension, hist_dimension, 15) != 0) { - fprintf (stderr, + fprintf (stderr, _("%s: dimension unit changed between histogram records\n" "%s: from '%s'\n" "%s: to '%s'\n"), @@ -140,12 +140,12 @@ read_histogram_header (histogram *record, if (n_hist_dimension_abbrev != hist_dimension_abbrev) { - fprintf (stderr, + fprintf (stderr, _("%s: dimension abbreviation changed between histogram records\n" "%s: from '%c'\n" "%s: to '%c'\n"), whoami, whoami, hist_dimension_abbrev, whoami, n_hist_dimension_abbrev); - done (1); + done (1); } /* The only reason we require the same scale for histograms is that @@ -154,10 +154,10 @@ read_histogram_header (histogram *record, things for different functions. */ if (fabs (hist_scale - n_hist_scale) > 0.000001) { - fprintf (stderr, + fprintf (stderr, _("%s: different scales in histogram records"), whoami); - done (1); + done (1); } } } @@ -191,10 +191,10 @@ hist_read_rec (FILE * ifp, const char *filename) hist_clip_symbol_address (&lowpc, &highpc); if (lowpc != highpc) { - fprintf (stderr, + fprintf (stderr, _("%s: overlapping histogram records\n"), whoami); - done (1); + done (1); } /* This is new record. Add it to global array and allocate space for @@ -203,10 +203,10 @@ hist_read_rec (FILE * ifp, const char *filename) xrealloc (histograms, sizeof (histogram) * (num_histograms + 1)); memcpy (histograms + num_histograms, &n_record, sizeof (histogram)); - record = &histograms[num_histograms]; + record = &histograms[num_histograms]; ++num_histograms; - record->sample = (int *) xmalloc (record->num_bins + record->sample = (int *) xmalloc (record->num_bins * sizeof (record->sample[0])); memset (record->sample, 0, record->num_bins * sizeof (record->sample[0])); } @@ -217,9 +217,9 @@ hist_read_rec (FILE * ifp, const char *filename) DBG (SAMPLEDEBUG, printf ("[hist_read_rec] n_lowpc 0x%lx n_highpc 0x%lx ncnt %u\n", - (unsigned long) record->lowpc, (unsigned long) record->highpc, + (unsigned long) record->lowpc, (unsigned long) record->highpc, record->num_bins)); - + for (i = 0; i < record->num_bins; ++i) { UNIT count; @@ -233,8 +233,8 @@ hist_read_rec (FILE * ifp, const char *filename) record->sample[i] += bfd_get_16 (core_bfd, (bfd_byte *) & count[0]); DBG (SAMPLEDEBUG, printf ("[hist_read_rec] 0x%lx: %u\n", - (unsigned long) (record->lowpc - + i * (record->highpc - record->lowpc) + (unsigned long) (record->lowpc + + i * (record->highpc - record->lowpc) / record->num_bins), record->sample[i])); } @@ -255,7 +255,7 @@ hist_write_hist (FILE * ofp, const char *filename) histogram *record = &histograms[r]; /* Write header. */ - + if (gmon_io_write_8 (ofp, GMON_TAG_TIME_HIST) || gmon_io_write_vma (ofp, record->lowpc) || gmon_io_write_vma (ofp, record->highpc) @@ -267,11 +267,11 @@ hist_write_hist (FILE * ofp, const char *filename) perror (filename); done (1); } - + for (i = 0; i < record->num_bins; ++i) { bfd_put_16 (core_bfd, (bfd_vma) record->sample[i], (bfd_byte *) &count[0]); - + if (fwrite (&count[0], sizeof (count), 1, ofp) != 1) { perror (filename); @@ -453,7 +453,7 @@ hist_assign_samples () for (i = 0; i < num_histograms; ++i) hist_assign_samples_1 (&histograms[i]); - + } /* Print header for flag histogram profile. */ @@ -637,7 +637,7 @@ hist_print () { double scaled_value = SItab[log_scale].scale * top_time; - if (scaled_value >= 1.0 && scaled_value < 1000.0) + if (scaled_value >= 1.0 && scaled_value < 1000.0) break; } } @@ -675,7 +675,7 @@ hist_check_address (unsigned address) if (histograms[i].lowpc <= address && address < histograms[i].highpc) return 1; - return 0; + return 0; } #if ! defined(min) @@ -750,5 +750,5 @@ find_histogram_for_pc (bfd_vma pc) if (histograms[i].lowpc <= pc && pc < histograms[i].highpc) return &histograms[i]; } - return 0; + return 0; } diff --git a/gprof/hist.h b/gprof/hist.h index e08cee9675..90b760caef 100644 --- a/gprof/hist.h +++ b/gprof/hist.h @@ -46,10 +46,10 @@ extern void hist_print (void); we have histogram data. Returns 1 if so and 0 otherwise. */ extern int hist_check_address (unsigned address); -/* Given a range of addresses for a symbol, find a histogram record +/* Given a range of addresses for a symbol, find a histogram record that intersects with this range, and clips the range to that histogram record, modifying *P_LOWPC and *P_HIGHPC. - + If no intersection is found, *P_LOWPC and *P_HIGHPC will be set to one unspecified value. If more that one intersection is found, an error is emitted. */