From: Jeff Johnston <jjohnstn@redhat.com>
To: gdb-patches@sources.redhat.com
Cc: Elena Zannoni <ezannoni@redhat.com>
Subject: [RFA]: error_silent for use in pending breakpoint support
Date: Thu, 18 Dec 2003 21:42:00 -0000 [thread overview]
Message-ID: <3FE21F2B.3030104@redhat.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1149 bytes --]
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 <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_last_output): Add prototypes.
* utils.c (error_silent, error_last_output): New functions.
[-- Attachment #2: error_silent.patch --]
[-- Type: text/plain, Size: 3202 bytes --]
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);
next reply other threads:[~2003-12-18 21:42 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-12-18 21:42 Jeff Johnston [this message]
2004-01-09 18:55 ` J. Johnston
2004-01-11 20:46 ` Andrew Cagney
2004-01-15 23:42 ` J. Johnston
2004-01-19 23:10 ` Andrew Cagney
2004-01-20 2:05 ` J. Johnston
2004-01-12 15:27 ` Elena Zannoni
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3FE21F2B.3030104@redhat.com \
--to=jjohnstn@redhat.com \
--cc=ezannoni@redhat.com \
--cc=gdb-patches@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox