Boost logo

Boost :

From: Michael Gopshtein (mgopshtein_at_[hidden])
Date: 2007-05-02 10:09:29

We are using sort of stack strace library in our project, and I think it
would be great to have something like that in boost.

Many responses talk about using build-in compiler's capabilities. IMHO they
don't always help.

As example, in our application we want the stack trace:
1) be always activated, even in release builds sent to the customers
2) be able to print the stack trace when exception occurs

1st is much easier using custom trace, as we don't need to compile the
project with debug info. BTW, that "instrumentation" doesn't look so bad in
the code, and can sometimes replace comment lines, e.g:
TRACE_UPDATE_CONTEXT("processing request");

The 2nd task is more tricky, as if you don't catch the exception in same
function where it occurs, but somewhere down the stack, the "normal" stack
trace is lost. In our code we keep a "history" of call stacks, and can
always print the whole stack.

1) When exitting a function, the stack trace should be automatically
notified. We did it by wrapping stack info with special class.
2) For multi-threaded application, separate stack should be kept for each
thread. There need to be a way to initialize per-thread structures before
using it.

"Atry" <pop.atry_at_[hidden]> wrote in message
> Java programs are easy to debug, one who catch an exception can print
> the stack trace, and when it crash, it would print the stack, too. It is
> useful, so I wrote some code of stack_trace for C++, see the sample below:
> ...

Boost list run by bdawes at, gregod at, cpdaniel at, john at