2016-01-04 15:30:50 +01:00
|
|
|
/* Copyright (C) 2006-2016 Free Software Foundation, Inc.
|
gfortran.h (gfc_option_t): Add flag_backtrace field.
* gfortran.h (gfc_option_t): Add flag_backtrace field.
* lang.opt: Add -fbacktrace option.
* invoke.texi: Document the new option.
* trans-decl.c (gfc_build_builtin_function_decls): Add new
option to the call to set_std.
* options.c (gfc_init_options, gfc_handle_option): Handle the
new option.
* runtime/backtrace.c: New file.
* runtime/environ.c (variable_table): New GFORTRAN_ERROR_BACKTRACE
environment variable.
* runtime/compile_options.c (set_std): Add new argument.
* runtime/main.c (store_exe_path, full_exe_path): New functions.
* runtime/error.c (sys_exit): Add call to show_backtrace.
* libgfortran.h (options_t): New backtrace field.
(store_exe_path, full_exe_path, show_backtrace): New prototypes.
* configure.ac: Add checks for execinfo.h, execvp, pipe, dup2,
close, fdopen, strcasestr, getrlimit, backtrace, backtrace_symbols
and getppid.
* Makefile.am: Add runtime/backtrace.c.
* fmain.c (main): Add call to store_exe_path.
* Makefile.in: Renegerate.
* config.h.in: Renegerate.
* configure: Regenerate.
From-SVN: r122954
2007-03-15 13:39:47 +01:00
|
|
|
Contributed by François-Xavier Coudert
|
|
|
|
|
2011-04-16 19:43:03 +02:00
|
|
|
This file is part of the GNU Fortran runtime library (libgfortran).
|
gfortran.h (gfc_option_t): Add flag_backtrace field.
* gfortran.h (gfc_option_t): Add flag_backtrace field.
* lang.opt: Add -fbacktrace option.
* invoke.texi: Document the new option.
* trans-decl.c (gfc_build_builtin_function_decls): Add new
option to the call to set_std.
* options.c (gfc_init_options, gfc_handle_option): Handle the
new option.
* runtime/backtrace.c: New file.
* runtime/environ.c (variable_table): New GFORTRAN_ERROR_BACKTRACE
environment variable.
* runtime/compile_options.c (set_std): Add new argument.
* runtime/main.c (store_exe_path, full_exe_path): New functions.
* runtime/error.c (sys_exit): Add call to show_backtrace.
* libgfortran.h (options_t): New backtrace field.
(store_exe_path, full_exe_path, show_backtrace): New prototypes.
* configure.ac: Add checks for execinfo.h, execvp, pipe, dup2,
close, fdopen, strcasestr, getrlimit, backtrace, backtrace_symbols
and getppid.
* Makefile.am: Add runtime/backtrace.c.
* fmain.c (main): Add call to store_exe_path.
* Makefile.in: Renegerate.
* config.h.in: Renegerate.
* configure: Regenerate.
From-SVN: r122954
2007-03-15 13:39:47 +01:00
|
|
|
|
|
|
|
Libgfortran is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
2009-04-09 17:00:19 +02:00
|
|
|
the Free Software Foundation; either version 3, or (at your option)
|
gfortran.h (gfc_option_t): Add flag_backtrace field.
* gfortran.h (gfc_option_t): Add flag_backtrace field.
* lang.opt: Add -fbacktrace option.
* invoke.texi: Document the new option.
* trans-decl.c (gfc_build_builtin_function_decls): Add new
option to the call to set_std.
* options.c (gfc_init_options, gfc_handle_option): Handle the
new option.
* runtime/backtrace.c: New file.
* runtime/environ.c (variable_table): New GFORTRAN_ERROR_BACKTRACE
environment variable.
* runtime/compile_options.c (set_std): Add new argument.
* runtime/main.c (store_exe_path, full_exe_path): New functions.
* runtime/error.c (sys_exit): Add call to show_backtrace.
* libgfortran.h (options_t): New backtrace field.
(store_exe_path, full_exe_path, show_backtrace): New prototypes.
* configure.ac: Add checks for execinfo.h, execvp, pipe, dup2,
close, fdopen, strcasestr, getrlimit, backtrace, backtrace_symbols
and getppid.
* Makefile.am: Add runtime/backtrace.c.
* fmain.c (main): Add call to store_exe_path.
* Makefile.in: Renegerate.
* config.h.in: Renegerate.
* configure: Regenerate.
From-SVN: r122954
2007-03-15 13:39:47 +01:00
|
|
|
any later version.
|
|
|
|
|
|
|
|
Libgfortran is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
2009-04-09 17:00:19 +02:00
|
|
|
Under Section 7 of GPL version 3, you are granted additional
|
|
|
|
permissions described in the GCC Runtime Library Exception, version
|
|
|
|
3.1, as published by the Free Software Foundation.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License and
|
|
|
|
a copy of the GCC Runtime Library Exception along with this program;
|
|
|
|
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
|
|
|
<http://www.gnu.org/licenses/>. */
|
gfortran.h (gfc_option_t): Add flag_backtrace field.
* gfortran.h (gfc_option_t): Add flag_backtrace field.
* lang.opt: Add -fbacktrace option.
* invoke.texi: Document the new option.
* trans-decl.c (gfc_build_builtin_function_decls): Add new
option to the call to set_std.
* options.c (gfc_init_options, gfc_handle_option): Handle the
new option.
* runtime/backtrace.c: New file.
* runtime/environ.c (variable_table): New GFORTRAN_ERROR_BACKTRACE
environment variable.
* runtime/compile_options.c (set_std): Add new argument.
* runtime/main.c (store_exe_path, full_exe_path): New functions.
* runtime/error.c (sys_exit): Add call to show_backtrace.
* libgfortran.h (options_t): New backtrace field.
(store_exe_path, full_exe_path, show_backtrace): New prototypes.
* configure.ac: Add checks for execinfo.h, execvp, pipe, dup2,
close, fdopen, strcasestr, getrlimit, backtrace, backtrace_symbols
and getppid.
* Makefile.am: Add runtime/backtrace.c.
* fmain.c (main): Add call to store_exe_path.
* Makefile.in: Renegerate.
* config.h.in: Renegerate.
* configure: Regenerate.
From-SVN: r122954
2007-03-15 13:39:47 +01:00
|
|
|
|
2007-08-31 16:01:34 +02:00
|
|
|
#include "libgfortran.h"
|
gfortran.h (gfc_option_t): Add flag_backtrace field.
* gfortran.h (gfc_option_t): Add flag_backtrace field.
* lang.opt: Add -fbacktrace option.
* invoke.texi: Document the new option.
* trans-decl.c (gfc_build_builtin_function_decls): Add new
option to the call to set_std.
* options.c (gfc_init_options, gfc_handle_option): Handle the
new option.
* runtime/backtrace.c: New file.
* runtime/environ.c (variable_table): New GFORTRAN_ERROR_BACKTRACE
environment variable.
* runtime/compile_options.c (set_std): Add new argument.
* runtime/main.c (store_exe_path, full_exe_path): New functions.
* runtime/error.c (sys_exit): Add call to show_backtrace.
* libgfortran.h (options_t): New backtrace field.
(store_exe_path, full_exe_path, show_backtrace): New prototypes.
* configure.ac: Add checks for execinfo.h, execvp, pipe, dup2,
close, fdopen, strcasestr, getrlimit, backtrace, backtrace_symbols
and getppid.
* Makefile.am: Add runtime/backtrace.c.
* fmain.c (main): Add call to store_exe_path.
* Makefile.in: Renegerate.
* config.h.in: Renegerate.
* configure: Regenerate.
From-SVN: r122954
2007-03-15 13:39:47 +01:00
|
|
|
|
2016-01-24 00:32:13 +01:00
|
|
|
#include <gthr.h>
|
|
|
|
|
gfortran.h (gfc_option_t): Add flag_backtrace field.
* gfortran.h (gfc_option_t): Add flag_backtrace field.
* lang.opt: Add -fbacktrace option.
* invoke.texi: Document the new option.
* trans-decl.c (gfc_build_builtin_function_decls): Add new
option to the call to set_std.
* options.c (gfc_init_options, gfc_handle_option): Handle the
new option.
* runtime/backtrace.c: New file.
* runtime/environ.c (variable_table): New GFORTRAN_ERROR_BACKTRACE
environment variable.
* runtime/compile_options.c (set_std): Add new argument.
* runtime/main.c (store_exe_path, full_exe_path): New functions.
* runtime/error.c (sys_exit): Add call to show_backtrace.
* libgfortran.h (options_t): New backtrace field.
(store_exe_path, full_exe_path, show_backtrace): New prototypes.
* configure.ac: Add checks for execinfo.h, execvp, pipe, dup2,
close, fdopen, strcasestr, getrlimit, backtrace, backtrace_symbols
and getppid.
* Makefile.am: Add runtime/backtrace.c.
* fmain.c (main): Add call to store_exe_path.
* Makefile.in: Renegerate.
* config.h.in: Renegerate.
* configure: Regenerate.
From-SVN: r122954
2007-03-15 13:39:47 +01:00
|
|
|
#include <string.h>
|
2011-11-09 19:25:58 +01:00
|
|
|
#include <stdlib.h>
|
2015-09-02 16:51:40 +02:00
|
|
|
#include <errno.h>
|
gfortran.h (gfc_option_t): Add flag_backtrace field.
* gfortran.h (gfc_option_t): Add flag_backtrace field.
* lang.opt: Add -fbacktrace option.
* invoke.texi: Document the new option.
* trans-decl.c (gfc_build_builtin_function_decls): Add new
option to the call to set_std.
* options.c (gfc_init_options, gfc_handle_option): Handle the
new option.
* runtime/backtrace.c: New file.
* runtime/environ.c (variable_table): New GFORTRAN_ERROR_BACKTRACE
environment variable.
* runtime/compile_options.c (set_std): Add new argument.
* runtime/main.c (store_exe_path, full_exe_path): New functions.
* runtime/error.c (sys_exit): Add call to show_backtrace.
* libgfortran.h (options_t): New backtrace field.
(store_exe_path, full_exe_path, show_backtrace): New prototypes.
* configure.ac: Add checks for execinfo.h, execvp, pipe, dup2,
close, fdopen, strcasestr, getrlimit, backtrace, backtrace_symbols
and getppid.
* Makefile.am: Add runtime/backtrace.c.
* fmain.c (main): Add call to store_exe_path.
* Makefile.in: Renegerate.
* config.h.in: Renegerate.
* configure: Regenerate.
From-SVN: r122954
2007-03-15 13:39:47 +01:00
|
|
|
|
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
#include <unistd.h>
|
|
|
|
#endif
|
|
|
|
|
2015-08-23 23:50:30 +02:00
|
|
|
#include "backtrace-supported.h"
|
|
|
|
#include "backtrace.h"
|
gfortran.h (gfc_option_t): Add flag_backtrace field.
* gfortran.h (gfc_option_t): Add flag_backtrace field.
* lang.opt: Add -fbacktrace option.
* invoke.texi: Document the new option.
* trans-decl.c (gfc_build_builtin_function_decls): Add new
option to the call to set_std.
* options.c (gfc_init_options, gfc_handle_option): Handle the
new option.
* runtime/backtrace.c: New file.
* runtime/environ.c (variable_table): New GFORTRAN_ERROR_BACKTRACE
environment variable.
* runtime/compile_options.c (set_std): Add new argument.
* runtime/main.c (store_exe_path, full_exe_path): New functions.
* runtime/error.c (sys_exit): Add call to show_backtrace.
* libgfortran.h (options_t): New backtrace field.
(store_exe_path, full_exe_path, show_backtrace): New prototypes.
* configure.ac: Add checks for execinfo.h, execvp, pipe, dup2,
close, fdopen, strcasestr, getrlimit, backtrace, backtrace_symbols
and getppid.
* Makefile.am: Add runtime/backtrace.c.
* fmain.c (main): Add call to store_exe_path.
* Makefile.in: Renegerate.
* config.h.in: Renegerate.
* configure: Regenerate.
From-SVN: r122954
2007-03-15 13:39:47 +01:00
|
|
|
|
|
|
|
|
2015-08-23 23:50:30 +02:00
|
|
|
/* Store our own state while backtracing. */
|
|
|
|
struct mystate
|
|
|
|
{
|
|
|
|
int frame;
|
2015-09-02 16:51:40 +02:00
|
|
|
bool try_simple;
|
|
|
|
bool in_signal_handler;
|
2015-08-23 23:50:30 +02:00
|
|
|
};
|
2011-11-09 17:04:42 +01:00
|
|
|
|
2007-10-18 23:25:21 +02:00
|
|
|
|
2015-08-23 23:50:30 +02:00
|
|
|
/* Does a function name have "_gfortran_" or "_gfortrani_" prefix, possibly
|
|
|
|
with additional underscore(s) at the beginning? Cannot use strncmp()
|
|
|
|
because we might be called from a signal handler. */
|
2007-06-25 19:21:46 +02:00
|
|
|
|
2015-08-23 23:50:30 +02:00
|
|
|
static int
|
|
|
|
has_gfortran_prefix (const char *s)
|
2011-05-22 18:38:05 +02:00
|
|
|
{
|
2015-08-23 23:50:30 +02:00
|
|
|
if (!s)
|
|
|
|
return 0;
|
gfortran.h (gfc_option_t): Add flag_backtrace field.
* gfortran.h (gfc_option_t): Add flag_backtrace field.
* lang.opt: Add -fbacktrace option.
* invoke.texi: Document the new option.
* trans-decl.c (gfc_build_builtin_function_decls): Add new
option to the call to set_std.
* options.c (gfc_init_options, gfc_handle_option): Handle the
new option.
* runtime/backtrace.c: New file.
* runtime/environ.c (variable_table): New GFORTRAN_ERROR_BACKTRACE
environment variable.
* runtime/compile_options.c (set_std): Add new argument.
* runtime/main.c (store_exe_path, full_exe_path): New functions.
* runtime/error.c (sys_exit): Add call to show_backtrace.
* libgfortran.h (options_t): New backtrace field.
(store_exe_path, full_exe_path, show_backtrace): New prototypes.
* configure.ac: Add checks for execinfo.h, execvp, pipe, dup2,
close, fdopen, strcasestr, getrlimit, backtrace, backtrace_symbols
and getppid.
* Makefile.am: Add runtime/backtrace.c.
* fmain.c (main): Add call to store_exe_path.
* Makefile.in: Renegerate.
* config.h.in: Renegerate.
* configure: Regenerate.
From-SVN: r122954
2007-03-15 13:39:47 +01:00
|
|
|
|
2015-08-23 23:50:30 +02:00
|
|
|
while (*s == '_')
|
|
|
|
s++;
|
gfortran.h (gfc_option_t): Add flag_backtrace field.
* gfortran.h (gfc_option_t): Add flag_backtrace field.
* lang.opt: Add -fbacktrace option.
* invoke.texi: Document the new option.
* trans-decl.c (gfc_build_builtin_function_decls): Add new
option to the call to set_std.
* options.c (gfc_init_options, gfc_handle_option): Handle the
new option.
* runtime/backtrace.c: New file.
* runtime/environ.c (variable_table): New GFORTRAN_ERROR_BACKTRACE
environment variable.
* runtime/compile_options.c (set_std): Add new argument.
* runtime/main.c (store_exe_path, full_exe_path): New functions.
* runtime/error.c (sys_exit): Add call to show_backtrace.
* libgfortran.h (options_t): New backtrace field.
(store_exe_path, full_exe_path, show_backtrace): New prototypes.
* configure.ac: Add checks for execinfo.h, execvp, pipe, dup2,
close, fdopen, strcasestr, getrlimit, backtrace, backtrace_symbols
and getppid.
* Makefile.am: Add runtime/backtrace.c.
* fmain.c (main): Add call to store_exe_path.
* Makefile.in: Renegerate.
* config.h.in: Renegerate.
* configure: Regenerate.
From-SVN: r122954
2007-03-15 13:39:47 +01:00
|
|
|
|
2015-08-23 23:50:30 +02:00
|
|
|
return (s[0] == 'g' && s[1] == 'f' && s[2] == 'o' && s[3] == 'r'
|
|
|
|
&& s[4] == 't' && s[5] == 'r' && s[6] == 'a' && s[7] == 'n'
|
|
|
|
&& (s[8] == '_' || (s[8] == 'i' && s[9] == '_')));
|
|
|
|
}
|
gfortran.h (gfc_option_t): Add flag_backtrace field.
* gfortran.h (gfc_option_t): Add flag_backtrace field.
* lang.opt: Add -fbacktrace option.
* invoke.texi: Document the new option.
* trans-decl.c (gfc_build_builtin_function_decls): Add new
option to the call to set_std.
* options.c (gfc_init_options, gfc_handle_option): Handle the
new option.
* runtime/backtrace.c: New file.
* runtime/environ.c (variable_table): New GFORTRAN_ERROR_BACKTRACE
environment variable.
* runtime/compile_options.c (set_std): Add new argument.
* runtime/main.c (store_exe_path, full_exe_path): New functions.
* runtime/error.c (sys_exit): Add call to show_backtrace.
* libgfortran.h (options_t): New backtrace field.
(store_exe_path, full_exe_path, show_backtrace): New prototypes.
* configure.ac: Add checks for execinfo.h, execvp, pipe, dup2,
close, fdopen, strcasestr, getrlimit, backtrace, backtrace_symbols
and getppid.
* Makefile.am: Add runtime/backtrace.c.
* fmain.c (main): Add call to store_exe_path.
* Makefile.in: Renegerate.
* config.h.in: Renegerate.
* configure: Regenerate.
From-SVN: r122954
2007-03-15 13:39:47 +01:00
|
|
|
|
2015-08-23 23:50:30 +02:00
|
|
|
static void
|
|
|
|
error_callback (void *data, const char *msg, int errnum)
|
2011-05-22 18:38:05 +02:00
|
|
|
{
|
2015-08-23 23:50:30 +02:00
|
|
|
struct mystate *state = (struct mystate *) data;
|
2015-09-02 16:51:40 +02:00
|
|
|
#define ERRHDR "\nCould not print backtrace: "
|
|
|
|
|
2015-08-23 23:50:30 +02:00
|
|
|
if (errnum < 0)
|
2011-05-14 09:55:51 +02:00
|
|
|
{
|
2015-09-02 16:51:40 +02:00
|
|
|
state->try_simple = true;
|
2015-08-23 23:50:30 +02:00
|
|
|
return;
|
2011-05-14 09:55:51 +02:00
|
|
|
}
|
2015-09-02 16:51:40 +02:00
|
|
|
else if (errnum == 0)
|
|
|
|
{
|
|
|
|
estr_write (ERRHDR);
|
|
|
|
estr_write (msg);
|
|
|
|
estr_write ("\n");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
char errbuf[256];
|
|
|
|
if (state->in_signal_handler)
|
|
|
|
{
|
|
|
|
estr_write (ERRHDR);
|
|
|
|
estr_write (msg);
|
|
|
|
estr_write (", errno: ");
|
|
|
|
const char *p = gfc_itoa (errnum, errbuf, sizeof (errbuf));
|
|
|
|
estr_write (p);
|
|
|
|
estr_write ("\n");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
st_printf (ERRHDR "%s: %s\n", msg,
|
|
|
|
gf_strerror (errnum, errbuf, sizeof (errbuf)));
|
|
|
|
}
|
2015-08-23 23:50:30 +02:00
|
|
|
}
|
gfortran.h (gfc_option_t): Add flag_backtrace field.
* gfortran.h (gfc_option_t): Add flag_backtrace field.
* lang.opt: Add -fbacktrace option.
* invoke.texi: Document the new option.
* trans-decl.c (gfc_build_builtin_function_decls): Add new
option to the call to set_std.
* options.c (gfc_init_options, gfc_handle_option): Handle the
new option.
* runtime/backtrace.c: New file.
* runtime/environ.c (variable_table): New GFORTRAN_ERROR_BACKTRACE
environment variable.
* runtime/compile_options.c (set_std): Add new argument.
* runtime/main.c (store_exe_path, full_exe_path): New functions.
* runtime/error.c (sys_exit): Add call to show_backtrace.
* libgfortran.h (options_t): New backtrace field.
(store_exe_path, full_exe_path, show_backtrace): New prototypes.
* configure.ac: Add checks for execinfo.h, execvp, pipe, dup2,
close, fdopen, strcasestr, getrlimit, backtrace, backtrace_symbols
and getppid.
* Makefile.am: Add runtime/backtrace.c.
* fmain.c (main): Add call to store_exe_path.
* Makefile.in: Renegerate.
* config.h.in: Renegerate.
* configure: Regenerate.
From-SVN: r122954
2007-03-15 13:39:47 +01:00
|
|
|
|
2015-08-23 23:50:30 +02:00
|
|
|
static int
|
|
|
|
simple_callback (void *data, uintptr_t pc)
|
|
|
|
{
|
|
|
|
struct mystate *state = (struct mystate *) data;
|
|
|
|
st_printf ("#%d 0x%lx\n", state->frame, (unsigned long) pc);
|
|
|
|
(state->frame)++;
|
|
|
|
return 0;
|
|
|
|
}
|
2011-05-29 22:13:52 +02:00
|
|
|
|
2015-08-23 23:50:30 +02:00
|
|
|
static int
|
|
|
|
full_callback (void *data, uintptr_t pc, const char *filename,
|
|
|
|
int lineno, const char *function)
|
2011-11-09 17:04:42 +01:00
|
|
|
{
|
2015-08-23 23:50:30 +02:00
|
|
|
struct mystate *state = (struct mystate *) data;
|
|
|
|
|
|
|
|
if (has_gfortran_prefix (function))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
st_printf ("#%d 0x%lx in %s\n", state->frame,
|
|
|
|
(unsigned long) pc, function == NULL ? "???" : function);
|
|
|
|
if (filename || lineno != 0)
|
|
|
|
st_printf ("\tat %s:%d\n", filename == NULL ? "???" : filename, lineno);
|
|
|
|
(state->frame)++;
|
|
|
|
|
|
|
|
if (function != NULL && strcmp (function, "main") == 0)
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
return 0;
|
2011-11-09 17:04:42 +01:00
|
|
|
}
|
2011-05-29 22:13:52 +02:00
|
|
|
|
2015-08-23 23:50:30 +02:00
|
|
|
|
|
|
|
/* Display the backtrace. */
|
|
|
|
|
|
|
|
void
|
2015-09-02 16:51:40 +02:00
|
|
|
show_backtrace (bool in_signal_handler)
|
2011-11-09 17:04:42 +01:00
|
|
|
{
|
2015-08-23 23:50:30 +02:00
|
|
|
struct backtrace_state *lbstate;
|
2015-09-02 16:51:40 +02:00
|
|
|
struct mystate state = { 0, false, in_signal_handler };
|
2015-08-23 23:50:30 +02:00
|
|
|
|
2016-01-24 00:32:13 +01:00
|
|
|
lbstate = backtrace_create_state (NULL, __gthread_active_p (),
|
|
|
|
error_callback, NULL);
|
|
|
|
|
|
|
|
if (lbstate == NULL)
|
|
|
|
return;
|
2011-11-09 17:04:42 +01:00
|
|
|
|
2015-08-23 23:50:30 +02:00
|
|
|
if (!BACKTRACE_SUPPORTED || (in_signal_handler && BACKTRACE_USES_MALLOC))
|
2011-11-09 17:04:42 +01:00
|
|
|
{
|
2015-08-23 23:50:30 +02:00
|
|
|
/* If symbolic backtrace is not supported on this target, or would
|
|
|
|
require malloc() and we are in a signal handler, go with a
|
|
|
|
simple backtrace. */
|
|
|
|
|
|
|
|
backtrace_simple (lbstate, 0, simple_callback, error_callback, &state);
|
2011-11-09 17:04:42 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-08-23 23:50:30 +02:00
|
|
|
/* libbacktrace uses mmap, which is safe to call from a signal handler
|
|
|
|
(in practice, if not in theory). Thus we can generate a symbolic
|
|
|
|
backtrace, if debug symbols are available. */
|
|
|
|
|
|
|
|
backtrace_full (lbstate, 0, full_callback, error_callback, &state);
|
|
|
|
if (state.try_simple)
|
|
|
|
backtrace_simple (lbstate, 0, simple_callback, error_callback, &state);
|
2011-11-09 17:04:42 +01:00
|
|
|
}
|
2015-08-23 23:50:30 +02:00
|
|
|
}
|
2011-11-09 17:04:42 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
2015-08-23 23:50:30 +02:00
|
|
|
/* Function called by the front-end translating the BACKTRACE intrinsic. */
|
2011-11-09 17:04:42 +01:00
|
|
|
|
2015-08-23 23:50:30 +02:00
|
|
|
extern void backtrace (void);
|
|
|
|
export_proto (backtrace);
|
2011-05-22 18:38:05 +02:00
|
|
|
|
gfortran.h (gfc_option_t): Add flag_backtrace field.
* gfortran.h (gfc_option_t): Add flag_backtrace field.
* lang.opt: Add -fbacktrace option.
* invoke.texi: Document the new option.
* trans-decl.c (gfc_build_builtin_function_decls): Add new
option to the call to set_std.
* options.c (gfc_init_options, gfc_handle_option): Handle the
new option.
* runtime/backtrace.c: New file.
* runtime/environ.c (variable_table): New GFORTRAN_ERROR_BACKTRACE
environment variable.
* runtime/compile_options.c (set_std): Add new argument.
* runtime/main.c (store_exe_path, full_exe_path): New functions.
* runtime/error.c (sys_exit): Add call to show_backtrace.
* libgfortran.h (options_t): New backtrace field.
(store_exe_path, full_exe_path, show_backtrace): New prototypes.
* configure.ac: Add checks for execinfo.h, execvp, pipe, dup2,
close, fdopen, strcasestr, getrlimit, backtrace, backtrace_symbols
and getppid.
* Makefile.am: Add runtime/backtrace.c.
* fmain.c (main): Add call to store_exe_path.
* Makefile.in: Renegerate.
* config.h.in: Renegerate.
* configure: Regenerate.
From-SVN: r122954
2007-03-15 13:39:47 +01:00
|
|
|
void
|
2012-12-20 19:15:13 +01:00
|
|
|
backtrace (void)
|
gfortran.h (gfc_option_t): Add flag_backtrace field.
* gfortran.h (gfc_option_t): Add flag_backtrace field.
* lang.opt: Add -fbacktrace option.
* invoke.texi: Document the new option.
* trans-decl.c (gfc_build_builtin_function_decls): Add new
option to the call to set_std.
* options.c (gfc_init_options, gfc_handle_option): Handle the
new option.
* runtime/backtrace.c: New file.
* runtime/environ.c (variable_table): New GFORTRAN_ERROR_BACKTRACE
environment variable.
* runtime/compile_options.c (set_std): Add new argument.
* runtime/main.c (store_exe_path, full_exe_path): New functions.
* runtime/error.c (sys_exit): Add call to show_backtrace.
* libgfortran.h (options_t): New backtrace field.
(store_exe_path, full_exe_path, show_backtrace): New prototypes.
* configure.ac: Add checks for execinfo.h, execvp, pipe, dup2,
close, fdopen, strcasestr, getrlimit, backtrace, backtrace_symbols
and getppid.
* Makefile.am: Add runtime/backtrace.c.
* fmain.c (main): Add call to store_exe_path.
* Makefile.in: Renegerate.
* config.h.in: Renegerate.
* configure: Regenerate.
From-SVN: r122954
2007-03-15 13:39:47 +01:00
|
|
|
{
|
2015-09-02 16:51:40 +02:00
|
|
|
show_backtrace (false);
|
gfortran.h (gfc_option_t): Add flag_backtrace field.
* gfortran.h (gfc_option_t): Add flag_backtrace field.
* lang.opt: Add -fbacktrace option.
* invoke.texi: Document the new option.
* trans-decl.c (gfc_build_builtin_function_decls): Add new
option to the call to set_std.
* options.c (gfc_init_options, gfc_handle_option): Handle the
new option.
* runtime/backtrace.c: New file.
* runtime/environ.c (variable_table): New GFORTRAN_ERROR_BACKTRACE
environment variable.
* runtime/compile_options.c (set_std): Add new argument.
* runtime/main.c (store_exe_path, full_exe_path): New functions.
* runtime/error.c (sys_exit): Add call to show_backtrace.
* libgfortran.h (options_t): New backtrace field.
(store_exe_path, full_exe_path, show_backtrace): New prototypes.
* configure.ac: Add checks for execinfo.h, execvp, pipe, dup2,
close, fdopen, strcasestr, getrlimit, backtrace, backtrace_symbols
and getppid.
* Makefile.am: Add runtime/backtrace.c.
* fmain.c (main): Add call to store_exe_path.
* Makefile.in: Renegerate.
* config.h.in: Renegerate.
* configure: Regenerate.
From-SVN: r122954
2007-03-15 13:39:47 +01:00
|
|
|
}
|
2015-08-23 23:50:30 +02:00
|
|
|
|