diff options
-rw-r--r-- | gdb/ChangeLog | 17 | ||||
-rw-r--r-- | gdb/breakpoint.c | 22 | ||||
-rw-r--r-- | gdb/cli/cli-interp.c | 2 | ||||
-rw-r--r-- | gdb/exceptions.c | 64 | ||||
-rw-r--r-- | gdb/exceptions.h | 8 | ||||
-rw-r--r-- | gdb/mi/mi-main.c | 2 | ||||
-rw-r--r-- | gdb/remote.c | 22 |
7 files changed, 84 insertions, 53 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 835d828..48ee486 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,22 @@ 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. diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 75249f5..9b77543 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -709,7 +709,7 @@ deprecated_read_memory_nobpt (CORE_ADDR memaddr, char *myaddr, unsigned len) /* A wrapper function for inserting catchpoints. */ -static int +static void insert_catchpoint (struct ui_out *uo, void *args) { struct breakpoint *b = (struct breakpoint *) args; @@ -733,8 +733,6 @@ insert_catchpoint (struct ui_out *uo, void *args) if (val < 0) throw_reason (RETURN_ERROR); - - return 0; } /* Helper routine: free the value chain for a breakpoint (watchpoint). */ @@ -1073,13 +1071,11 @@ insert_bp_location (struct bp_location *bpt, || 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; @@ -5134,7 +5130,7 @@ break_command_1 (char *arg, int flag, int from_tty, struct breakpoint *pending_b 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) @@ -5145,7 +5141,7 @@ break_command_1 (char *arg, int flag, int from_tty, struct breakpoint *pending_b 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. */ @@ -5171,7 +5167,7 @@ break_command_1 (char *arg, int flag, int from_tty, struct breakpoint *pending_b pending = 1; break; default: - exception_print (gdb_stderr, NULL, e); + exception_print (gdb_stderr, e); return e.reason; } default: diff --git a/gdb/cli/cli-interp.c b/gdb/cli/cli-interp.c index ac905b2..8893cb1 100644 --- a/gdb/cli/cli-interp.c +++ b/gdb/cli/cli-interp.c @@ -133,7 +133,7 @@ safe_execute_command (struct ui_out *uiout, char *command, int from_tty) 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; } diff --git a/gdb/exceptions.c b/gdb/exceptions.c index aed10a8..1301623 100644 --- a/gdb/exceptions.c +++ b/gdb/exceptions.c @@ -302,9 +302,28 @@ do_write (void *data, const char *buffer, long length_buffer) } +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) { @@ -312,26 +331,29 @@ exception_print (struct ui_file *file, const char *pre_print, 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"); } } diff --git a/gdb/exceptions.h b/gdb/exceptions.h index 03318ae..80c120d 100644 --- a/gdb/exceptions.h +++ b/gdb/exceptions.h @@ -67,9 +67,11 @@ struct exception 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 diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c index bd45cd5..7351d1e 100644 --- a/gdb/mi/mi-main.c +++ b/gdb/mi/mi-main.c @@ -1156,7 +1156,7 @@ mi_execute_command (char *cmd, int from_tty) 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) { diff --git a/gdb/remote.c b/gdb/remote.c index 108b5e8..a2e22a5 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -83,8 +83,6 @@ static void remote_resume (ptid_t ptid, int step, 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); @@ -2019,7 +2017,7 @@ remote_start_remote_dummy (struct ui_out *uiout, void *dummy) return 1; } -static int +static void remote_start_remote (struct ui_out *uiout, void *dummy) { immediate_quit++; /* Allow user to interrupt it. */ @@ -2037,9 +2035,7 @@ remote_start_remote (struct ui_out *uiout, void *dummy) 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. @@ -2157,7 +2153,7 @@ static void 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" @@ -2260,17 +2256,15 @@ remote_open_1 (char *name, int from_tty, struct target_ops *target, 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) |