Patchwork [Fortran] PR51197 - print signal number before backtrace [RFC]

login
register
mail settings
Submitter Tobias Burnus
Date Jan. 9, 2012, 10:33 p.m.
Message ID <4F0B6B4A.8010203@net-b.de>
Download mbox | patch
Permalink /patch/135128/
State New
Headers show

Comments

Tobias Burnus - Jan. 9, 2012, 10:33 p.m.
Dear Janne,

> - The integer values for the signal numbers are not standardized,
> hence printing them might give the user a false impression that these
> numbers convey some information beyond whichever SIG* macro they map
> to on that particular target.
>
> - It doesn't test all the signals which are actually handled, see
> compile_options.c:set_options(). Also, as a minor point, there's no
> need to have #ifdef tests for the C89 signals, again see
> set_options().

How about the attached version? The description is based on IEEE Std 
1003.1:2003, though I additionally left "segmentation fault" and 
"floating-point exception" as those names are presumably better known 
that the long description and as SIGSEGV/SIGFPE. "Bus error" is also 
somewhat known, but SIGBUS should be sufficient.

Tobias
Janne Blomqvist - Jan. 10, 2012, 7:15 a.m.
On Tue, Jan 10, 2012 at 00:33, Tobias Burnus <burnus@net-b.de> wrote:
> Dear Janne,
>
>
>> - The integer values for the signal numbers are not standardized,
>> hence printing them might give the user a false impression that these
>> numbers convey some information beyond whichever SIG* macro they map
>> to on that particular target.
>>
>> - It doesn't test all the signals which are actually handled, see
>> compile_options.c:set_options(). Also, as a minor point, there's no
>> need to have #ifdef tests for the C89 signals, again see
>> set_options().
>
>
> How about the attached version? The description is based on IEEE Std
> 1003.1:2003, though I additionally left "segmentation fault" and
> "floating-point exception" as those names are presumably better known that
> the long description and as SIGSEGV/SIGFPE. "Bus error" is also somewhat
> known, but SIGBUS should be sufficient.

Ok, thanks!

Patch

2012-01-09  Tobias Burnus  <burnus@net-b.de>

	PR fortran/51197
	* runtime/compile_options.c (show_signal): List
	more signals.

Index: libgfortran/runtime/compile_options.c
===================================================================
--- libgfortran/runtime/compile_options.c	(Revision 183034)
+++ libgfortran/runtime/compile_options.c	(Arbeitskopie)
@@ -43,37 +43,72 @@  show_signal (int signum)
 
   switch (signum)
     {
-#if defined(SIGSEGV)
+#if defined(SIGQUIT)
+      case SIGQUIT:
+	name = "SIGQUIT";
+	desc = "Terminal quit signal";
+	break;
+#endif
+
+      /* The following 4 signals are defined by C89.  */
+      case SIGILL:
+	name = "SIGILL";
+	desc = "Illegal instruction";
+	break;
+
+      case SIGABRT:
+	name = "SIGABRT";
+	desc = "Process abort signal";
+	break;
+
+      case SIGFPE:
+	name = "SIGFPE";
+	desc = "Floating-point exception - erroneous arithmetic operation";
+	break;
+
       case SIGSEGV:
 	name = "SIGSEGV";
-	desc = "Segmentation fault";
+	desc = "Segmentation fault - invalid memory reference";
 	break;
-#endif
 
 #if defined(SIGBUS)
       case SIGBUS:
 	name = "SIGBUS";
-	desc = "Bus error";
+	desc = "Access to an undefined portion of a memory object";
 	break;
 #endif
 
-#if defined(SIGILL)
-      case SIGILL:
-	name = "SIGILL";
-	desc = "Illegal instruction";
+#if defined(SIGSYS)
+      case SIGSYS:
+	name = "SIGSYS";
+	desc = "Bad system call";
 	break;
 #endif
 
-#if defined(SIGFPE)
-      case SIGFPE:
-	name = "SIGFPE";
-	desc = "Floating-point exception";
+#if defined(SIGTRAP)
+      case SIGTRAP:
+	name = "SIGTRAP";
+	desc = "Trace/breakpoint trap";
 	break;
 #endif
+
+#if defined(SIGXCPU)
+      case SIGXCPU:
+	name = "SIGXCPU";
+	desc = "CPU time limit exceeded";
+	break;
+#endif
+
+#if defined(SIGXFSZ)
+      case SIGXFSZ:
+	name = "SIGXFSZ";
+	desc = "File size limit exceeded";
+	break;
+#endif
     }
 
   if (name)
-    st_printf ("\nProgram received signal %d (%s): %s.\n", signum, name, desc);
+    st_printf ("\nProgram received signal %s: %s.\n", name, desc);
   else
     st_printf ("\nProgram received signal %d.\n", signum);
 }