[LC++]Producing a log of routine entry and exit

Vincent Penquerc'h Vincent.Penquerch at artworks.co.uk
Thu Aug 29 19:41:05 UTC 2002

> For debugging purposes, I wished to provide a standard means of
> logging the entry into, and exit from, each of my routines.  This
> log should give the name of the routine, and calling signature.
> On entry it should print the input parameters, and on exit, the
> output parameters.

class EntryExitLogger {
  string name;
  EntryExitLogger(const char *name): name(name)
    fprintf(stderr,"Entering %s\n",name);
    fprintf(stderr,"Exiting %s\n",name);

#define EELOG EntryExitLogger entry_exit_logger(__PRETTY_FUNCTION__);

void foo()
  // Do stuff

__PRETTY_FUNCTION__ may not be the right spelling, check the docs.

If you want the parameters, then it becomes way more complicated.
If you want an automated thing, your best bet is to either modify
the code to GCC to insert such code (yuck) or have some code to
interpret the function signature and peek on the stack what it says
is there (probably rather flaky).

Vincent Penquerc'h 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.linux.org.au/pipermail/tuxcpprogramming/attachments/20020829/aaf76be1/attachment.htm 

More information about the tuxCPProgramming mailing list