2009-02-12 Ken Werner <ken.werner@de.ibm.com>
- * corefile.c (core_create_function_syms): Remove "<locore>" and
+ * corefile.c (core_create_function_syms): Remove "<locore>" and
"<hicore>" sentinels.
* gprof.c: Likewise.
* cg_print.c (cg_print_function_ordering): Likewise.
# 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
# <http://www.gnu.org/licenses/>.
# 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
# <http://www.gnu.org/licenses/>.
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
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".
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
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. */
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 <http://www.gnu.org/licenses/>.
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
#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)
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));
}
done (1);
}
- histograms->sample[i]
+ histograms->sample[i]
+= bfd_get_16 (core_bfd, (bfd_byte *) raw_bin_count);
}
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
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);
if (output_style & STYLE_FLAT_PROFILE)
{
/* Print the flat profile. */
- hist_print ();
+ hist_print ();
}
if (cg && (output_style & STYLE_CALL_GRAPH))
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 ();
@titlepage
@title GNU gprof
-@subtitle The @sc{gnu} Profiler
+@subtitle The @sc{gnu} Profiler
@ifset VERSION_PACKAGE
@subtitle @value{VERSION_PACKAGE}
@end ifset
@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 ]
@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}
@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
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
@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
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
@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
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
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
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
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
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
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)
unsigned n;
2 ->@{
register ulg c;
-
+
static ulg crc = (ulg)0xffffffffL;
-
+
2 -> if (s == NULL) @{
1 -> c = 0xffffffffL;
1 -> @} else @{
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.
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.
/* 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)
{
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)
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"),
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
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);
}
}
}
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
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]));
}
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;
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]));
}
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)
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);
for (i = 0; i < num_histograms; ++i)
hist_assign_samples_1 (&histograms[i]);
-
+
}
/* Print header for flag histogram profile. */
{
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;
}
}
if (histograms[i].lowpc <= address && address < histograms[i].highpc)
return 1;
- return 0;
+ return 0;
}
#if ! defined(min)
if (histograms[i].lowpc <= pc && pc < histograms[i].highpc)
return &histograms[i];
}
- return 0;
+ return 0;
}
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. */