Boost logo

Boost :

From: Michael Gopshtein (mgopshtein_at_[hidden])
Date: 2007-05-02 14:26:01


"me22" <me22.ca_at_[hidden]> wrote in message
news:fa28b9250705020844x39fb51e7s11356a63ef184436_at_mail.gmail.com...
> On 02/05/07, Michael Gopshtein <mgopshtein_at_[hidden]> wrote:
>> 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.
>>
> That's a neat idea.
>
> I'm guessing you keep an iterator into the container of calls, then on
> a return just decrement that iterator so you can see the full trace
> even after stack unwinding, then be able to throw away those calls
> when you next call a function? (Or something like that.)

Yes, that's exactly what it does. It basically keeps a list of call stacks,
and 2 iterators: "current" and "maximal". When entering a function:
current++; maximal=current. When leaving a function: current-- only.
When exception is caught, the whole stack is printed, until the "maximal".

The main problem with it to distinquish between the case where you return
from the function normally, and the case of exception. On of solutions is
Atry's and Pavel's suggestion: storing tha stack info in the constructor of
exception object. Other option is to just set the "maximal" iterator in
exception's constructor, to make sure we don't print extra functions.

> ~ Scott McMurray
> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost
>


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