Boost logo

Boost :

From: Ted Byers (r.ted.byers_at_[hidden])
Date: 2002-06-20 10:45:43

> The immediate need I had was, a low-level function contains an
> assert. I gave the code to an associate, who quickly triggered the
> assertion. I couldn't easily tell where it came from since it could
> have been called on various paths. I would have liked to see a
> traceback showing the path through my code, maybe up to main.
So then, something like my traceable exceptions may work for you, if you're
willing to add a couple automatic string variables and one macro at the
beginning of each function you want to be able to have show up in such a
trace, and a second macro at the end of each of these functions (much easier
it done from the beginning of a project than it is to add after it is mostly
developed, which is something I am faced with). Hopefully I will get a
simple example put together and sent to Schobi showing how I use this RSN
(I'd be faster with this if I didn't have to earn a living ;-)).

> I personally don't often use exceptions. By default on my environment
> (linux/g++) they provide no information to the user that can be fed
> back to the programmer (other than a core). In most cases the core is
> useless when compiled with high optimization on g++.
I haven't use them much until now, but I would point out a couple things.
My traceable exception assumes nothing about the interface of the exception
class caught, other than that it exists, unless one specifically provides a
specialization for a given exception class. This would fit well with your
default exceptions. That said, I am now looking at producing an exception
class framework to handle OS/hardware exceptions, and having the constructor
capture as much information about them as Windows provides. Then, this
stuff would be embedded into my traceable exception framework so that,
again, the cost of using it would be the same as it is now, ignoring the
runtime overhead of try/catch blocks. A creative use of conditional defines
would make this portable between Borland's C++ Builder and MSVC++ (and I can
test on both because I have both). I do not see why you couldn't do the
same sort of thing with Linux/g++: the interface can be made the same, while
the contents of the cpp files would vary among platforms. In fact, if my
revenues remain stable, I hope to get a new computer and put Suse Linux on
it (and OpenBSD on one of my old ones), so I'd love to hear about how one
could do this sort of thing on your platform. Have you written signal
handlers that deal with the various sorts of hardware or OS error that might
occur and need to be handled? If so, what do you think of the idea of
trapping these signals and converting them into exceptions (giving the
exception all the information you can collect at the point the signal is
raised), and then throwing and converting these into traceable exceptions?



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