[Issue 1001] print stack trace (in debug mode) when program die

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Feb 4 17:19:03 PST 2010


http://d.puremagic.com/issues/show_bug.cgi?id=1001



--- Comment #13 from Witold Baryluk <baryluk at smp.if.uj.edu.pl> 2010-02-04 17:19:01 PST ---
(In reply to comment #12)
> Stack tracing is integrated with Throwable now, so if it's enabled it will
> happen for all exceptions that are created with "new" (ie. it won't happen on
> OutOfMemory).  It can either be shipped as a standalone library so the user has
> to link it, or it can be enabled/disabled via a code statement, something like:
> 
> Runtime.traceHandler = defaultTraceHandler; // turn on
> Runtime.traceHandler = null; // turn off
> 
> The runtime property is already there, so it would just be a matter of exposing
> "defaultTraceHandler".

IMHO it is not sufficient. It is global switch, will change behaviour of all
exceptions (beyond few system errors).

What is problematic is that one can have implementation of something (ie.
iterators) which uses havily exceptions (throw new ... them milion per second).
If this part of code is already tested we don't want to trace stack for this
control-exceptions becuase it is pointless and can for example slow down code
by order of magnitude (just a guess).

Possible solutions:
  - do not throw new object: save somewhere throwed object, and when back to
throw it again similar control exception, throw really buffered object (this
way we will not call constructor of exception).
  - have a way to specify which exceptions are traced, this can be done in
multiple ways:
    - trace all, minus blacklisted classes (defined in runtime or using
derivation from some class)
    - trace none, plus whitelisted classes (as above).

It would be also usefull to have handler of SIGSEGV signal which will show
trace of the thread/process which done something wrong. Also INT3 is intersting
to have.


In flectioned (which is nice, but really hackish, have ELF parser, lots of
asembler and whiteliste of many functions), this is solved using (phobos part);
 - tracing only of exceptions derived from flectioned.TracedException
 - and optionally tracing all exception by calling first
                 flectioned.TracedException.traceAllExceptions(true);

Well maybe You have better ideas :)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list