all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Eric S. Raymond" <esr@snark.thyrsus.com>
Subject: Patch -- fixes some deficiencies in the gprof manual
Date: Thu, 11 Sep 2003 18:22:01 -0400	[thread overview]
Message-ID: <200309112222.h8BMM1QY011530@snark.thyrsus.com> (raw)

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	other threads:[~2003-09-11 22:22 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200309112222.h8BMM1QY011530@snark.thyrsus.com \
    --to=esr@snark.thyrsus.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.