www.delorie.com/djgpp/doc/libc/libc_582.html   search  
libc.a reference

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

monstartup

Syntax

 
#include <sys/gmon.h>

int monstartup (unsigned long lowpc, unsigned long highpc);

Description

This function allows to selectively collect profiling information for a specific range of addresses. The arguments specify the address range that is to be sampled: the lowest address is given by lowpc and the highest is just below highpc. monstartup arranges for the profiling data to be gathered and written at program exit time, and then calls the moncontrol function (see section moncontrol) to start profiling.

The call graph printed by the gprof utility will only include functions in this range compiled with the `-pg' option, but EIP sampling triggered by the timer tick will measure execution time of all the functions in the specified range.

This function should be called by a program which was not linked with the `-pg' linker switch. If `-pg' was used during linking, monstartup is called automatically by the startup code with arguments which span the entire range of executable addresses in the program, from the program's entry point to the highest code segment address.

Only the first call to this function has an effect; any further calls will do nothing and return a failure indication. (In particular, in a program linked with `-pg', this function always fails, since the startup code already called it.) This is because monstartup sets up some internal data structures which cannot be resized if a different address range is requested.

Profiling begins on return from this function. You can use moncontrol (see section moncontrol) to turn profiling off and on.

Return Value

Zero on success, non-zero on failure.

Portability

ANSI/ISO C No
POSIX No

Example

See section moncontrol.


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

  webmaster   donations   bookstore     delorie software   privacy  
  Copyright 2004   by DJ Delorie     Updated Apr 2004