![]() |
Home | Libraries | People | FAQ | More |
|
WARNING : PRE-RELEASE VERSION,
NOT OFFICIAL BOOST LIBRARY!!!! StackTrack is not an official Boost library. It has not been submitted for review as a potential Boost library, although the current intention is to seek review after a stable release with significant positive experience in the Boost community. |
Setting up an application for StackTrack in easy. This section walks through the basics.
| For information on getting StackTrack installed, see Installing and Building StackTrack |
The StackTrack checkpoint macros are used to specify the location of checkpoints within an application. Before adding checkpoints in a file, an appropriate StackTrack header needs to be included, and the file needs to be "registered" with the StackTrack system. The simplest way to do this is to add these lines
#include <boost/stacktrack/stacktrack.hpp> BOOST_STACKTRACK_FILE
to the source file.
// open track sink log( "foo" ); BOOST_STACKTRACK_SCOPE(main)
Here's a quick example:
#include <boost/stacktrack/stacktrack.hpp> #include <iostream> // sets up this source file for StackTrack BOOST_STACKTRACK_FILE // associate (and capture at beginning of each track) property value for this source file BOOST_STACKTRACK_FILE_PROPERTY( my_version, 1.1 ) void bar( int x, int y ) { std::cout << "bar x:" << x << " y:" << y << std::endl; } void foo( int z ) { BOOST_STACKTRACK_SCOPE( foo ) BOOST_STACKTRACK_VAL_OF( z ) int x; for( x = 0; x < z; x++ ) { bar( x, 0 ); } BOOST_STACKTRACK_STEP( x10 ) for( x = 0; x < z; x++ ) { bar( x, 10 ); } } int main( int argc, char *argv ) { // open track sink log( "foo" ); // start main track scope for this thread BOOST_STACKTRACK_SCOPE(main) foo( 1 ); return 0; }
| Copyright © 2005 James Fowler |