Boost logo

Boost :

From: Atry (pop.atry_at_[hidden])
Date: 2007-04-20 14:22:25

Larry Evans дµÀ:
> On 04/20/2007 12:04 PM, Atry wrote:
>> 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:
> The trace_scope_stk template here:
> is related. I've not used it in quite a while; so, the following
> description may not be entirely accurate. To use it, us must
> declare an instance of the template at each scope entry. When
> the program runs, it prints an indented message when entrying the scope
> and again when exiting the scope. The indentation reflects the
> depth of the call stack. The elements in the call stack are also
> stored in a stack which, I'd expect, you can print out somehow.
> Just from a brief glance at your code, it looks like you also have to
> put some code at the start of each scope entry and I guess the code
> pushes something onto the stack (line and file number) which can
> then be printed when an exception is thrown.
> It would be nice to merge these two.
> ------------------------------------------------------------------------
> _______________________________________________
> Unsubscribe & other changes:

I have seen trace_scope_stk, and I think it is another function. I did
not print so many message at each entry/exit of each scope. I just
record the call stack instead of writing anything. I am not care how
user use these record. So I wrote exception_with_stack_trace in
sample.hpp, assuming someone would use stack track information with
In my macro at start of each scope entry, it declare an static element.
once the program enter the scope, it only push the pointer of the static
element on the element stack. The element stack is a tss pointer, so it
would work with multi-thread.

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