diff options
-rw-r--r-- | gdb/ChangeLog | 10 | ||||
-rw-r--r-- | gdb/cli/cli-interp.c | 4 | ||||
-rw-r--r-- | gdb/interps.c | 34 | ||||
-rw-r--r-- | gdb/interps.h | 23 | ||||
-rw-r--r-- | gdb/main.c | 5 | ||||
-rw-r--r-- | gdb/mi/mi-main.c | 1 |
6 files changed, 53 insertions, 24 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 0b7a1e3b4e3..bd9722c1b6c 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,13 @@ +2003-02-04 Andrew Cagney <ac131313@redhat.com> + + * interps.c (current_interp_command_loop): New function. + + * main.c (captured_command_loop): Call current_interp_command_loop. + + * interps.h (current_interp_command_loop): Declare. + (interp_command_loop_ftype): Define. + (struct interp_procs): Add command_loop_proc. + 2003-02-03 Andrew Cagney <ac131313@redhat.com> * interps.c (gdb_interpreter_get_procs): Delete function. diff --git a/gdb/cli/cli-interp.c b/gdb/cli/cli-interp.c index 1056d4b5670..09a82251ff3 100644 --- a/gdb/cli/cli-interp.c +++ b/gdb/cli/cli-interp.c @@ -25,6 +25,7 @@ #include "ui-out.h" #include "cli-out.h" #include "top.h" /* for "execute_command" */ +#include "gdb_string.h" struct ui_out *cli_uiout; @@ -81,8 +82,7 @@ cli_interpreter_exec (void *data, const char *command_str) /* FIXME: cagney/2003-02-01: Need to const char *propogate safe_execute_command. */ - char *str = alloca (strlen (command_str) + 1); - strcpy (str, command_str); + char *str = strcpy (alloca (strlen (command_str) + 1), command_str); /* gdb_stdout could change between the time cli_uiout was initialized and now. Since we're probably using a different interpreter which has diff --git a/gdb/interps.c b/gdb/interps.c index 01d5613759a..c61c08a373a 100644 --- a/gdb/interps.c +++ b/gdb/interps.c @@ -41,17 +41,21 @@ #include "gdb_string.h" #include "gdb-events.h" #include "gdb_assert.h" +#include "top.h" /* For command_loop. */ struct interp { /* This is the name in "-i=" and set interpreter. */ const char *name; - /* Interpreters are stored in a linked list, this is the next one... */ + /* Interpreters are stored in a linked list, this is the next + one... */ struct interp *next; - /* This is a cookie that the instance of the interpreter can use, for - instance to call itself in hook functions */ + /* This is a cookie that an instance of the interpreter can use. + This is a bit confused right now as the exact initialization + sequence for it, and how it relates to the interpreter's uiout + object is a bit confused. */ void *data; /* Has the init_proc been run? */ @@ -59,7 +63,7 @@ struct interp /* This is the ui_out used to collect results for this interpreter. It can be a formatter for stdout, as is the case for the console - & mi outputs, or it might be a result formatter. */ + & mi outputs, or it might be a result formatter. */ struct ui_out *interpreter_out; const struct interp_procs *procs; @@ -245,9 +249,9 @@ current_interp_named_p (const char *interp_name) return 0; } -/* This is called in display_gdb_prompt. - If the proc returns a zero value, display_gdb_prompt will - return without displaying the prompt. */ +/* This is called in display_gdb_prompt. If the proc returns a zero + value, display_gdb_prompt will return without displaying the + prompt. */ int current_interp_display_prompt_p (void) { @@ -259,6 +263,22 @@ current_interp_display_prompt_p (void) data); } +/* Run the current command interpreter's main loop. */ +void +current_interp_command_loop (void) +{ + /* Somewhat messy. For the moment prop up all the old ways of + selecting the command loop. `command_loop_hook' should be + deprecated. */ + if (command_loop_hook != NULL) + command_loop_hook (); + else if (current_interpreter != NULL + && current_interpreter->procs->command_loop_proc != NULL) + current_interpreter->procs->command_loop_proc (current_interpreter->data); + else + command_loop (); +} + int interp_quiet_p (struct interp *interp) { diff --git a/gdb/interps.h b/gdb/interps.h index 1bf37bfa988..7bb1675b5c7 100644 --- a/gdb/interps.h +++ b/gdb/interps.h @@ -32,19 +32,21 @@ extern int interp_exec_p (struct interp *interp); extern int 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 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 int (interp_command_loop_ftype) (void *data); struct interp_procs { - interp_init_ftype init_proc; - interp_resume_ftype resume_proc; - interp_suspend_ftype suspend_proc; - interp_exec_ftype exec_proc; - interp_prompt_p_ftype prompt_proc_p; + interp_init_ftype *init_proc; + interp_resume_ftype *resume_proc; + interp_suspend_ftype *suspend_proc; + interp_exec_ftype *exec_proc; + interp_prompt_p_ftype *prompt_proc_p; + interp_command_loop_ftype *command_loop_proc; }; extern struct interp *interp_new (const char *name, void *data, @@ -57,6 +59,7 @@ extern struct ui_out *interp_ui_out (struct interp *interp); extern int current_interp_named_p (const char *name); extern int current_interp_display_prompt_p (void); +extern void current_interp_command_loop (void); extern void clear_interpreter_hooks (); diff --git a/gdb/main.c b/gdb/main.c index 7cb74ce97bd..a1dbf4662f8 100644 --- a/gdb/main.c +++ b/gdb/main.c @@ -96,10 +96,7 @@ extern char *external_editor_command; static int captured_command_loop (void *data) { - if (command_loop_hook == NULL) - command_loop (); - else - command_loop_hook (); + current_interp_command_loop (); /* FIXME: cagney/1999-11-05: A correct command_loop() implementaton would clean things up (restoring the cleanup chain) to the state they were just prior to the call. Technically, this means that diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c index 54450fd91b4..2f21f74cf66 100644 --- a/gdb/mi/mi-main.c +++ b/gdb/mi/mi-main.c @@ -1162,7 +1162,6 @@ captured_mi_execute_command (struct ui_out *uiout, void *data) /* If we changed interpreters, DON'T print out anything. */ if (current_interp_named_p (INTERP_MI) - || current_interp_named_p (INTERP_MI2) || current_interp_named_p (INTERP_MI1)) { /* print the result */ |