diff options
author | Jeff Johnston <jjohnstn@redhat.com> | 2004-01-20 02:04:19 +0000 |
---|---|---|
committer | Jeff Johnston <jjohnstn@redhat.com> | 2004-01-20 02:04:19 +0000 |
commit | 4fcef00ad0f7de5a38ce1431e9db564aa3508871 (patch) | |
tree | c6c24f8ed847db8e72d197e8dbaaab60bc0e84c3 /gdb | |
parent | 53a83a21c7ab484d1e5c3dec1ccb976cbeb50924 (diff) | |
download | gdb-4fcef00ad0f7de5a38ce1431e9db564aa3508871.zip gdb-4fcef00ad0f7de5a38ce1431e9db564aa3508871.tar.gz gdb-4fcef00ad0f7de5a38ce1431e9db564aa3508871.tar.bz2 |
2004-01-19 Jeff Johnston <jjohnstn@redhat.com>
* linespec.c (decode_variable, symtab_from_filename): Call
error_silent with error message instead of throwing an exception
directly.
* defs.h (error_silent, error_output_message): Add prototypes.
(catch_exceptions_with_msg): Ditto.
* utils.c (error_silent, error_output_message): New functions.
* top.c (catch_exceptions_with_msg): New function.
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/ChangeLog | 10 | ||||
-rw-r--r-- | gdb/defs.h | 17 | ||||
-rw-r--r-- | gdb/linespec.c | 20 | ||||
-rw-r--r-- | gdb/top.c | 33 | ||||
-rw-r--r-- | gdb/utils.c | 34 |
5 files changed, 106 insertions, 8 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 67668ea..753e1a8 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,13 @@ +2004-01-19 Jeff Johnston <jjohnstn@redhat.com> + + * linespec.c (decode_variable, symtab_from_filename): Call + error_silent with error message instead of throwing an exception + directly. + * defs.h (error_silent, error_output_message): Add prototypes. + (catch_exceptions_with_msg): Ditto. + * utils.c (error_silent, error_output_message): New functions. + * top.c (catch_exceptions_with_msg): New function. + 2004-01-20 Nick Roberts <nick@nick.uklinux.net> * mi/mi-cmds.h (enum print_values): Add definition. @@ -1,7 +1,7 @@ /* *INDENT-OFF* */ /* ATTR_FORMAT confuses indent, avoid running it for now */ /* Basic, host-specific, and target-specific definitions for GDB. Copyright 1986, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, - 1997, 1998, 1999, 2000, 2001, 2002, 2003 + 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. This file is part of GDB. @@ -911,6 +911,8 @@ extern NORETURN void verror (const char *fmt, va_list ap) ATTR_NORETURN; 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); message. */ extern char *error_last_message (void); +/* Output arbitrary error message. */ +extern void error_output_message (char *pre_print, char *msg); + extern NORETURN void internal_verror (const char *file, int line, const char *, va_list ap) ATTR_NORETURN; @@ -982,6 +987,11 @@ extern NORETURN void throw_exception (enum return_reason) ATTR_NORETURN; new cleanup_chain is established. The old values are restored before catch_exceptions() returns. + The variant catch_exceptions_with_msg() is the same as + catch_exceptions() but adds the ability to return an allocated + copy of the gdb error message. This is used when a silent error is + issued and the caller wants to manually issue the error message. + FIXME; cagney/2001-08-13: The need to override the global UIOUT builder variable should just go away. @@ -994,6 +1004,11 @@ typedef int (catch_exceptions_ftype) (struct ui_out *ui_out, void *args); extern int catch_exceptions (struct ui_out *uiout, catch_exceptions_ftype *func, void *func_args, char *errstring, return_mask mask); +extern int catch_exceptions_with_msg (struct ui_out *uiout, + catch_exceptions_ftype *func, + void *func_args, + char *errstring, char **gdberrmsg, + return_mask mask); /* If CATCH_ERRORS_FTYPE throws an error, catch_errors() returns zero otherwize the result from CATCH_ERRORS_FTYPE is returned. It is diff --git a/gdb/linespec.c b/gdb/linespec.c index 741ac88..e16e96e 100644 --- a/gdb/linespec.c +++ b/gdb/linespec.c @@ -1,6 +1,6 @@ /* Parser for linespec for the GNU debugger, GDB. Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, - 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 + 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. This file is part of GDB. @@ -1469,7 +1469,14 @@ symtab_from_filename (char **argptr, char *p, int is_quote_enclosed, if (not_found_ptr) { *not_found_ptr = 1; - throw_exception (RETURN_ERROR); + /* The caller has indicated that it wishes quiet notification of any + error where the function or file is not found. A call to + error_silent causes an error to occur, but it does not issue + the supplied message. The message can be manually output by + the caller, if desired. This is used, for example, when + attempting to set breakpoints for functions in shared libraries + that have not yet been loaded. */ + error_silent ("No source file named %s.", copy); } error ("No source file named %s.", copy); } @@ -1684,7 +1691,14 @@ decode_variable (char *copy, int funfirstline, char ***canonical, if (not_found_ptr) { *not_found_ptr = 1; - throw_exception (RETURN_ERROR); + /* The caller has indicated that it wishes quiet notification of any + error where the function or file is not found. A call to + error_silent causes an error to occur, but it does not issue + the supplied message. The message can be manually output by + the caller, if desired. This is used, for example, when + attempting to set breakpoints for functions in shared libraries + that have not yet been loaded. */ + error_silent ("Function \"%s\" not defined.", copy); } error ("Function \"%s\" not defined.", copy); @@ -383,6 +383,7 @@ catcher (catch_exceptions_ftype *func, int *func_val, enum return_reason *func_caught, char *errstring, + char **gdberrmsg, return_mask mask) { SIGJMP_BUF *saved_catch; @@ -428,7 +429,14 @@ catcher (catch_exceptions_ftype *func, if (!caught) val = (*func) (func_uiout, func_args); else - val = 0; + { + val = 0; + /* If caller wants a copy of the low-level error message, make one. + This is used in the case of a silent error whereby the caller + may optionally want to issue the message. */ + if (gdberrmsg) + *gdberrmsg = error_last_message (); + } catch_return = saved_catch; /* FIXME: cagney/1999-11-05: A correct FUNC implementation will @@ -476,7 +484,25 @@ catch_exceptions (struct ui_out *uiout, { int val; enum return_reason caught; - catcher (func, uiout, func_args, &val, &caught, errstring, mask); + catcher (func, uiout, func_args, &val, &caught, errstring, NULL, mask); + gdb_assert (val >= 0); + gdb_assert (caught <= 0); + if (caught < 0) + return caught; + return val; +} + +int +catch_exceptions_with_msg (struct ui_out *uiout, + catch_exceptions_ftype *func, + void *func_args, + char *errstring, + char **gdberrmsg, + return_mask mask) +{ + int val; + enum return_reason caught; + catcher (func, uiout, func_args, &val, &caught, errstring, gdberrmsg, mask); gdb_assert (val >= 0); gdb_assert (caught <= 0); if (caught < 0) @@ -506,7 +532,8 @@ catch_errors (catch_errors_ftype *func, void *func_args, char *errstring, struct catch_errors_args args; args.func = func; args.func_args = func_args; - catcher (do_catch_errors, uiout, &args, &val, &caught, errstring, mask); + catcher (do_catch_errors, uiout, &args, &val, &caught, errstring, + NULL, mask); if (caught != 0) return 0; return val; diff --git a/gdb/utils.c b/gdb/utils.c index ba936d5..bf80618 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -1,7 +1,7 @@ /* General utility routines for GDB, the GNU debugger. Copyright 1986, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, - 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 Free Software + 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. This file is part of GDB. @@ -628,6 +628,38 @@ do_write (void *data, const char *buffer, long length_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 an error message including any pre-print text to gdb_stderr. */ +void +error_output_message (char *pre_print, char *msg) +{ + target_terminal_ours (); + wrap_here (""); /* Force out any buffered output */ + gdb_flush (gdb_stdout); + annotate_error_begin (); + if (pre_print) + fputs_filtered (pre_print, gdb_stderr); + fputs_filtered (msg, gdb_stderr); + fprintf_filtered (gdb_stderr, "\n"); +} + NORETURN void error_stream (struct ui_file *stream) { |