Boost logo

Boost :

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

"me22" <me22.ca_at_[hidden]> wrote in message
> 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:

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