bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Patch -- fixes some deficiencies in the gprof manual


From: Eric S. Raymond
Subject: Patch -- fixes some deficiencies in the gprof manual
Date: Thu, 11 Sep 2003 18:22:01 -0400

Answers the biggest FAQ.  Corrects some typos.  Adds a useful tip.

--- gprof.texi.orig     2003-09-11 17:42:44.000000000 -0400
+++ gprof.texi  2003-09-11 18:10:15.000000000 -0400
@@ -90,6 +90,7 @@
 execute programs.  @sc{gnu} @code{gprof} was written by Jay Fenlason.
 
 This manual was updated August 1997 by Brent Baccala.
+Eric S. Raymond made some minor corrections and additions in 2003.
 
 @menu
 * Introduction::        What profiling means, and why it is useful.
@@ -190,6 +191,14 @@
 cc -o myprog myprog.c utils.c -g -pg
 @end example
 
+Note: The @samp{-pg} option must be part of your compilation options
+as well as your link options.  If it is not, when you run @code{gprof}
+you will get no profile report and an error message like this:
+
+@example
+gprof: gmon.out file is missing call-graph data
+@end example
+
 If you run the linker @code{ld} directly instead of through a compiler
 such as @code{cc}, you may have to specify a profiling startup file
 @file{gcrt0.o} as the first input file instead of the usual startup
@@ -219,10 +228,13 @@
 that match program addresses to source code lines.
 @xref{Line-by-line}.
 
-In addition to the @samp{-pg} and @samp{-g} options,
-you may also wish to specify the @samp{-a} option when compiling.
-This will instrument
-the program to perform basic-block counting.  As the program runs,
+In addition to the @samp{-pg} and @samp{-g} options, older versions of
+GCC required you to specify the @samp{-a} option when compiling in
+order to instrument it to perform basic-block counting.  Newer
+versions do not require this option and will not accept it;
+basic-block counting is always enabled when @samp{-pg} is on.
+
+When basic-block counting is enabled, as the program runs
 it will count how many times it executed each branch of each @samp{if}
 statement, each iteration of each @samp{do} loop, etc.  This will
 enable @code{gprof} to construct an annotated source code
@@ -303,7 +315,7 @@
 * Output Options::      Controlling @code{gprof}'s output style
 * Analysis Options::    Controlling how @code{gprof} analyses its data
 * Miscellaneous Options::
-* Depricated Options::  Options you no longer need to use, but which
+* Deprecated Options::  Options you no longer need to use, but which
                             have been retained for compatibility
 * Symspecs::            Specifying functions to include or exclude
 @end menu
@@ -565,7 +577,7 @@
 
 @end table
 
-@node Miscellaneous Options,Depricated Options,Analysis Options,Invoking
+@node Miscellaneous Options,Deprecated Options,Analysis Options,Invoking
 @section Miscellaneous Options
 
 @table @code
@@ -601,8 +613,8 @@
 
 @end table
 
-@node Depricated Options,Symspecs,Miscellaneous Options,Invoking
-@section Depricated Options
+@node Deprecated Options,Symspecs,Miscellaneous Options,Invoking
+@section Deprecated Options
 
 @table @code
 
@@ -653,7 +665,7 @@
 lists in the call graph all functions that were reached from either
 @code{foo} or @code{bar} and were not reachable from @code{boring}.
 
-@node Symspecs,,Depricated Options,Invoking
+@node Symspecs,,Deprecated Options,Invoking
 @section Symspecs
 
 Many of the output options allow functions to be included or excluded
@@ -1507,6 +1519,14 @@
 @chapter Answers to Common Questions
 
 @table @asis
+@item How can I get more exact information about hot spots in my program?
+
+Looking at the per-line call counts only tells part of the story.
+Because @code{gprof} can only report call times and counts by function,
+the best way to get finer-grained information on where the program
+is spending its time is to refactor large functions into sequences
+of calls to smaller ones.
+
 @item How do I find which lines in my program were executed the most times?
 
 Compile your program with basic-block counting enabled, run it, then
-- 
                <a href="http://www.catb.org/~esr/";>Eric S. Raymond</a>

"Taking my gun away because I might shoot someone is like cutting my tongue
out because I might yell `Fire!' in a crowded theater."
        -- Peter Venetoklis




reply via email to

[Prev in Thread] Current Thread [Next in Thread]