From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21680 invoked by alias); 18 Dec 2003 21:42:04 -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 21673 invoked from network); 18 Dec 2003 21:42:03 -0000 Received: from unknown (HELO touchme.toronto.redhat.com) (207.219.125.105) by sources.redhat.com with SMTP; 18 Dec 2003 21:42:03 -0000 Received: from redhat.com (toocool.toronto.redhat.com [172.16.14.72]) by touchme.toronto.redhat.com (Postfix) with ESMTP id 5F1AF80018E; Thu, 18 Dec 2003 16:42:03 -0500 (EST) Message-ID: <3FE21F2B.3030104@redhat.com> Date: Thu, 18 Dec 2003 21:42: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: gdb-patches@sources.redhat.com Cc: Elena Zannoni Subject: [RFA]: error_silent for use in pending breakpoint support Content-Type: multipart/mixed; boundary="------------040700080503090608070805" X-SW-Source: 2003-12/txt/msg00437.txt.bz2 This is a multi-part message in MIME format. --------------040700080503090608070805 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 1149 To properly support pending breakpoints, gdb needs to be able to suppress the "not found" messages at will, but it also needs to sometimes issue these messages and determine the cause of the error was a "not found" event. To handle the problem, I propose two new useful functions in utils.c. The first is error_silent() which works just like error(), only it does not issue the error message. Like error(), it stores the error message in gdb_lasterr. This leads to the other new function: error_last_output() which is used to output the last error message. This allows the pending breakpoint support to issue the error message when the user is doing the initial break command and to suppress it when shared libraries are being loaded or a pending breakpoint is reenabled. Ok to commit? 2003-12-18 Jeff Johnston * linespec.c (decode_variable, symtab_from_filename): Call error_silent with error message instead of throwing an exception directly. * defs.h (error_silent, error_last_output): Add prototypes. * utils.c (error_silent, error_last_output): New functions. --------------040700080503090608070805 Content-Type: text/plain; name="error_silent.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="error_silent.patch" Content-length: 3202 Index: defs.h =================================================================== RCS file: /cvs/src/src/gdb/defs.h,v retrieving revision 1.135 diff -u -p -r1.135 defs.h --- defs.h 7 Dec 2003 17:22:29 -0000 1.135 +++ defs.h 18 Dec 2003 21:25:08 -0000 @@ -912,6 +912,8 @@ extern NORETURN void verror (const char extern NORETURN void error (const char *fmt, ...) ATTR_NORETURN ATTR_FORMAT (printf, 1, 2); +extern NORETURN void error_silent (const char *fmt, ...) ATTR_NORETURN ATTR_FORMAT (printf, 1, 2); + extern NORETURN void error_stream (struct ui_file *) ATTR_NORETURN; /* Initialize the error buffer. */ @@ -920,6 +922,9 @@ extern void error_init (void); /* Returns a freshly allocate buffer containing the last error message. */ extern char *error_last_message (void); + +/* Output last error message. */ +extern void error_last_output (void); extern NORETURN void internal_verror (const char *file, int line, const char *, va_list ap) ATTR_NORETURN; Index: utils.c =================================================================== RCS file: /cvs/src/src/gdb/utils.c,v retrieving revision 1.110 diff -u -p -r1.110 utils.c --- utils.c 21 Sep 2003 01:26:45 -0000 1.110 +++ utils.c 18 Dec 2003 21:25:08 -0000 @@ -626,6 +626,38 @@ do_write (void *data, const char *buffer ui_file_write (data, buffer, length_buffer); } +/* Cause a silent error to occur. Any error message is recorded + though it is not issued. */ +NORETURN void +error_silent (const char *string, ...) +{ + va_list args; + struct ui_file *tmp_stream = mem_fileopen (); + va_start (args, string); + make_cleanup_ui_file_delete (tmp_stream); + vfprintf_unfiltered (tmp_stream, string, args); + /* Copy the stream into the GDB_LASTERR buffer. */ + ui_file_rewind (gdb_lasterr); + ui_file_put (tmp_stream, do_write, gdb_lasterr); + va_end (args); + + throw_exception (RETURN_ERROR); +} + +/* Output the last error message plus any error_pre_print to gdb_stderr. */ +void +error_last_output (void) +{ + target_terminal_ours (); + wrap_here (""); /* Force out any buffered output */ + gdb_flush (gdb_stdout); + annotate_error_begin (); + if (error_pre_print) + fputs_filtered (error_pre_print, gdb_stderr); + ui_file_put (gdb_lasterr, do_write, gdb_stderr); + fprintf_filtered (gdb_stderr, "\n"); +} + NORETURN void error_stream (struct ui_file *stream) { Index: linespec.c =================================================================== RCS file: /cvs/src/src/gdb/linespec.c,v retrieving revision 1.53 diff -u -p -r1.53 linespec.c --- linespec.c 17 Dec 2003 21:47:47 -0000 1.53 +++ linespec.c 18 Dec 2003 21:25:08 -0000 @@ -1469,7 +1469,7 @@ symtab_from_filename (char **argptr, cha if (not_found_ptr) { *not_found_ptr = 1; - throw_exception (RETURN_ERROR); + error_silent ("No source file named %s.", copy); } error ("No source file named %s.", copy); } @@ -1684,7 +1684,7 @@ decode_variable (char *copy, int funfirs if (not_found_ptr) { *not_found_ptr = 1; - throw_exception (RETURN_ERROR); + error_silent ("Function \"%s\" not defined.", copy); } error ("Function \"%s\" not defined.", copy); --------------040700080503090608070805--