daily update
[external/binutils.git] / gprof / gprof.texi
index f389087..30f43f9 100644 (file)
@@ -1,7 +1,7 @@
 \input texinfo @c -*-texinfo-*-
 @setfilename gprof.info
 @c Copyright 1988, 1992, 1993, 1998, 1999, 2000, 2001, 2002, 2003,
-@c 2004, 2007, 2008
+@c 2004, 2007, 2008, 2009
 @c Free Software Foundation, Inc.
 @settitle GNU gprof
 @setchapternewpage odd
 @include bfdver.texi
 @c man end
 
-@ifinfo
+@ifnottex
 @c This is a dir.info fragment to support semi-automated addition of
 @c manuals to an info tree.  zoo@cygnus.com is developing this facility.
-@format
-START-INFO-DIR-ENTRY
+@dircategory Software development
+@direntry
 * gprof: (gprof).                Profiling your program's execution
-END-INFO-DIR-ENTRY
-@end format
-@end ifinfo
+@end direntry
+@end ifnottex
 
 @copying
 This file documents the gprof profiler of the GNU system.
 
 @c man begin COPYRIGHT
-Copyright @copyright{} 1988, 92, 97, 98, 99, 2000, 2001, 2003, 2007, 2008 Free Software Foundation, Inc.
+Copyright @copyright{} 1988, 1992, 1997, 1998, 1999, 2000, 2001, 2003,
+2007, 2008, 2009 Free Software Foundation, Inc.
 
 Permission is granted to copy, distribute and/or modify this document
 under the terms of the GNU Free Documentation License, Version 1.3
@@ -57,7 +57,8 @@ execute programs.  @sc{gnu} @code{gprof} was written by Jay Fenlason.
 Eric S. Raymond made some minor corrections and additions in 2003.
 
 @vskip 0pt plus 1filll
-Copyright @copyright{} 1988, 92, 97, 98, 99, 2000, 2003, 2008 Free Software Foundation, Inc.
+Copyright @copyright{} 1988, 1992, 1997, 1998, 1999, 2000, 2003, 2008,
+2009 Free Software Foundation, Inc.
 
       Permission is granted to copy, distribute and/or modify this document
       under the terms of the GNU Free Documentation License, Version 1.3
@@ -128,7 +129,8 @@ gprof [ -[abcDhilLrsTvwxyz] ] [ -[ACeEfFJnNOpPqQZ][@var{name}] ]
  [ --static-call-graph ] [ --sum ] [ --table-length=@var{len} ]
  [ --traditional ] [ --version ] [ --width=@var{n} ]
  [ --ignore-non-functions ] [ --demangle[=@var{STYLE}] ]
- [ --no-demangle ] [ @var{image-file} ] [ @var{profile-file} @dots{} ]
+ [ --no-demangle ] [--external-symbol-table=name] 
+ [ @var{image-file} ] [ @var{profile-file} @dots{} ]
 @c man end
 @end smallexample
 
@@ -325,6 +327,20 @@ example:
 ld -o myprog /lib/gcrt0.o myprog.o utils.o -lc_p
 @end example
 
+If you are running the program on a system which supports shared
+libraries you may run into problems with the profiling support code in
+a shared library being called before that library has been fully
+initialised.  This is usually detected by the program encountering a
+segmentation fault as soon as it is run.  The solution is to link
+against a static version of the library containing the profiling
+support code, which for @code{gcc} users can be done via the
+@samp{-static} or @samp{-static-libgcc} command line option.  For
+example:
+
+@example
+gcc -g -pg -static-libgcc myprog.c utils.c -o myprog
+@end example
+
 If you compile only some of the modules of the program with @samp{-pg}, you
 can still profile the program, but you won't get complete information about
 the modules that were compiled without @samp{-pg}.  The only information
@@ -711,6 +727,13 @@ to only propagate times for symbols matching @var{symspec}.
 The @samp{-n} option causes @code{gprof}, in its call graph analysis,
 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 
+for profiling kernel modules.
+
 @item -z
 @itemx --display-unused-functions
 If you give the @samp{-z} option, @code{gprof} will mention all
@@ -763,10 +786,10 @@ number, and then exit.
 @node Deprecated Options
 @section Deprecated Options
 
-@table @code
-
 These options have been replaced with newer versions that use symspecs.
 
+@table @code
+
 @item -e @var{function_name}
 The @samp{-e @var{function}} option tells @code{gprof} to not print
 information about the function @var{function_name} (and its
@@ -1591,10 +1614,14 @@ only a small amount of time, so that on the average the sampling process
 ought to catch that function in the act only once, there is a pretty good
 chance it will actually find that function zero times, or twice.
 
-By contrast, the number-of-calls and basic-block figures
-are derived by counting, not
-sampling.  They are completely accurate and will not vary from run to run
-if your program is deterministic.
+By contrast, the number-of-calls and basic-block figures are derived
+by counting, not sampling.  They are completely accurate and will not
+vary from run to run if your program is deterministic and single
+threaded.  In multi-threaded applications, or single threaded
+applications that link with multi-threaded libraries, the counts are
+only deterministic if the counting function is thread-safe.  (Note:
+beware that the mcount counting function in glibc is @emph{not}
+thread-safe).  @xref{Implementation, ,Implementation of Profiling}.
 
 The @dfn{sampling period} that is printed at the beginning of the flat
 profile says how often samples are taken.  The rule of thumb is that a