PrevUpHomeNext

User's Guide

Class call_stack

call_stack is a platform-agnostic data structure to keep call_frames information in. Use a boost::call_stack::call_stack_info to render it in a human-readable form.

The template is parameterized by the maximum depth of the stack to be collected.

One can get the stack either when a call_stack object is constructed, either later, by calling member get_stack().

Example

See previous section.

Class call_frame

call_frame holds the information of a call stack frame. Use a call_frame_info to print it.

Example

boost::call_stack::call_stack<40> astack; //
astack.get_stack(); // Where am I now?
for (std::size_t i = 0; i < astack.size(); ++i)
{
    boost::call_stack::call_frame aframe( astack[i] );
    std::cout << boost::call_stack::call_frame_info< boost::call_stack::extended_symbol_resolver    // extended_symbol_resolver, basic_symbol_resolver or null_symbol_resolver
                                                   , boost::call_stack::fancy_call_frame_formatter  // fancy_call_frame_formatter or terse_call_frame_formatter
                                                   > (aframe)
              << "\n"
              ;
}

Call Frame Formatters

A call_frame formatter dictates how the symbol information is to be printed to an output stream. The library supplies two symbol formatters:

Example

typedef boost::call_stack::call_stack<39> stack_type;
std::cout << "I am here: \n"
          << boost::call_stack::call_stack_info< stack_type
                                               , boost::call_stack::null_symbol_resolver
                                               , boost::call_stack::terse_call_frame_formatter
                                               >(stack_type(true))
          << std::endl;

Output:

I am here:
[eb1eea] ??+0x0 (??) in ??:0
[eb6f30] ??+0x0 (??) in ??:0
[eb2b1c] ??+0x0 (??) in ??:0
[eb2ab4] ??+0x0 (??) in ??:0
[eb1086] ??+0x0 (??) in ??:0
[eb9689] ??+0x0 (??) in ??:0
[eb97cd] ??+0x0 (??) in ??:0
[765433aa] ??+0x0 (??) in ??:0
[779d9ef2] ??+0x0 (??) in ??:0
[779d9ec5] ??+0x0 (??) in ??:0

Class call_frame_info

call_frame_info binds together:

Used to output call_frame information.

Example

boost::call_stack::call_stack<40> astack; //
astack.get_stack(); // Where am I now?
for (std::size_t i = 0; i < astack.size(); ++i)
{
    boost::call_stack::call_frame aframe( astack[i] );
    std::cout << boost::call_stack::call_frame_info< boost::call_stack::extended_symbol_resolver    // extended_symbol_resolver, basic_symbol_resolver or null_symbol_resolver
                                                   , boost::call_stack::fancy_call_frame_formatter  // fancy_call_frame_formatter or terse_call_frame_formatter
                                                   > (aframe)
              << "\n"
              ;
}

Class symbol_info

symbol_info binds together:

You can pass in to the constructor an arbitrary memory address. Do so at your own risk: proper resolution is platform-dependent and sometimes unreliable.

Example

// Construction from some address (of a function). Notes: MSVC 7.1 fails to resolve it.
boost::call_stack::symbol_info< boost::call_stack::extended_symbol_resolver,
                                boost::call_stack::fancy_symbol_formatter > sym1( func1 );
std::cout << "\nfunc1 symbol info:\n" << sym1 << std::endl;

Symbol Formatters

A symbol formatter dictates how the symbol information is to be printed to an output stream. The library supplies two symbol formatters:

Example

See above.

Class symbol_resolver

There are three symbol resolvers in the library:

Example

See above.

Class call_stack_info

call_stack_info is used to render to render call_stack in a human-readable form.

It binds together:

Example

See previous section.

boost::call_stack::init and boost::call_stack::shutdown

PrevUpHomeNext