From 9cbc821d4e761ccb7164c704f4299160e72b4d08 Mon Sep 17 00:00:00 2001 From: Andrew Cagney Date: Fri, 14 Jan 2005 22:59:36 +0000 Subject: 2005-01-14 Andrew Cagney * 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. --- gdb/exceptions.c | 64 +++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 43 insertions(+), 21 deletions(-) (limited to 'gdb/exceptions.c') 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"); } } -- cgit v1.1