Boost logo

Boost :

From: scleary_at_[hidden]
Date: 2002-06-18 15:18:08


> From: David Abrahams [mailto:david.abrahams_at_[hidden]]
> ----- Original Message -----
> From: "Fernando Cacciola" <fcacciola_at_[hidden]>
> > ----- Original Message -----
> > From: "David Abrahams" <david.abrahams_at_[hidden]>
> > > I just want to point out that the termination model used by C++
> exceptions
> > > makes any approach using them unsuitable for a great many
> applications.
> > >
> > > -Dave
> > >
> > I don't understand what you mean. Could you elaborate it?
>
> Exceptions cause unwinding. Often you don't want that.
>
> Example 1: assertions. By the time the stack is unwound much
> information is
> lost. On Unix, for example, you want a core dump, not an exception. On
> Windows you also don't want stack unwinding, though the case
> is a little
> more complicated there.
>
> Example 2: memory allocation tracking and leak detection. An extremely
> useful technique involves labeling each allocated block with
> the call stack
> leading to the allocation. If every allocation causes an
> exception, your
> program won't get far.

This is what I was trying to get at in my earlier post: stack tracing and
exceptions should not have to be tied together. For, e.g., the 2nd example,
a stack tracing library should have some means of getting the "current
stack".

My current stack tracing solution is implemented as called from an exception
filter; I did it this way because the only other way under Win32 is to spawn
off a worker thread, suspend the original thread, have the worker thread
trace the original thread's stack, pass that info back to the original
thread, resume the original thread, and delete the worker thread. Which is
much more work. :)

But there's no reason why my stack tracing solution can't have a function
that just has a simple OS throw/catch. So the basic solution (called from
an exception filter) could still work.

To make it more clear, let's talk interface: what Dave/I would like:
  std::string get_stack();
not:
  try { ... } catch (const some_type & t) { t.get_stack(); }

        -Steve


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