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

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue May 25 00:15:43 PDT 2010


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



--- Comment #19 from Brad Roberts <braddr at puremagic.com> 2010-05-25 00:15:31 PDT ---
Sean, any objection to me submitting this minor diff:

Index: src/object_.d
===================================================================
--- src/object_.d       (revision 296)
+++ src/object_.d       (working copy)
@@ -1189,6 +1189,13 @@
     traceHandler = h;
 }

+/**
+ * Return the current trace handler
+ */
+extern (C) TraceHandler rt_getTraceHandler()
+{
+    return traceHandler;
+}

 /**
  * This function will be called when an exception is constructed.  The
Index: src/core/runtime.d
===================================================================
--- src/core/runtime.d  (revision 296)
+++ src/core/runtime.d  (working copy)
@@ -23,6 +23,7 @@

     extern (C) void rt_setCollectHandler( CollectHandler h );
     extern (C) void rt_setTraceHandler( TraceHandler h );
+    extern (C) TraceHandler rt_getTraceHandler();

     alias void delegate( Throwable ) ExceptionHandler;
     extern (C) bool rt_init( ExceptionHandler dg = null );
@@ -172,6 +173,13 @@
         rt_setTraceHandler( h );
     }

+    /**
+     * Return the current trace handler
+     */
+    static TraceHandler traceHandler()
+    {
+        return rt_getTraceHandler();
+    }

     /**
      * Overrides the default collect hander with a user-supplied version. 
This


This would enable code like this:

    auto oldTH = Runtime.traceHandler;
    Runtime.traceHandler = null;
    scope(exit) Runtime.traceHandler = oldTH;

I ran across this 'need' while working on the dmd test suite that is checking
some object throwing results, specifically two asserts like this:

    Object e = new Exception("hello");
    assert(e.toString() == "object.Exception: hello");
    assert(format(e) == "object.Exception: hello");

-- 
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