aboutsummaryrefslogtreecommitdiff
path: root/libgfortran
diff options
context:
space:
mode:
authorHarald Anlauf <anlauf@gmx.de>2012-01-09 19:53:27 +0000
committerTobias Burnus <burnus@gcc.gnu.org>2012-01-09 20:53:27 +0100
commit3881a3dee847b26d88355db35090214a0b5a7d43 (patch)
treedba1e46608e4deec61e85fb47f6faa0712d153a3 /libgfortran
parent96db41219623d27be681d27eb3c577ad0d2daaf2 (diff)
downloadgcc-3881a3dee847b26d88355db35090214a0b5a7d43.zip
gcc-3881a3dee847b26d88355db35090214a0b5a7d43.tar.gz
gcc-3881a3dee847b26d88355db35090214a0b5a7d43.tar.bz2
re PR fortran/51197 (Backtrace information less useful)
2012-01-09 Harald Anlauf <anlauf@gmx.de> Tobias Burnus <burnus@net-b.de> PR fortran/51197 * runtime/backtrace.c (show_backtrace): Modify wording written before the backtrace. * runtime/compile_options.c (show_signal): New function. (backtrace_handler): Use it. Co-Authored-By: Tobias Burnus <burnus@net-b.de> From-SVN: r183030
Diffstat (limited to 'libgfortran')
-rw-r--r--libgfortran/ChangeLog9
-rw-r--r--libgfortran/runtime/backtrace.c4
-rw-r--r--libgfortran/runtime/compile_options.c50
3 files changed, 60 insertions, 3 deletions
diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog
index c170cae..c399dbe 100644
--- a/libgfortran/ChangeLog
+++ b/libgfortran/ChangeLog
@@ -1,3 +1,12 @@
+2012-01-09 Harald Anlauf <anlauf@gmx.de>
+ Tobias Burnus <burnus@net-b.de>
+
+ PR fortran/51197
+ * runtime/backtrace.c (show_backtrace): Modify wording written
+ before the backtrace.
+ * runtime/compile_options.c (show_signal): New function.
+ (backtrace_handler): Use it.
+
2012-01-09 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
* Makefile.am (libgfortran_la_LDFLAGS): Add -Wc,-shared-libgcc.
diff --git a/libgfortran/runtime/backtrace.c b/libgfortran/runtime/backtrace.c
index e28bdcb..5ebd972 100644
--- a/libgfortran/runtime/backtrace.c
+++ b/libgfortran/runtime/backtrace.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2006, 2007, 2009, 2011 Free Software Foundation, Inc.
+/* Copyright (C) 2006, 2007, 2009, 2011, 2012 Free Software Foundation, Inc.
Contributed by François-Xavier Coudert
This file is part of the GNU Fortran runtime library (libgfortran).
@@ -197,7 +197,7 @@ show_backtrace (void)
state.frame_number = 0;
state.error = 0;
- estr_write ("\nA fatal error occurred! Backtrace for this error:\n");
+ estr_write ("\nBacktrace for this error:\n");
#if CAN_PIPE
diff --git a/libgfortran/runtime/compile_options.c b/libgfortran/runtime/compile_options.c
index 0c139a2..8038f07 100644
--- a/libgfortran/runtime/compile_options.c
+++ b/libgfortran/runtime/compile_options.c
@@ -1,5 +1,6 @@
/* Handling of compile-time options that influence the library.
- Copyright (C) 2005, 2007, 2009, 2010, 2011 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2007, 2009, 2010, 2011, 2012
+ Free Software Foundation, Inc.
This file is part of the GNU Fortran runtime library (libgfortran).
@@ -32,6 +33,52 @@ compile_options_t compile_options;
volatile sig_atomic_t fatal_error_in_progress = 0;
+
+/* Helper function for backtrace_handler to write information about the
+ received signal to stderr before actually giving the backtrace. */
+static void
+show_signal (int signum)
+{
+ const char * name = NULL, * desc = NULL;
+
+ switch (signum)
+ {
+#if defined(SIGSEGV)
+ case SIGSEGV:
+ name = "SIGSEGV";
+ desc = "Segmentation fault";
+ break;
+#endif
+
+#if defined(SIGBUS)
+ case SIGBUS:
+ name = "SIGBUS";
+ desc = "Bus error";
+ break;
+#endif
+
+#if defined(SIGILL)
+ case SIGILL:
+ name = "SIGILL";
+ desc = "Illegal instruction";
+ break;
+#endif
+
+#if defined(SIGFPE)
+ case SIGFPE:
+ name = "SIGFPE";
+ desc = "Floating-point exception";
+ break;
+#endif
+ }
+
+ if (name)
+ st_printf ("\nProgram received signal %d (%s): %s.\n", signum, name, desc);
+ else
+ st_printf ("\nProgram received signal %d.\n", signum);
+}
+
+
/* A signal handler to allow us to output a backtrace. */
void
backtrace_handler (int signum)
@@ -43,6 +90,7 @@ backtrace_handler (int signum)
raise (signum);
fatal_error_in_progress = 1;
+ show_signal (signum);
show_backtrace();
/* Now reraise the signal. We reactivate the signal's