aboutsummaryrefslogtreecommitdiff
path: root/gdb/utils.c
diff options
context:
space:
mode:
authorJeff Johnston <jjohnstn@redhat.com>2004-01-20 02:04:19 +0000
committerJeff Johnston <jjohnstn@redhat.com>2004-01-20 02:04:19 +0000
commit4fcef00ad0f7de5a38ce1431e9db564aa3508871 (patch)
treec6c24f8ed847db8e72d197e8dbaaab60bc0e84c3 /gdb/utils.c
parent53a83a21c7ab484d1e5c3dec1ccb976cbeb50924 (diff)
downloadgdb-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/utils.c')
-rw-r--r--gdb/utils.c34
1 files changed, 33 insertions, 1 deletions
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)
{