+2015-09-05 Janne Blomqvist <jb@gcc.gnu.org>
+
+ PR fortran/53379
+ * libgfortran.h (exit_error): New prototype.
+ * runtime/error.c (exit_error): New function.
+ (os_error): Call exit_error instead of exit.
+ (runtime_error): Likewise.
+ (runtime_error_at): Likewise.
+ (internal_error): Likewise.
+ (generate_error): Likewise.
+ (notify_std): Likewise.
+ * runtime/stop.c (error_stop_string): Likewise.
+ (error_stop_numeric): Likewise.
+
2015-09-04 Janne Blomqvist <jb@gcc.gnu.org>
* io/unix.h (delete_file): Remove prototype.
2.3.5 also explains how co-images synchronize during termination.
- In libgfortran we have two ways of ending a program. exit(code) is
- a normal exit; calling exit() also causes open units to be
- closed. No backtrace or core dump is needed here. When something
- goes wrong, we have sys_abort() which tries to print the backtrace
- if -fbacktrace is enabled, and then dumps core; whether a core file
- is generated is system dependent. When aborting, we don't flush and
- close open units, as program memory might be corrupted and we'd
- rather risk losing dirty data in the buffers rather than corrupting
- files on disk.
+ In libgfortran we have three ways of ending a program. exit(code)
+ is a normal exit; calling exit() also causes open units to be
+ closed. No backtrace or core dump is needed here. For error
+ termination, we have exit_error(status), which prints a backtrace
+ if backtracing is enabled, then exits. Finally, when something
+ goes terribly wrong, we have sys_abort() which tries to print the
+ backtrace if -fbacktrace is enabled, and then dumps core; whether a
+ core file is generated is system dependent. When aborting, we don't
+ flush and close open units, as program memory might be corrupted
+ and we'd rather risk losing dirty data in the buffers rather than
+ corrupting files on disk.
*/
}
+/* Exit in case of error termination. If backtracing is enabled, print
+ backtrace, then exit. */
+
+void
+exit_error (int status)
+{
+ if (options.backtrace == 1
+ || (options.backtrace == -1 && compile_options.backtrace == 1))
+ {
+ estr_write ("\nError termination. Backtrace:\n");
+ show_backtrace (false);
+ }
+ exit (status);
+}
+
+
+
/* gfc_xtoa()-- Integer to hexadecimal conversion. */
const char *
estr_write ("\n");
estr_write (message);
estr_write ("\n");
- exit (1);
+ exit_error (1);
}
iexport(os_error);
st_vprintf (message, ap);
va_end (ap);
estr_write ("\n");
- exit (2);
+ exit_error (2);
}
iexport(runtime_error);
st_vprintf (message, ap);
va_end (ap);
estr_write ("\n");
- exit (2);
+ exit_error (2);
}
iexport(runtime_error_at);
because hopefully it doesn't happen too often). */
stupid_function_name_for_static_linking();
- exit (3);
+ exit_error (3);
}
estr_write ("Fortran runtime error: ");
estr_write (message);
estr_write ("\n");
- exit (2);
+ exit_error (2);
}
iexport(generate_error);
estr_write ("Fortran runtime error: ");
estr_write (message);
estr_write ("\n");
- exit (2);
+ exit_error (2);
}
else
{