+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.
/* *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.
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. */
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;
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.
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
/* 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.
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);
}
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);
int *func_val,
enum return_reason *func_caught,
char *errstring,
+ char **gdberrmsg,
return_mask mask)
{
SIGJMP_BUF *saved_catch;
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
{
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)
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;
/* 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.
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)
{