Boost logo

Boost :

From: Sven Van Echelpoel (sven.vanechelpoel.sv_at_[hidden])
Date: 2002-06-13 06:30:05


[...]

> To complement (a) I have uploaded a file to
> http://groups.yahoo.com/group/boost/files/StackTraces/ which contains Linux
> and Solaris implementations. It separates the system-dependant part from
> display. The system part is a function stacktrace() that calls back to a
> display functor for each stack entry encountered. The example function
> that
> I included only writes to an ostream, but functors to append to strings or
> call back_inserters are easy to add. These files are meant to be a starting
> point for discussing requirements for (a).

Why not use iterators in the style of the stream iterators? I once
implemented such a stackframe_iterator, modeled as a forward iterator.
Dereferencing the iterator yields a stackframe object. Its use was
extremenly simple:

stackframe_iterator start_frame( 0 ); // 0 means start from this frame
                                       // 1 is the frame of the caller,
etc
stackframe_iterator end_frame;

// now use them however you like

I used dbghelp dll on windows, so the interface may not be portable to
every platform. Anyway, this is just a sugestion.

Svenne.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk