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.
This commit is contained in:
parent
df227444e2
commit
9cbc821d4e
7 changed files with 84 additions and 53 deletions
|
@ -1,5 +1,22 @@
|
||||||
2005-01-14 Andrew Cagney <cagney@gnu.org>
|
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.
|
* utils.c (error_output_message): Delete function.
|
||||||
* defs.h (error_output_message): Delete declaration.
|
* defs.h (error_output_message): Delete declaration.
|
||||||
|
|
||||||
|
|
|
@ -709,7 +709,7 @@ deprecated_read_memory_nobpt (CORE_ADDR memaddr, char *myaddr, unsigned len)
|
||||||
|
|
||||||
|
|
||||||
/* A wrapper function for inserting catchpoints. */
|
/* A wrapper function for inserting catchpoints. */
|
||||||
static int
|
static void
|
||||||
insert_catchpoint (struct ui_out *uo, void *args)
|
insert_catchpoint (struct ui_out *uo, void *args)
|
||||||
{
|
{
|
||||||
struct breakpoint *b = (struct breakpoint *) args;
|
struct breakpoint *b = (struct breakpoint *) args;
|
||||||
|
@ -733,8 +733,6 @@ insert_catchpoint (struct ui_out *uo, void *args)
|
||||||
|
|
||||||
if (val < 0)
|
if (val < 0)
|
||||||
throw_reason (RETURN_ERROR);
|
throw_reason (RETURN_ERROR);
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Helper routine: free the value chain for a breakpoint (watchpoint). */
|
/* 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_vfork
|
||||||
|| bpt->owner->type == bp_catch_exec)
|
|| bpt->owner->type == bp_catch_exec)
|
||||||
{
|
{
|
||||||
char *prefix = xstrprintf ("warning: inserting catchpoint %d: ",
|
struct exception e = catch_exception (uiout, insert_catchpoint,
|
||||||
bpt->owner->number);
|
bpt->owner, RETURN_MASK_ERROR);
|
||||||
struct cleanup *cleanups = make_cleanup (xfree, prefix);
|
exception_fprintf (gdb_stderr, e, "warning: inserting catchpoint %d: ",
|
||||||
val = catch_exceptions (uiout, insert_catchpoint, bpt->owner, prefix,
|
bpt->owner->number);
|
||||||
RETURN_MASK_ERROR);
|
if (e.reason < 0)
|
||||||
do_cleanups (cleanups);
|
|
||||||
if (val < 0)
|
|
||||||
bpt->owner->enable_state = bp_disabled;
|
bpt->owner->enable_state = bp_disabled;
|
||||||
else
|
else
|
||||||
bpt->inserted = 1;
|
bpt->inserted = 1;
|
||||||
|
@ -5134,7 +5130,7 @@ break_command_1 (char *arg, int flag, int from_tty, struct breakpoint *pending_b
|
||||||
switch (e.reason)
|
switch (e.reason)
|
||||||
{
|
{
|
||||||
case RETURN_QUIT:
|
case RETURN_QUIT:
|
||||||
exception_print (gdb_stderr, NULL, e);
|
exception_print (gdb_stderr, e);
|
||||||
return e.reason;
|
return e.reason;
|
||||||
case RETURN_ERROR:
|
case RETURN_ERROR:
|
||||||
switch (e.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)
|
if (pending_bp)
|
||||||
return e.reason;
|
return e.reason;
|
||||||
|
|
||||||
exception_print (gdb_stderr, NULL, e);
|
exception_print (gdb_stderr, e);
|
||||||
|
|
||||||
/* If pending breakpoint support is turned off, throw
|
/* If pending breakpoint support is turned off, throw
|
||||||
error. */
|
error. */
|
||||||
|
@ -5171,7 +5167,7 @@ break_command_1 (char *arg, int flag, int from_tty, struct breakpoint *pending_b
|
||||||
pending = 1;
|
pending = 1;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
exception_print (gdb_stderr, NULL, e);
|
exception_print (gdb_stderr, e);
|
||||||
return e.reason;
|
return e.reason;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -133,7 +133,7 @@ safe_execute_command (struct ui_out *uiout, char *command, int from_tty)
|
||||||
RETURN_MASK_ALL);
|
RETURN_MASK_ALL);
|
||||||
/* FIXME: cagney/2005-01-13: This shouldn't be needed. Instead the
|
/* FIXME: cagney/2005-01-13: This shouldn't be needed. Instead the
|
||||||
caller should print the exception. */
|
caller should print the exception. */
|
||||||
exception_print (gdb_stderr, NULL, e);
|
exception_print (gdb_stderr, e);
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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
|
void
|
||||||
exception_print (struct ui_file *file, const char *pre_print,
|
exception_print (struct ui_file *file, struct exception e)
|
||||||
struct exception e)
|
|
||||||
{
|
{
|
||||||
if (e.reason < 0 && e.message != NULL)
|
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 */
|
wrap_here (""); /* Force out any buffered output */
|
||||||
gdb_flush (file);
|
gdb_flush (file);
|
||||||
annotate_error_begin ();
|
annotate_error_begin ();
|
||||||
if (pre_print)
|
print_exception (file, e);
|
||||||
fputs_filtered (pre_print, file);
|
fprintf_filtered (file, "\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* KLUGE: cagney/2005-01-13: Write the string out one line at a
|
void
|
||||||
time as that way the MI's behavior is preserved. */
|
exception_fprintf (struct ui_file *file, struct exception e,
|
||||||
{
|
const char *prefix, ...)
|
||||||
const char *start;
|
{
|
||||||
const char *end;
|
if (e.reason < 0 && e.message != NULL)
|
||||||
for (start = e.message; start != NULL; start = end)
|
{
|
||||||
{
|
va_list args;
|
||||||
end = strchr (start, '\n');
|
target_terminal_ours ();
|
||||||
if (end == NULL)
|
wrap_here (""); /* Force out any buffered output */
|
||||||
fputs_filtered (start, file);
|
gdb_flush (file);
|
||||||
else
|
annotate_error_begin ();
|
||||||
{
|
|
||||||
end++;
|
/* Print the prefix. */
|
||||||
ui_file_write (file, start, end - start);
|
va_start (args, prefix);
|
||||||
}
|
vfprintf_filtered (file, prefix, args);
|
||||||
}
|
va_end (args);
|
||||||
}
|
|
||||||
|
print_exception (file, e);
|
||||||
fprintf_filtered (file, "\n");
|
fprintf_filtered (file, "\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,9 +67,11 @@ struct exception
|
||||||
extern const struct exception exception_none;
|
extern const struct exception exception_none;
|
||||||
|
|
||||||
/* If E is an exception, print it's error message on the specified
|
/* If E is an exception, print it's error message on the specified
|
||||||
stream. */
|
stream. for _fprintf, prefix the message with PREFIX... */
|
||||||
extern void exception_print (struct ui_file *file, const char *pre_print,
|
extern void exception_print (struct ui_file *file, struct exception e);
|
||||||
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
|
/* Throw an exception (as described by "struct exception"). Will
|
||||||
execute a LONG JUMP to the inner most containing exception handler
|
execute a LONG JUMP to the inner most containing exception handler
|
||||||
|
|
|
@ -1156,7 +1156,7 @@ mi_execute_command (char *cmd, int from_tty)
|
||||||
args.command = command;
|
args.command = command;
|
||||||
result = catch_exception (uiout, captured_mi_execute_command, &args,
|
result = catch_exception (uiout, captured_mi_execute_command, &args,
|
||||||
RETURN_MASK_ALL);
|
RETURN_MASK_ALL);
|
||||||
exception_print (gdb_stderr, NULL, result);
|
exception_print (gdb_stderr, result);
|
||||||
|
|
||||||
if (args.action == EXECUTE_COMMAND_SUPRESS_PROMPT)
|
if (args.action == EXECUTE_COMMAND_SUPRESS_PROMPT)
|
||||||
{
|
{
|
||||||
|
|
22
gdb/remote.c
22
gdb/remote.c
|
@ -83,8 +83,6 @@ static void remote_resume (ptid_t ptid, int step,
|
||||||
enum target_signal siggnal);
|
enum target_signal siggnal);
|
||||||
static void remote_async_resume (ptid_t ptid, int step,
|
static void remote_async_resume (ptid_t ptid, int step,
|
||||||
enum target_signal siggnal);
|
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_open (char *name, int from_tty);
|
||||||
static void remote_async_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;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static void
|
||||||
remote_start_remote (struct ui_out *uiout, void *dummy)
|
remote_start_remote (struct ui_out *uiout, void *dummy)
|
||||||
{
|
{
|
||||||
immediate_quit++; /* Allow user to interrupt it. */
|
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. */
|
putpkt ("?"); /* Initiate a query from remote machine. */
|
||||||
immediate_quit--;
|
immediate_quit--;
|
||||||
|
|
||||||
/* NOTE: See comment above in remote_start_remote_dummy(). This
|
remote_start_remote_dummy (uiout, dummy);
|
||||||
function returns something >=0. */
|
|
||||||
return remote_start_remote_dummy (uiout, dummy);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Open a connection to a remote debugger.
|
/* 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,
|
remote_open_1 (char *name, int from_tty, struct target_ops *target,
|
||||||
int extended_p, int async_p)
|
int extended_p, int async_p)
|
||||||
{
|
{
|
||||||
int ex;
|
struct exception ex;
|
||||||
struct remote_state *rs = get_remote_state ();
|
struct remote_state *rs = get_remote_state ();
|
||||||
if (name == 0)
|
if (name == 0)
|
||||||
error ("To open a remote debug connection, you need to specify what\n"
|
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
|
been fixed - the function set_cmd_context() makes it possible for
|
||||||
all the ``target ....'' commands to share a common callback
|
all the ``target ....'' commands to share a common callback
|
||||||
function. See cli-dump.c. */
|
function. See cli-dump.c. */
|
||||||
ex = catch_exceptions (uiout,
|
ex = catch_exception (uiout, remote_start_remote, NULL, RETURN_MASK_ALL);
|
||||||
remote_start_remote, NULL,
|
exception_fprintf (gdb_stderr, ex, "Couldn't establish connection to remote"
|
||||||
"Couldn't establish connection to remote"
|
" target\n");
|
||||||
" target\n",
|
if (ex.reason < 0)
|
||||||
RETURN_MASK_ALL);
|
|
||||||
if (ex < 0)
|
|
||||||
{
|
{
|
||||||
pop_target ();
|
pop_target ();
|
||||||
if (async_p)
|
if (async_p)
|
||||||
wait_forever_enabled_p = 1;
|
wait_forever_enabled_p = 1;
|
||||||
throw_reason (ex);
|
throw_reason (ex.reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (async_p)
|
if (async_p)
|
||||||
|
|
Loading…
Reference in a new issue