diff options
author | geoffk <geoffk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-02-12 01:05:47 +0000 |
---|---|---|
committer | geoffk <geoffk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-02-12 01:05:47 +0000 |
commit | 5f07bab078ec00fa479c9e5c522d321b43377b2b (patch) | |
tree | 4da9d6d58f72a28241619628a1b3f73d75b12303 /gcc | |
parent | 35cf5a4cf3b060ce2a46462f0daad527d8822baf (diff) | |
download | gcc-5f07bab078ec00fa479c9e5c522d321b43377b2b.tar.gz |
* diagnostic.c (real_abort): New.
(diagnostic_report_diagnostic): Call real_abort on error.
* diagnostic.h (diagnostic_abort_on_error): New.
(struct diagnostic_context): Add abort_on_error field.
* toplev.c (setup_core_dumping): New.
(decode_d_option): Handle 'H' case.
* doc/invoke.texi (Debugging Options): Document -dH.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@62753 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 10 | ||||
-rw-r--r-- | gcc/diagnostic.c | 13 | ||||
-rw-r--r-- | gcc/diagnostic.h | 11 | ||||
-rw-r--r-- | gcc/doc/invoke.texi | 3 | ||||
-rw-r--r-- | gcc/toplev.c | 27 |
5 files changed, 62 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 7190341a7f8..96d364e7c87 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,13 @@ +2003-02-11 Geoffrey Keating <geoffk@apple.com> + + * diagnostic.c (real_abort): New. + (diagnostic_report_diagnostic): Call real_abort on error. + * diagnostic.h (diagnostic_abort_on_error): New. + (struct diagnostic_context): Add abort_on_error field. + * toplev.c (setup_core_dumping): New. + (decode_d_option): Handle 'H' case. + * doc/invoke.texi (Debugging Options): Document -dH. + 2003-02-11 Nathanael Nerode <neroden@gcc.gnu.org> * Makefile.in: Remove pointless setting of CXXFLAGS for dejagnu diff --git a/gcc/diagnostic.c b/gcc/diagnostic.c index a192229bd59..21d78a95dc5 100644 --- a/gcc/diagnostic.c +++ b/gcc/diagnostic.c @@ -81,6 +81,7 @@ static void default_diagnostic_finalizer PARAMS ((diagnostic_context *, static void error_recursion PARAMS ((diagnostic_context *)) ATTRIBUTE_NORETURN; static bool text_specifies_location PARAMS ((text_info *, location_t *)); +static void real_abort PARAMS ((void)) ATTRIBUTE_NORETURN; extern int rtl_dump_and_exit; extern int warnings_are_errors; @@ -1283,6 +1284,8 @@ diagnostic_report_diagnostic (context, diagnostic) output_flush (&context->buffer); } + if (context->abort_on_error && diagnostic->kind <= DK_ERROR) + real_abort(); --context->lock; } @@ -1459,3 +1462,13 @@ warn_deprecated_use (node) warning ("type is deprecated"); } } + +/* Really call the system 'abort'. This has to go right at the end of + this file, so that there are no functions after it that call abort + and get the system abort instead of our macro. */ +#undef abort +static void +real_abort () +{ + abort (); +} diff --git a/gcc/diagnostic.h b/gcc/diagnostic.h index 2bb0f8af349..2c822fc1617 100644 --- a/gcc/diagnostic.h +++ b/gcc/diagnostic.h @@ -1,5 +1,5 @@ /* Various declarations for language-independent diagnostics subroutines. - Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc. + Copyright (C) 2000, 2001, 2002, 2003 Free Software Foundation, Inc. Contributed by Gabriel Dos Reis <gdr@codesourcery.com> This file is part of GCC. @@ -190,6 +190,9 @@ struct diagnostic_context message, usually displayed once per compiler run. */ bool warnings_are_errors_message; + /* True if we should raise a SIGABRT on errors. */ + bool abort_on_error; + /* This function is called before any message is printed out. It is responsible for preparing message prefix and such. For example, it might say: @@ -259,12 +262,16 @@ struct diagnostic_context #define diagnostic_set_last_module(DC) \ (DC)->last_module = input_file_stack_tick +/* Raise SIGABRT on any diagnostic of severity DK_ERROR or higher. */ +#define diagnostic_abort_on_error(DC) \ + (DC)->abort_on_error = true + /* This diagnostic_context is used by front-ends that directly output diagnostic messages without going through `error', `warning', and similar functions. */ extern diagnostic_context *global_dc; -/* The total count of a KIND of diagnostics meitted so far. */ +/* The total count of a KIND of diagnostics emitted so far. */ #define diagnostic_kind_count(DC, DK) (DC)->diagnostic_count[(int) (DK)] /* The number of errors that have been issued so far. Ideally, these diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 6ebc5556fa9..0e0a0ea91a1 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -3216,6 +3216,9 @@ Dump after the peephole pass, to @file{@var{file}.27.peephole2}. @item a @opindex da Produce all the dumps listed above. +@item H +@opindex dH +Produce a core dump whenever an error occurs. @item m @opindex dm Print statistics on memory usage, at the end of the run, to diff --git a/gcc/toplev.c b/gcc/toplev.c index a4cd1df4588..38cff5b12d7 100644 --- a/gcc/toplev.c +++ b/gcc/toplev.c @@ -113,6 +113,7 @@ static void finalize PARAMS ((void)); static void set_target_switch PARAMS ((const char *)); static void crash_signal PARAMS ((int)) ATTRIBUTE_NORETURN; +static void setup_core_dumping PARAMS ((void)); static void compile_file PARAMS ((void)); static void display_help PARAMS ((void)); static void display_target_options PARAMS ((void)); @@ -1693,6 +1694,29 @@ crash_signal (signo) internal_error ("%s", strsignal (signo)); } +/* Arrange to dump core on error. (The regular error message is still + printed first, except in the case of abort().) */ + +static void +setup_core_dumping () +{ +#ifdef SIGABRT + signal (SIGABRT, SIG_DFL); +#endif +#if defined(HAVE_SETRLIMIT) + { + struct rlimit rlim; + if (getrlimit (RLIMIT_CORE, &rlim) != 0) + fatal_io_error ("getting core file size maximum limit"); + rlim.rlim_cur = rlim.rlim_max; + if (setrlimit (RLIMIT_CORE, &rlim) != 0) + fatal_io_error ("setting core file size limit to maximum"); + } +#endif + diagnostic_abort_on_error (global_dc); +} + + /* Strip off a legitimate source ending from the input string NAME of length LEN. Rather than having to know the names used by all of our front ends, we strip off an ending of a period followed by @@ -3953,6 +3977,9 @@ decode_d_option (arg) case 'D': /* These are handled by the preprocessor. */ case 'I': break; + case 'H': + setup_core_dumping(); + break; default: matched = 0; |