diff options
author | Andrew Cagney <cagney@redhat.com> | 2005-01-13 02:35:39 +0000 |
---|---|---|
committer | Andrew Cagney <cagney@redhat.com> | 2005-01-13 02:35:39 +0000 |
commit | c1043fc2c19efe25b2b183a7c550d5ba85d4c0e6 (patch) | |
tree | 33992f8388c297e887751b5b3fafb9eb24e55e1c | |
parent | 2a78bfb53ccd6d78e97293502ae0b41ce4d120a5 (diff) | |
download | gdb-c1043fc2c19efe25b2b183a7c550d5ba85d4c0e6.zip gdb-c1043fc2c19efe25b2b183a7c550d5ba85d4c0e6.tar.gz gdb-c1043fc2c19efe25b2b183a7c550d5ba85d4c0e6.tar.bz2 |
2005-01-12 Andrew Cagney <cagney@gnu.org>
* exceptions.c (exception_none): New variable.
* Makefile.in: Update dependencies.
* interps.c: Include "exceptions.h".
(interpreter_exec_cmd, interp_exec): Update to return "struct
exception"
* exceptions.h (no_exception): Declare.
* tui/tui-interp.c (tui_exec): Update to return "struct exception"
* mi/mi-interp.c: Include "exceptions.h".
(mi_cmd_interpreter_exec, mi_interpreter_exec): Update to return
'struct exception".
* cli/cli-interp.c (cli_interpreter_exec, safe_execute_command)
(do_captured_execute_command): Update to use catch_exception.
* interps.h: Include "exceptions.h".
(interp_exec_ftype, interp_exec): Return "struct exception".
-rw-r--r-- | gdb/ChangeLog | 15 | ||||
-rw-r--r-- | gdb/Makefile.in | 19 | ||||
-rw-r--r-- | gdb/cli/cli-interp.c | 18 | ||||
-rw-r--r-- | gdb/exceptions.c | 2 | ||||
-rw-r--r-- | gdb/exceptions.h | 3 | ||||
-rw-r--r-- | gdb/interps.c | 8 | ||||
-rw-r--r-- | gdb/interps.h | 7 | ||||
-rw-r--r-- | gdb/mi/mi-interp.c | 22 | ||||
-rw-r--r-- | gdb/tui/tui-interp.c | 2 |
9 files changed, 63 insertions, 33 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 2dee79c..40985f8 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,20 @@ 2005-01-12 Andrew Cagney <cagney@gnu.org> + * exceptions.c (exception_none): New variable. + * Makefile.in: Update dependencies. + * interps.c: Include "exceptions.h". + (interpreter_exec_cmd, interp_exec): Update to return "struct + exception" + * exceptions.h (no_exception): Declare. + * tui/tui-interp.c (tui_exec): Update to return "struct exception" + * mi/mi-interp.c: Include "exceptions.h". + (mi_cmd_interpreter_exec, mi_interpreter_exec): Update to return + 'struct exception". + * cli/cli-interp.c (cli_interpreter_exec, safe_execute_command) + (do_captured_execute_command): Update to use catch_exception. + * interps.h: Include "exceptions.h". + (interp_exec_ftype, interp_exec): Return "struct exception". + * exceptions.h (throw_reason): Rename throw_exception. (enum errors, struct exception): Define. (catch_exception_ftype): Define. diff --git a/gdb/Makefile.in b/gdb/Makefile.in index 66f189a..79374d4 100644 --- a/gdb/Makefile.in +++ b/gdb/Makefile.in @@ -714,7 +714,7 @@ inf_loop_h = inf-loop.h inflow_h = inflow.h $(terminal_h) inf_ptrace_h = inf-ptrace.h inf_ttrace_h = inf-ttrace.h -interps_h = interps.h +interps_h = interps.h $(exceptions_h) jv_lang_h = jv-lang.h kod_h = kod.h language_h = language.h @@ -1758,13 +1758,13 @@ breakpoint.o: breakpoint.c $(defs_h) $(symtab_h) $(frame_h) $(breakpoint_h) \ $(objfiles_h) $(source_h) $(linespec_h) $(completer_h) $(gdb_h) \ $(ui_out_h) $(cli_script_h) $(gdb_assert_h) $(block_h) $(solist_h) \ $(observer_h) $(exceptions_h) $(gdb_events_h) -bsd-uthread.o: bsd-uthread.c $(defs_h) $(gdb_core_h) $(gdbthread_h) \ - $(inferior_h) $(objfiles_h) $(observer_h) $(regcache_h) \ - $(solist_h) $(symfile_h) $(target_h) $(gdb_assert_h) \ - $(gdb_obstack_h) $(bsd_uthread_h) bsd-kvm.o: bsd-kvm.c $(defs_h) $(cli_cmds_h) $(command_h) $(frame_h) \ $(regcache_h) $(target_h) $(value_h) $(gdbcore_h) $(gdb_assert_h) \ $(readline_h) $(bsd_kvm_h) +bsd-uthread.o: bsd-uthread.c $(defs_h) $(gdbcore_h) $(gdbthread_h) \ + $(inferior_h) $(objfiles_h) $(observer_h) $(regcache_h) $(solist_h) \ + $(symfile_h) $(target_h) $(gdb_assert_h) $(gdb_obstack_h) \ + $(bsd_uthread_h) buildsym.o: buildsym.c $(defs_h) $(bfd_h) $(gdb_obstack_h) $(symtab_h) \ $(symfile_h) $(objfiles_h) $(gdbtypes_h) $(gdb_assert_h) \ $(complaints_h) $(gdb_string_h) $(expression_h) $(bcache_h) \ @@ -1896,7 +1896,9 @@ event-loop.o: event-loop.c $(defs_h) $(event_loop_h) $(event_top_h) \ event-top.o: event-top.c $(defs_h) $(top_h) $(inferior_h) $(target_h) \ $(terminal_h) $(event_loop_h) $(event_top_h) $(interps_h) \ $(exceptions_h) $(gdbcmd_h) $(readline_h) $(readline_history_h) -exceptions.o: exceptions.c +exceptions.o: exceptions.c $(defs_h) $(exceptions_h) $(breakpoint_h) \ + $(target_h) $(inferior_h) $(annotate_h) $(ui_out_h) $(gdb_assert_h) \ + $(gdb_string_h) exec.o: exec.c $(defs_h) $(frame_h) $(inferior_h) $(target_h) $(gdbcmd_h) \ $(language_h) $(symfile_h) $(objfiles_h) $(completer_h) $(value_h) \ $(exec_h) $(readline_h) $(gdb_string_h) $(gdbcore_h) $(gdb_stat_h) \ @@ -2109,7 +2111,7 @@ inf-ttrace.o: inf-ttrace.c $(defs_h) $(command_h) $(gdbcore_h) \ $(gdb_assert_h) $(gdb_string_h) $(inf_child_h) $(inf_ttrace_h) interps.o: interps.c $(defs_h) $(gdbcmd_h) $(ui_out_h) $(event_loop_h) \ $(event_top_h) $(interps_h) $(completer_h) $(gdb_string_h) \ - $(gdb_events_h) $(gdb_assert_h) $(top_h) + $(gdb_events_h) $(gdb_assert_h) $(top_h) $(exceptions_h) irix5-nat.o: irix5-nat.c $(defs_h) $(inferior_h) $(gdbcore_h) $(target_h) \ $(regcache_h) $(gdb_string_h) $(gregset_h) $(mips_tdep_h) jv-exp.o: jv-exp.c $(defs_h) $(gdb_string_h) $(expression_h) $(value_h) \ @@ -2945,7 +2947,8 @@ mi-getopt.o: $(srcdir)/mi/mi-getopt.c $(defs_h) $(mi_getopt_h) \ $(CC) -c $(INTERNAL_CFLAGS) $(srcdir)/mi/mi-getopt.c mi-interp.o: $(srcdir)/mi/mi-interp.c $(defs_h) $(gdb_string_h) $(interps_h) \ $(event_top_h) $(event_loop_h) $(inferior_h) $(ui_out_h) $(top_h) \ - $(mi_main_h) $(mi_cmds_h) $(mi_out_h) $(mi_console_h) + $(exceptions_h) $(mi_main_h) $(mi_cmds_h) $(mi_out_h) \ + $(mi_console_h) $(CC) -c $(INTERNAL_CFLAGS) $(srcdir)/mi/mi-interp.c mi-main.o: $(srcdir)/mi/mi-main.c $(defs_h) $(target_h) $(inferior_h) \ $(gdb_string_h) $(exceptions_h) $(top_h) $(gdbthread_h) $(mi_cmds_h) \ diff --git a/gdb/cli/cli-interp.c b/gdb/cli/cli-interp.c index 35b7622..021b798 100644 --- a/gdb/cli/cli-interp.c +++ b/gdb/cli/cli-interp.c @@ -34,9 +34,8 @@ struct ui_out *cli_uiout; /* These are the ui_out and the interpreter for the console interpreter. */ /* Longjmp-safe wrapper for "execute_command" */ -static int do_captured_execute_command (struct ui_out *uiout, void *data); -static enum gdb_rc safe_execute_command (struct ui_out *uiout, char *command, - int from_tty); +static struct exception safe_execute_command (struct ui_out *uiout, + char *command, int from_tty); struct captured_execute_command_args { char *command; @@ -93,11 +92,11 @@ cli_interpreter_display_prompt_p (void *data) return 1; } -static int +static struct exception cli_interpreter_exec (void *data, const char *command_str) { - int result; struct ui_file *old_stream; + struct exception result; /* FIXME: cagney/2003-02-01: Need to const char *propogate safe_execute_command. */ @@ -115,23 +114,22 @@ cli_interpreter_exec (void *data, const char *command_str) return result; } -static int +static void do_captured_execute_command (struct ui_out *uiout, void *data) { struct captured_execute_command_args *args = (struct captured_execute_command_args *) data; execute_command (args->command, args->from_tty); - return GDB_RC_OK; } -static enum gdb_rc +static struct exception safe_execute_command (struct ui_out *uiout, char *command, int from_tty) { struct captured_execute_command_args args; args.command = command; args.from_tty = from_tty; - return catch_exceptions (uiout, do_captured_execute_command, &args, - NULL, RETURN_MASK_ALL); + return catch_exception (uiout, do_captured_execute_command, &args, + RETURN_MASK_ALL); } diff --git a/gdb/exceptions.c b/gdb/exceptions.c index 2964f76..ccf4863 100644 --- a/gdb/exceptions.c +++ b/gdb/exceptions.c @@ -32,6 +32,8 @@ #include "gdb_assert.h" #include "gdb_string.h" +const struct exception exception_none = { 0, NO_ERROR, NULL }; + /* One should use catch_errors rather than manipulating these directly. */ #if defined(HAVE_SIGSETJMP) diff --git a/gdb/exceptions.h b/gdb/exceptions.h index b5d8fd5..fedd405 100644 --- a/gdb/exceptions.h +++ b/gdb/exceptions.h @@ -62,6 +62,9 @@ struct exception char *message; }; +/* A pre-defined non-exception. */ +extern const struct exception exception_none; + /* Throw an exception (as described by "struct exception"). Will execute a LONG JUMP to the inner most containing exception handler established using catch_exceptions() (or similar). diff --git a/gdb/interps.c b/gdb/interps.c index 2a4cc0b..b93b3f6 100644 --- a/gdb/interps.c +++ b/gdb/interps.c @@ -42,6 +42,7 @@ #include "gdb-events.h" #include "gdb_assert.h" #include "top.h" /* For command_loop. */ +#include "exceptions.h" struct interp { @@ -304,14 +305,14 @@ interp_exec_p (struct interp *interp) return interp->procs->exec_proc != NULL; } -int +struct exception interp_exec (struct interp *interp, const char *command_str) { if (interp->procs->exec_proc != NULL) { return interp->procs->exec_proc (interp->data, command_str); } - return 0; + return exception_none; } /* A convenience routine that nulls out all the @@ -398,7 +399,8 @@ interpreter_exec_cmd (char *args, int from_tty) for (i = 1; i < nrules; i++) { - if (!interp_exec (interp_to_use, prules[i])) + struct exception e = interp_exec (interp_to_use, prules[i]); + if (!e.reason) { interp_set (old_interp); interp_set_quiet (interp_to_use, old_quiet); diff --git a/gdb/interps.h b/gdb/interps.h index 8e3257b..9ef68a6 100644 --- a/gdb/interps.h +++ b/gdb/interps.h @@ -24,6 +24,8 @@ #ifndef INTERPS_H #define INTERPS_H +#include "exceptions.h" + struct ui_out; struct interp; @@ -31,14 +33,15 @@ extern int interp_resume (struct interp *interp); extern int interp_suspend (struct interp *interp); extern int interp_prompt_p (struct interp *interp); extern int interp_exec_p (struct interp *interp); -extern int interp_exec (struct interp *interp, const char *command); +extern struct exception interp_exec (struct interp *interp, + const char *command); extern int interp_quiet_p (struct interp *interp); typedef void *(interp_init_ftype) (void); typedef int (interp_resume_ftype) (void *data); typedef int (interp_suspend_ftype) (void *data); typedef int (interp_prompt_p_ftype) (void *data); -typedef int (interp_exec_ftype) (void *data, const char *command); +typedef struct exception (interp_exec_ftype) (void *data, const char *command); typedef void (interp_command_loop_ftype) (void *data); struct interp_procs diff --git a/gdb/mi/mi-interp.c b/gdb/mi/mi-interp.c index 71abb75..a3af521 100644 --- a/gdb/mi/mi-interp.c +++ b/gdb/mi/mi-interp.c @@ -27,7 +27,7 @@ #include "inferior.h" #include "ui-out.h" #include "top.h" - +#include "exceptions.h" #include "mi-main.h" #include "mi-cmds.h" #include "mi-out.h" @@ -145,13 +145,14 @@ mi_interpreter_suspend (void *data) return 1; } -static int +static struct exception mi_interpreter_exec (void *data, const char *command) { + static struct exception ok; char *tmp = alloca (strlen (command) + 1); strcpy (tmp, command); mi_execute_command_wrapper (tmp); - return 1; + return exception_none; } /* Never display the default gdb prompt in mi case. */ @@ -236,12 +237,15 @@ mi_cmd_interpreter_exec (char *command, char **argv, int argc) since that is what the cli expects - before running the command, and then set it back to 0 when we are done. */ sync_execution = 1; - if (interp_exec (interp_to_use, argv[i]) < 0) - { - mi_error_message = error_last_message (); - result = MI_CMD_ERROR; - break; - } + { + struct exception e = interp_exec (interp_to_use, argv[i]); + if (e.reason < 0) + { + mi_error_message = e.message; + result = MI_CMD_ERROR; + break; + } + } xfree (buff); do_exec_error_cleanups (ALL_CLEANUPS); sync_execution = 0; diff --git a/gdb/tui/tui-interp.c b/gdb/tui/tui-interp.c index b5c3b40..ced5dbd 100644 --- a/gdb/tui/tui-interp.c +++ b/gdb/tui/tui-interp.c @@ -106,7 +106,7 @@ tui_display_prompt_p (void *data) return 1; } -static int +static struct exception tui_exec (void *data, const char *command_str) { internal_error (__FILE__, __LINE__, "tui_exec called"); |