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

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

moncontrol

Syntax

 
#include <sys/gmon.h>

int moncontrol (int mode);

Description

This function allows to control collection of profiling information during the program run. Profiling begins when a program linked with the `-pg' option starts, or when monstartup is called (see section monstartup). To stop the collection of histogram ticks and function call counts, call moncontrol with a zero argument mode; this stops the timer used to sample the program counter (EIP) values and disables the code which counts how many times each function compiled with `-pg' was called. To resume collection of profile data, call moncontrol with a non-zero argument.

Note that the profiling output is always written to the file `gmon.out' at program exit time, regardless of whether profiling is on or off.

Return Value

moncontrol returns the previous state of profiling: zero if it was turned off, non-zero if it was on.

Portability

ANSI/ISO C No
POSIX No

Example

 
 extern void my_func();
 extern void my_func_end();
 /* Profile only one function.  */
 monstartup((unsigned long)my_func, (unsigned long)my_func_end);
 ...
 /* Stop profiling.  */
 moncontrol(0);
 ...
 /* Resume profiling.  */
 moncontrol(1);

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