Boost logo

Boost :

From: Hendrik Schober (boost_at_[hidden])
Date: 2002-06-20 11:33:10


"Ted Byers" <r.ted.byers_at_[hidden]> wrote:
> [...]
> 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 [...]

  Why that string? That's (approximately) how I do it:

    # define ERROR_STACKTRACE_BEGIN {const unsigned int _error_exc_stack_trace_line=__LINE__;try{
    # define ERROR_STACKTRACE_END }catch(...){Error::Detail::addStackTrace(STACK_HERE(_error_exc_stack_trace_line));throw;}}

  where 'STACK_HERE' is

    #if defined(COMPILER_FEATURE_FUNCTION_MACRO)
    # define STACK_HERE(begin) __FILE__, \
                                 begin, __LINE__, \
                                 COMPILER_FEATURE_FUNCTION_MACRO, \
                                 __DATE__, __TIME__
    #else //defined(COMPILER_FEATURE_FUNCTION_MACRO)
    # define STACK_HERE(begin) __FILE__, \
                                 begin, __LINE__, \
                                 __DATE__, __TIME__
    #endif //defined(COMPILER_FEATURE_FUNCTION_MACRO)

  (I don't believe in everybody always thinking of
  changing manually added function name string literals.
  I think it's either automagic, or it's error prone.)

> 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 ;-)).

  Yeah, it's easier for me to upload it, isn't it? <g>

> [...] 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?

  There isn't much that you're allowed to do in a
  signal handler. Throwing exceptions isn't among
  that. (AFAIK, you might not even have a valid stack
  frame within a signal handler.)

> Cheers,
>
> Ted

  Schobi


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