public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-3988] libphobos: Print stacktrace before terminating program due to uncaught exception.
@ 2021-09-30 16:41 Iain Buclaw
  0 siblings, 0 replies; only message in thread
From: Iain Buclaw @ 2021-09-30 16:41 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:ed3ec7343b7d104a3285336fbfc1e4719719f9b6

commit r12-3988-ged3ec7343b7d104a3285336fbfc1e4719719f9b6
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date:   Sat Sep 25 23:03:41 2021 +0200

    libphobos: Print stacktrace before terminating program due to uncaught exception.
    
    By default, D run-time has a top level exception handler to catch
    anything that was uncaught by user code.  However when the
    `rt_trapExceptions' flag is cleared, this handler would not be enabled,
    and this termination would occur, aborting the program, but without any
    information about the exception.
    
    libphobos/ChangeLog:
    
            * libdruntime/gcc/deh.d (_d_print_throwable): Declare.
            (_d_throw): Print stacktrace before terminating program due to
            uncaught exception.

Diff:
---
 libphobos/libdruntime/gcc/deh.d | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/libphobos/libdruntime/gcc/deh.d b/libphobos/libdruntime/gcc/deh.d
index eb83751c59d..a7eb37cfd9e 100644
--- a/libphobos/libdruntime/gcc/deh.d
+++ b/libphobos/libdruntime/gcc/deh.d
@@ -34,6 +34,7 @@ extern(C)
 {
     int _d_isbaseof(ClassInfo, ClassInfo);
     void _d_createTrace(Object, void*);
+    void _d_print_throwable(Throwable t);
 }
 
 /**
@@ -510,7 +511,11 @@ extern(C) void _d_throw(Throwable object)
     // things, almost certainly we will have crashed before now, rather than
     // actually being able to diagnose the problem.
     if (r == _URC_END_OF_STACK)
+    {
+        __gdc_begin_catch(&eh.unwindHeader);
+        _d_print_throwable(object);
         terminate("uncaught exception", __LINE__);
+    }
 
     terminate("unwind error", __LINE__);
 }


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-09-30 16:41 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-30 16:41 [gcc r12-3988] libphobos: Print stacktrace before terminating program due to uncaught exception Iain Buclaw

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).