* exceptions.h (exception_fprintf): Declare.
(exception_print): Drop pre_print parameter.
* mi/mi-main.c (mi_execute_command): Update exception_print call.
* cli/cli-interp.c (safe_execute_command): Update exception_print
call.
* remote.c (remote_open_1): Instead of passing an error prefix to
catch_exceptions, use catch_exceptions and exception_fprintf.
(remote_start_remote): Change return type to void.
* breakpoint.c (insert_bp_location): Instead of passing an error
prefix to catch_exceptions, use catch_exceptions and
exception_fprintf.
(insert_catchpoint): Change return type to void.
(break_command_1): Update exception_print call.
* exceptions.c (exception_fprintf): New function.
(print_exception): New function.
(exception_print): Use print_exception.
2005-01-14 Andrew Cagney <cagney@gnu.org>
+ * exceptions.h (exception_fprintf): Declare.
+ (exception_print): Drop pre_print parameter.
+ * mi/mi-main.c (mi_execute_command): Update exception_print call.
+ * cli/cli-interp.c (safe_execute_command): Update exception_print
+ call.
+ * remote.c (remote_open_1): Instead of passing an error prefix to
+ catch_exceptions, use catch_exceptions and exception_fprintf.
+ (remote_start_remote): Change return type to void.
+ * breakpoint.c (insert_bp_location): Instead of passing an error
+ prefix to catch_exceptions, use catch_exceptions and
+ exception_fprintf.
+ (insert_catchpoint): Change return type to void.
+ (break_command_1): Update exception_print call.
+ * exceptions.c (exception_fprintf): New function.
+ (print_exception): New function.
+ (exception_print): Use print_exception.
+
* utils.c (error_output_message): Delete function.
* defs.h (error_output_message): Delete declaration.
\f
/* A wrapper function for inserting catchpoints. */
-static int
+static void
insert_catchpoint (struct ui_out *uo, void *args)
{
struct breakpoint *b = (struct breakpoint *) args;
if (val < 0)
throw_reason (RETURN_ERROR);
-
- return 0;
}
/* Helper routine: free the value chain for a breakpoint (watchpoint). */
|| bpt->owner->type == bp_catch_vfork
|| bpt->owner->type == bp_catch_exec)
{
- char *prefix = xstrprintf ("warning: inserting catchpoint %d: ",
- bpt->owner->number);
- struct cleanup *cleanups = make_cleanup (xfree, prefix);
- val = catch_exceptions (uiout, insert_catchpoint, bpt->owner, prefix,
- RETURN_MASK_ERROR);
- do_cleanups (cleanups);
- if (val < 0)
+ struct exception e = catch_exception (uiout, insert_catchpoint,
+ bpt->owner, RETURN_MASK_ERROR);
+ exception_fprintf (gdb_stderr, e, "warning: inserting catchpoint %d: ",
+ bpt->owner->number);
+ if (e.reason < 0)
bpt->owner->enable_state = bp_disabled;
else
bpt->inserted = 1;
switch (e.reason)
{
case RETURN_QUIT:
- exception_print (gdb_stderr, NULL, e);
+ exception_print (gdb_stderr, e);
return e.reason;
case RETURN_ERROR:
switch (e.error)
if (pending_bp)
return e.reason;
- exception_print (gdb_stderr, NULL, e);
+ exception_print (gdb_stderr, e);
/* If pending breakpoint support is turned off, throw
error. */
pending = 1;
break;
default:
- exception_print (gdb_stderr, NULL, e);
+ exception_print (gdb_stderr, e);
return e.reason;
}
default:
RETURN_MASK_ALL);
/* FIXME: cagney/2005-01-13: This shouldn't be needed. Instead the
caller should print the exception. */
- exception_print (gdb_stderr, NULL, e);
+ exception_print (gdb_stderr, e);
return e;
}
}
+static void
+print_exception (struct ui_file *file, struct exception e)
+{
+ /* KLUGE: cagney/2005-01-13: Write the string out one line at a time
+ as that way the MI's behavior is preserved. */
+ const char *start;
+ const char *end;
+ for (start = e.message; start != NULL; start = end)
+ {
+ end = strchr (start, '\n');
+ if (end == NULL)
+ fputs_filtered (start, file);
+ else
+ {
+ end++;
+ ui_file_write (file, start, end - start);
+ }
+ }
+}
+
void
-exception_print (struct ui_file *file, const char *pre_print,
- struct exception e)
+exception_print (struct ui_file *file, struct exception e)
{
if (e.reason < 0 && e.message != NULL)
{
wrap_here (""); /* Force out any buffered output */
gdb_flush (file);
annotate_error_begin ();
- if (pre_print)
- fputs_filtered (pre_print, file);
+ print_exception (file, e);
+ fprintf_filtered (file, "\n");
+ }
+}
- /* KLUGE: cagney/2005-01-13: Write the string out one line at a
- time as that way the MI's behavior is preserved. */
- {
- const char *start;
- const char *end;
- for (start = e.message; start != NULL; start = end)
- {
- end = strchr (start, '\n');
- if (end == NULL)
- fputs_filtered (start, file);
- else
- {
- end++;
- ui_file_write (file, start, end - start);
- }
- }
- }
+void
+exception_fprintf (struct ui_file *file, struct exception e,
+ const char *prefix, ...)
+{
+ if (e.reason < 0 && e.message != NULL)
+ {
+ va_list args;
+ target_terminal_ours ();
+ wrap_here (""); /* Force out any buffered output */
+ gdb_flush (file);
+ annotate_error_begin ();
+
+ /* Print the prefix. */
+ va_start (args, prefix);
+ vfprintf_filtered (file, prefix, args);
+ va_end (args);
+
+ print_exception (file, e);
fprintf_filtered (file, "\n");
}
}
extern const struct exception exception_none;
/* If E is an exception, print it's error message on the specified
- stream. */
-extern void exception_print (struct ui_file *file, const char *pre_print,
- struct exception e);
+ stream. for _fprintf, prefix the message with PREFIX... */
+extern void exception_print (struct ui_file *file, struct exception e);
+extern void exception_fprintf (struct ui_file *file, struct exception e,
+ const char *prefix,
+ ...) ATTR_FORMAT (printf, 3, 4);
/* Throw an exception (as described by "struct exception"). Will
execute a LONG JUMP to the inner most containing exception handler
args.command = command;
result = catch_exception (uiout, captured_mi_execute_command, &args,
RETURN_MASK_ALL);
- exception_print (gdb_stderr, NULL, result);
+ exception_print (gdb_stderr, result);
if (args.action == EXECUTE_COMMAND_SUPRESS_PROMPT)
{
enum target_signal siggnal);
static void remote_async_resume (ptid_t ptid, int step,
enum target_signal siggnal);
-static int remote_start_remote (struct ui_out *uiout, void *dummy);
-
static void remote_open (char *name, int from_tty);
static void remote_async_open (char *name, int from_tty);
return 1;
}
-static int
+static void
remote_start_remote (struct ui_out *uiout, void *dummy)
{
immediate_quit++; /* Allow user to interrupt it. */
putpkt ("?"); /* Initiate a query from remote machine. */
immediate_quit--;
- /* NOTE: See comment above in remote_start_remote_dummy(). This
- function returns something >=0. */
- return remote_start_remote_dummy (uiout, dummy);
+ remote_start_remote_dummy (uiout, dummy);
}
/* Open a connection to a remote debugger.
remote_open_1 (char *name, int from_tty, struct target_ops *target,
int extended_p, int async_p)
{
- int ex;
+ struct exception ex;
struct remote_state *rs = get_remote_state ();
if (name == 0)
error ("To open a remote debug connection, you need to specify what\n"
been fixed - the function set_cmd_context() makes it possible for
all the ``target ....'' commands to share a common callback
function. See cli-dump.c. */
- ex = catch_exceptions (uiout,
- remote_start_remote, NULL,
- "Couldn't establish connection to remote"
- " target\n",
- RETURN_MASK_ALL);
- if (ex < 0)
+ ex = catch_exception (uiout, remote_start_remote, NULL, RETURN_MASK_ALL);
+ exception_fprintf (gdb_stderr, ex, "Couldn't establish connection to remote"
+ " target\n");
+ if (ex.reason < 0)
{
pop_target ();
if (async_p)
wait_forever_enabled_p = 1;
- throw_reason (ex);
+ throw_reason (ex.reason);
}
if (async_p)