From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18354 invoked by alias); 4 Nov 2004 23:06:01 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 18345 invoked from network); 4 Nov 2004 23:06:00 -0000 Received: from unknown (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org with SMTP; 4 Nov 2004 23:06:00 -0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.12.11/8.12.11) with ESMTP id iA4N60gR019712 for ; Thu, 4 Nov 2004 18:06:00 -0500 Received: from pobox.toronto.redhat.com (pobox.toronto.redhat.com [172.16.14.4]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id iA4N5xr23636; Thu, 4 Nov 2004 18:05:59 -0500 Received: from touchme.toronto.redhat.com (IDENT:postfix@touchme.toronto.redhat.com [172.16.14.9]) by pobox.toronto.redhat.com (8.12.8/8.12.8) with ESMTP id iA4N5xbU002267; Thu, 4 Nov 2004 18:05:59 -0500 Received: from redhat.com (toocool.toronto.redhat.com [172.16.14.72]) by touchme.toronto.redhat.com (Postfix) with ESMTP id 66F2780002E; Thu, 4 Nov 2004 18:05:59 -0500 (EST) Message-ID: <418AB5D7.2070908@redhat.com> Date: Thu, 04 Nov 2004 23:06:00 -0000 From: Jeff Johnston User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 MIME-Version: 1.0 To: Andrew Cagney Cc: Joel Brobecker , gdb-patches@sources.redhat.com Subject: Re: [RFA]: issue warnings for frame offenses References: <417EBFF9.5060104@redhat.com> <20041026213037.GR1039@gnat.com> <41897333.6070201@gnu.org> In-Reply-To: <41897333.6070201@gnu.org> Content-Type: multipart/mixed; boundary="------------020004010906080205000400" X-SW-Source: 2004-11/txt/msg00072.txt.bz2 This is a multi-part message in MIME format. --------------020004010906080205000400 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Content-length: 1026 Andrew, The following updated patch implements your suggestion of having a new error routine that throw RETURN_QUIT. The backtrace command is now protected with a catch_errors call. I did not change other existing calls to catch_errors to use RETURN_MASK_ERROR instead of RETURN_MASK_ALL. Ok or is there something I have missed? -- Jeff J. 2004-11-04 Jeff Johnston * defs.h (fatal_error, vfatal_error): New function prototypes. * stack.c (backtrace_command_stub): Stub to call backtrace_command_1 via catch_errors. (backtrace_command): Change to call backtrace_command_stub via catch_errors instead of calling backtrace_command_1 directly. (backtrace_full_command): Ditto. * utils.c (error_stream_1): New static function. (verror): Change to call error_stream_1 instead of error_stream. (error_stream): Call error_stream_1 with RETURN_ERROR argument. (vfatal_error, fatal_error): New functions. --------------020004010906080205000400 Content-Type: text/plain; name="backtrace.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="backtrace.patch" Content-length: 5003 Index: defs.h =================================================================== RCS file: /cvs/src/src/gdb/defs.h,v retrieving revision 1.170 diff -u -p -r1.170 defs.h --- defs.h 12 Oct 2004 10:06:14 -0000 1.170 +++ defs.h 4 Nov 2004 22:55:02 -0000 @@ -911,6 +911,10 @@ extern char *error_last_message (void); /* Output arbitrary error message. */ extern void error_output_message (char *pre_print, char *msg); +extern NORETURN void vfatal_error (const char *fmt, va_list ap) ATTR_NORETURN; + +extern NORETURN void fatal_error (const char *fmt, ...) ATTR_NORETURN ATTR_FORMAT (printf, 1, 2); + extern NORETURN void internal_verror (const char *file, int line, const char *, va_list ap) ATTR_NORETURN; Index: stack.c =================================================================== RCS file: /cvs/src/src/gdb/stack.c,v retrieving revision 1.115 diff -u -p -r1.115 stack.c --- stack.c 30 Oct 2004 21:16:10 -0000 1.115 +++ stack.c 4 Nov 2004 22:55:03 -0000 @@ -1204,6 +1204,22 @@ backtrace_command_1 (char *count_exp, in printf_filtered ("(More stack frames follow...)\n"); } +struct backtrace_command_args + { + char *count_exp; + int show_locals; + int from_tty; + }; + +/* Stub to call backtrace_command_1 by way of an error catcher. */ +static int +backtrace_command_stub (void *data) +{ + struct backtrace_command_args *args = (struct backtrace_command_args *)data; + backtrace_command_1 (args->count_exp, args->show_locals, args->from_tty); + return 0; +} + static void backtrace_command (char *arg, int from_tty) { @@ -1211,6 +1227,7 @@ backtrace_command (char *arg, int from_t char **argv = (char **) NULL; int argIndicatingFullTrace = (-1), totArgLen = 0, argc = 0; char *argPtr = arg; + struct backtrace_command_args btargs; if (arg != (char *) NULL) { @@ -1260,7 +1277,10 @@ backtrace_command (char *arg, int from_t } } - backtrace_command_1 (argPtr, (argIndicatingFullTrace >= 0), from_tty); + btargs.count_exp = argPtr; + btargs.show_locals = (argIndicatingFullTrace >= 0); + btargs.from_tty = from_tty; + catch_errors (backtrace_command_stub, (char *)&btargs, "", RETURN_MASK_ERROR); if (argIndicatingFullTrace >= 0 && totArgLen > 0) xfree (argPtr); @@ -1273,7 +1293,11 @@ static void backtrace_full_command (char static void backtrace_full_command (char *arg, int from_tty) { - backtrace_command_1 (arg, 1, from_tty); + struct backtrace_command_args btargs; + btargs.count_exp = arg; + btargs.show_locals = 1; + btargs.from_tty = from_tty; + catch_errors (backtrace_command_stub, (char *)&btargs, "", RETURN_MASK_ERROR); } Index: utils.c =================================================================== RCS file: /cvs/src/src/gdb/utils.c,v retrieving revision 1.137 diff -u -p -r1.137 utils.c --- utils.c 30 Sep 2004 19:57:54 -0000 1.137 +++ utils.c 4 Nov 2004 22:55:03 -0000 @@ -104,6 +104,9 @@ static void prompt_for_continue (void); static void set_screen_size (void); static void set_width (void); +static NORETURN void error_stream_1 (struct ui_file *stream, + enum return_reason reason) ATTR_NORETURN; + /* Chain of cleanup actions established with make_cleanup, to be executed if an error happens. */ @@ -620,7 +623,7 @@ verror (const char *string, va_list args struct ui_file *tmp_stream = mem_fileopen (); make_cleanup_ui_file_delete (tmp_stream); vfprintf_unfiltered (tmp_stream, string, args); - error_stream (tmp_stream); + error_stream_1 (tmp_stream, RETURN_ERROR); } NORETURN void @@ -632,6 +635,28 @@ error (const char *string, ...) va_end (args); } +/* Print an error message and quit. + The first argument STRING is the error message, used as a fprintf string, + and the remaining args are passed as arguments to it. */ + +NORETURN void +vfatal_error (const char *string, va_list args) +{ + struct ui_file *tmp_stream = mem_fileopen (); + make_cleanup_ui_file_delete (tmp_stream); + vfprintf_unfiltered (tmp_stream, string, args); + error_stream_1 (tmp_stream, RETURN_QUIT); +} + +NORETURN void +fatal_error (const char *string, ...) +{ + va_list args; + va_start (args, string); + vfatal_error (string, args); + va_end (args); +} + static void do_write (void *data, const char *buffer, long length_buffer) { @@ -670,8 +695,8 @@ error_output_message (char *pre_print, c fprintf_filtered (gdb_stderr, "\n"); } -NORETURN void -error_stream (struct ui_file *stream) +static NORETURN void +error_stream_1 (struct ui_file *stream, enum return_reason reason) { if (deprecated_error_begin_hook) deprecated_error_begin_hook (); @@ -690,7 +715,13 @@ error_stream (struct ui_file *stream) ui_file_put (stream, do_write, gdb_stderr); fprintf_filtered (gdb_stderr, "\n"); - throw_exception (RETURN_ERROR); + throw_exception (reason); +} + +NORETURN void +error_stream (struct ui_file *stream) +{ + error_stream_1 (stream, RETURN_ERROR); } /* Get the last error message issued by gdb */ --------------020004010906080205000400--