Basic Interface

Function Stack

Tracking the calling sequence is done by creating a TraceFct object in each routine which should be tracked. The sequence is stored as class global -- TraceFct thus may not reliably be used in a multithreaded program.

The class must be initialized by calling the special, three argument version of the constructor. This is usually done in the main subroutine.

int main( int argc, char * argv[] )
{
  TraceFct tf( argv[0], 0, -1 );

Thereafter, use the one-argument constructor when entering a new subroutine to be traced.

void f2( void )
{
  static int level = 0;
  TraceFct tf( "f2" );

Messages and Exit

TraceFct provides several methods to output warning or diagnostic messages as well as produce a function stack dump upon an error exit. The benefit of using the output methods is that all output will have a common, unique prefix, which permits easier analysis of complicated log files. Messages may have embedded newlines.

  tf.message( "message test: %d\n", level );
  tf.message( "1. multiline\n2. message test\n" );

Currently TraceFct does not have an overloaded << operator; use the TraceFct::message() and TraceFct::vmessage() methods.

To generate a stack dump upon exit, use the TraceFct::exit() method.

    tf.exit( 1, "f1 exit: line1\nf1 exit: line2, extra newline\n" );

To generate just a stack dump, just call TraceFct::dump_stack().


Go to the prev section, the next section, or the top.

Generated on Mon Oct 20 13:55:20 2008 for tracefctxx by  doxygen 1.5.6