www.delorie.com/gnu/docs/gcc/gccint_133.html   search  
 
Buy the book!


GNU Compiler Collection (GCC) Internals

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

10.10.12 Generating Code for Profiling

These macros will help you generate code for profiling.

FUNCTION_PROFILER (file, labelno)
A C statement or compound statement to output to file some assembler code to call the profiling subroutine mcount.

The details of how mcount expects to be called are determined by your operating system environment, not by GCC. To figure them out, compile a small program for profiling using the system's installed C compiler and look at the assembler code that results.

Older implementations of mcount expect the address of a counter variable to be loaded into some register. The name of this variable is `LP' followed by the number labelno, so you would generate the name using `LP%d' in a fprintf.

PROFILE_HOOK
A C statement or compound statement to output to file some assembly code to call the profiling subroutine mcount even the target does not support profiling.

NO_PROFILE_COUNTERS
Define this macro if the mcount subroutine on your system does not need a counter variable allocated for each function. This is true for almost all modern implementations. If you define this macro, you must not use the labelno argument to FUNCTION_PROFILER.

PROFILE_BEFORE_PROLOGUE
Define this macro if the code for function profiling should come before the function prologue. Normally, the profiling code comes after.

TARGET_ALLOWS_PROFILING_WITHOUT_FRAME_POINTER
On some targets, it is impossible to use profiling when the frame pointer has been omitted. For example, on x86 GNU/Linux systems, the mcount routine provided by the GNU C Library finds the address of the routine that called the routine that called mcount by looking in the immediate caller's stack frame. If the immediate caller has no frame pointer, this lookup will fail.

By default, GCC assumes that the target does allow profiling when the frame pointer is omitted. This macro should be defined to a C expression that evaluates to false if the target does not allow profiling when the frame pointer is omitted.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

  webmaster     delorie software   privacy  
  Copyright 2003   by The Free Software Foundation     Updated Jun 2003