www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Exception tweak (simple solution to stack trace and friends)

reply Kai Backman <kai shorthike.com> writes:
 Walter,

=A0Here is a simple change I'd like to see to Exception:

class Exception {
+  static void* function() exceptionHook =3D null;
+  void* hookData;
}

=A0If the application sets the global exceptionHook this function is called=
 in
the context that generated the exception (ie. with the stack intact). The=
 return
value is attached to the Exception created.

 This would enable client implementation of stack tracing, crash dumps and
similar features without burdening the language or compiler. Currently
implementing crash recovery is brittle at best and impossibe at worst.

=A0Take care,

=A0Kai


--
Kai Backman, programmer, kai shorthike.com
http://www.ShortHike.com - space station game
Nov 07 2005
parent Kai Backman <kai shorthike.com> writes:
 On Mon, 7 Nov 2005 16:06:06 +0200, Kai Backman wrote:
=A0called in the context that generated the exception (ie. with the
=A0stack intact).
Just to be a bit more precise. There can naturally be a constant number of additional stack frames on the stack (the exception processing routines) or alternatively the hook function can take an int parameter giving the= number of extra frames. -- Kai Backman, programmer, kai shorthike.com http://www.ShortHike.com - space station game
Nov 07 2005