diff options
author | Pedro Alves <palves@redhat.com> | 2014-07-14 19:55:31 +0100 |
---|---|---|
committer | Pedro Alves <palves@redhat.com> | 2014-07-14 20:30:12 +0100 |
commit | 9d1e69a21488cb5b8b7553c8df18ee5c3f4d82e3 (patch) | |
tree | 378ce24c987af0711b9357a933a34d4091ef9de8 /gdb/main.c | |
parent | feefc97b5942325a8b7793e7ae089d87ecdee11c (diff) | |
download | gdb-9d1e69a21488cb5b8b7553c8df18ee5c3f4d82e3.zip gdb-9d1e69a21488cb5b8b7553c8df18ee5c3f4d82e3.tar.gz gdb-9d1e69a21488cb5b8b7553c8df18ee5c3f4d82e3.tar.bz2 |
Move catch_command_errors and catch_command_errors_const to main.c
We'll need to add error handling code to commands run before the event
loop starts (commands in .gdbinit, -ex commands, etc.). Turns out
those are run through catch_command_errors, and, catch_command_errors
is used nowhere else. Move it (and the _const variant) to main.c, so
that we can further specialize it freely.
gdb/
2014-07-14 Pedro Alves <palves@redhat.com>
* exceptions.c (catch_command_errors, catch_command_errors_const):
Moved to main.c.
* exceptions.h (catch_command_errors_ftype)
(catch_command_errors_const_ftype): Moved to main.c.
(catch_command_errors, catch_command_errors_const): Delete
declarations.
* main.c (catch_command_errors_ftype)
(catch_command_errors_const_ftype): Moved here from exceptions.h.
(catch_command_errors, catch_command_errors_const)): Moved here
from exceptions.c and make static.
Diffstat (limited to 'gdb/main.c')
-rw-r--r-- | gdb/main.c | 44 |
1 files changed, 44 insertions, 0 deletions
@@ -337,6 +337,50 @@ captured_command_loop (void *data) return 1; } +/* Type of the command callback passed to catch_command_errors. */ + +typedef void (catch_command_errors_ftype) (char *, int); + +/* Wrap calls to commands run before the event loop is started. */ + +static int +catch_command_errors (catch_command_errors_ftype *command, + char *arg, int from_tty, return_mask mask) +{ + volatile struct gdb_exception e; + + TRY_CATCH (e, mask) + { + command (arg, from_tty); + } + exception_print (gdb_stderr, e); + if (e.reason < 0) + return 0; + return 1; +} + +/* Type of the command callback passed to catch_command_errors_const. */ + +typedef void (catch_command_errors_const_ftype) (const char *, int); + +/* Like catch_command_errors, but works with const command and args. */ + +static int +catch_command_errors_const (catch_command_errors_const_ftype *command, + const char *arg, int from_tty, return_mask mask) +{ + volatile struct gdb_exception e; + + TRY_CATCH (e, mask) + { + command (arg, from_tty); + } + exception_print (gdb_stderr, e); + if (e.reason < 0) + return 0; + return 1; +} + /* Arguments of --command option and its counterpart. */ typedef struct cmdarg { /* Type of this option. */ |