+2002-11-04 Elena Zannoni <ezannoni@redhat.com>
+
+ * cli/cli-interp.c (_initialize_cli_interp): Call
+ gdb_interpreter_new and gdb_interpreter_add.
+ * top.c (gdb_init): Call gdb_interpreter_lookup.
+ (gdb_init): Call gdb_interpreter_set.
+ * interps.c (gdb_interpreter_new): Renamed from
+ gdb_new_interpreter.
+ (gdb_interpreter_add): Renamed from gdb_add_interpreter.
+ (gdb_interpreter_set): Renamed from gdb_set_interpreter.
+ (gdb_interpreter_lookup): Renamed from gdb_lookup_interpreter.
+ (gdb_interpreter_current): Renamed from gdb_current_interpreter.
+ Update all callers.
+ * interps.h: Ditto.
+
2002-11-04 Elena Zannoni <ezannoni@redhat.com>
* interps.h (gdb_interpreter_is_quiet_p): Rename from
/* Create a default uiout builder for the CLI. */
cli_uiout = cli_out_new (gdb_stdout);
- cli_interp = gdb_new_interpreter (GDB_INTERPRETER_CONSOLE, NULL, cli_uiout,
+ cli_interp = gdb_interpreter_new (GDB_INTERPRETER_CONSOLE, NULL, cli_uiout,
&procs);
- gdb_add_interpreter (cli_interp);
+ gdb_interpreter_add (cli_interp);
}
static int interpreter_initialized = 0;
-/* gdb_new_interpreter - This allocates space for a new interpreter,
+/* gdb_interpreter_new - This allocates space for a new interpreter,
fills the fields from the inputs, and returns a pointer to the
interpreter. */
struct gdb_interpreter *
-gdb_new_interpreter (char *name,
+gdb_interpreter_new (char *name,
void *data,
struct ui_out *uiout,
struct gdb_interpreter_procs *procs)
the new one is NOT added, and the function returns 0. Otherwise
it returns 1. */
int
-gdb_add_interpreter (struct gdb_interpreter *interp)
+gdb_interpreter_add (struct gdb_interpreter *interp)
{
if (!interpreter_initialized)
initialize_interps ();
- if (gdb_lookup_interpreter (interp->name) != NULL)
+ if (gdb_interpreter_lookup (interp->name) != NULL)
return 0;
interp->next = interp_list;
old interpreter, then raise an internal error, since we are in
pretty bad shape at this point. */
int
-gdb_set_interpreter (struct gdb_interpreter *interp)
+gdb_interpreter_set (struct gdb_interpreter *interp)
{
struct gdb_interpreter *old_interp = current_interpreter;
int first_time = 0;
{
if (!interp->procs.init_proc (interp->data))
{
- if (!gdb_set_interpreter (old_interp))
+ if (!gdb_interpreter_set (old_interp))
internal_error (__FILE__, __LINE__,
"Failed to initialize new interp \"%s\" %s",
interp->name,
if (interp->procs.resume_proc != NULL
&& (!interp->procs.resume_proc (interp->data)))
{
- if (!gdb_set_interpreter (old_interp))
+ if (!gdb_interpreter_set (old_interp))
internal_error (__FILE__, __LINE__,
"Failed to initialize new interp \"%s\" %s",
interp->name, "and could not restore old interp!\n");
return 1;
}
-/* gdb_lookup_interpreter - Looks up the interpreter for NAME. If no
+/* gdb_interpreter_lookup - Looks up the interpreter for NAME. If no
such interpreter exists, return NULL, otherwise return a pointer to
the interpreter. */
struct gdb_interpreter *
-gdb_lookup_interpreter (char *name)
+gdb_interpreter_lookup (char *name)
{
struct gdb_interpreter *interp;
}
/* Returns the current interpreter. */
-struct gdb_interpreter *
-gdb_current_interpreter ()
+static struct gdb_interpreter *
+gdb_interpreter_current (void)
{
return current_interpreter;
}
/* Returns true if the current interp is the passed in name. */
int
-gdb_current_interpreter_is_named (char *interp_name)
+gdb_interpreter_current_is_named_p (char *interp_name)
{
- struct gdb_interpreter *current_interp = gdb_current_interpreter ();
+ struct gdb_interpreter *current_interp = gdb_interpreter_current ();
if (current_interp)
return (strcmp (current_interp->name, interp_name) == 0);
if (nrules < 2)
error ("usage: interpreter-exec <interpreter> [ <command> ... ]");
- old_interp = gdb_current_interpreter ();
+ old_interp = gdb_interpreter_current ();
- interp_to_use = gdb_lookup_interpreter (prules[0]);
+ interp_to_use = gdb_interpreter_lookup (prules[0]);
if (interp_to_use == NULL)
error ("Could not find interpreter \"%s\".", prules[0]);
old_quiet = gdb_interpreter_set_quiet (old_interp, 1);
use_quiet = gdb_interpreter_set_quiet (interp_to_use, 1);
- if (!gdb_set_interpreter (interp_to_use))
+ if (!gdb_interpreter_set (interp_to_use))
error ("Could not switch to interpreter \"%s\".", prules[0]);
for (i = 1; i < nrules; i++)
{
if (!gdb_interpreter_exec (prules[i]))
{
- gdb_set_interpreter (old_interp);
+ gdb_interpreter_set (old_interp);
gdb_interpreter_set_quiet (interp_to_use, old_quiet);
error ("error in command: \"%s\".", prules[i]);
break;
}
}
- gdb_set_interpreter (old_interp);
+ gdb_interpreter_set (old_interp);
gdb_interpreter_set_quiet (interp_to_use, use_quiet);
gdb_interpreter_set_quiet (old_interp, old_quiet);
}
};
extern struct gdb_interpreter
- *gdb_new_interpreter (char *name, void *data, struct ui_out *uiout,
+ *gdb_interpreter_new (char *name, void *data, struct ui_out *uiout,
struct gdb_interpreter_procs *procs);
-extern int gdb_add_interpreter (struct gdb_interpreter *interp);
-extern int gdb_set_interpreter (struct gdb_interpreter *interp);
-extern struct gdb_interpreter *gdb_lookup_interpreter (char *name);
-extern struct gdb_interpreter *gdb_current_interpreter ();
+extern int gdb_interpreter_set (struct gdb_interpreter *interp);
+extern struct gdb_interpreter *gdb_interpreter_lookup (char *name);
extern struct ui_out *gdb_interpreter_ui_out (struct gdb_interpreter *interp);
-extern int gdb_current_interpreter_is_named (char *interp_name);
+extern int gdb_interpreter_current_is_named_p (char *interp_name);
extern int gdb_interpreter_exec (char *command_str);
extern int gdb_interpreter_display_prompt_p (void);
-extern int gdb_interpreter_set_quiet (struct gdb_interpreter *interp,
- int quiet);
extern int gdb_interpreter_is_quiet_p (struct gdb_interpreter *interp);
+extern int gdb_interpreter_add (struct gdb_interpreter *interp);
extern struct gdb_interpreter_procs *gdb_interpreter_get_procs (struct
gdb_interpreter
*interp);
+2002-11-04 Elena Zannoni <ezannoni@redhat.com>
+
+ * mi-interp.c (mi_interpreter_resume): Ditto.
+ (mi_cmd_interpreter_exec): Use gdb_interpreter_lookup.
+ (_initialize_mi_interp): Use gdb_interpreter_new,
+ gdb_interpreter_add.
+ * mi-cmd-break.c (mi_cmd_break_insert): Use
+ gdb_interpreter_current_is_named_p.
+ (mi_cmd_break_watch): Ditto.
+ * mi-events.c (mi_interp_stack_changed_hook): Ditto.
+ (event_notify): Ditto.
+ * mi-main.c (captured_mi_execute_command): Use
+ gdb_interpreter_current_is_named_p.
+ (mi_load_progress): Ditto.
+
2002-11-04 Elena Zannoni <ezannoni@redhat.com>
* mi-interp.c (_initialize_mi_interp): Use mi_interpreter_prompt_p
handlers, so we won't get any event notifications sent out to the
client. MI3+ does NOT send breakpoint information with the -break-insert
command for this reason. */
- if (gdb_current_interpreter_is_named (GDB_INTERPRETER_MI2)
- || gdb_current_interpreter_is_named (GDB_INTERPRETER_MI1))
+ if (gdb_interpreter_current_is_named_p (GDB_INTERPRETER_MI2)
+ || gdb_interpreter_current_is_named_p (GDB_INTERPRETER_MI1))
old_hooks = set_gdb_event_hooks (&breakpoint_hooks);
/* Now we have what we need, let's insert the breakpoint! */
"mi_cmd_break_insert: Bad switch.");
}
- if (gdb_current_interpreter_is_named (GDB_INTERPRETER_MI2)
- || gdb_current_interpreter_is_named (GDB_INTERPRETER_MI1))
+ if (gdb_interpreter_current_is_named_p (GDB_INTERPRETER_MI2)
+ || gdb_interpreter_current_is_named_p (GDB_INTERPRETER_MI1))
set_gdb_event_hooks (old_hooks);
if (rc == GDB_RC_FAIL)
cannot use the same printing mechanisms. So for MI3+, we simply
rewind MI's uiout so that we can prevent GDB from printing
any information about the watchpoint we just inserted. */
- if (!gdb_current_interpreter_is_named (GDB_INTERPRETER_MI2)
- && !gdb_current_interpreter_is_named (GDB_INTERPRETER_MI1))
+ if (!gdb_interpreter_current_is_named_p (GDB_INTERPRETER_MI2)
+ && !gdb_interpreter_current_is_named_p (GDB_INTERPRETER_MI1))
mi_out_rewind (uiout);
return MI_CMD_DONE;
struct ui_out *saved_ui_out = uiout;
struct mi_out *tmp_mi_out;
- if (gdb_current_interpreter_is_named (GDB_INTERPRETER_MI1))
+ if (gdb_interpreter_current_is_named_p (GDB_INTERPRETER_MI1))
uiout = gdb_interpreter_ui_out (mi1_interp);
else
uiout = gdb_interpreter_ui_out (mi_interp);
{
va_list args;
- if (!gdb_current_interpreter_is_named (GDB_INTERPRETER_MI1)
- && !gdb_current_interpreter_is_named (GDB_INTERPRETER_MI2))
+ if (!gdb_interpreter_current_is_named_p (GDB_INTERPRETER_MI1)
+ && !gdb_interpreter_current_is_named_p (GDB_INTERPRETER_MI2))
{
va_start (args, string);
vfprintf_unfiltered (mi_event_channel, string, args);
/* Route target output through the MI. */
gdb_stdtarg = mi_stdtarg;
- /* Replace all the hooks that we know about. There really needs to be a better way
- of doing this... */
+ /* Replace all the hooks that we know about. There really needs to
+ be a better way of doing this... */
clear_interpreter_hooks ();
set_gdb_event_hooks (&mi_event_handlers);
show_load_progress = mi_load_progress;
/* If we're _the_ interpreter, take control. */
- if (gdb_current_interpreter_is_named (GDB_INTERPRETER_MI2))
+ if (gdb_interpreter_current_is_named_p (GDB_INTERPRETER_MI2))
command_loop_hook = mi2_command_loop;
- else if (gdb_current_interpreter_is_named (GDB_INTERPRETER_MI1))
+ else if (gdb_interpreter_current_is_named_p (GDB_INTERPRETER_MI1))
command_loop_hook = mi1_command_loop;
- else if (gdb_current_interpreter_is_named (GDB_INTERPRETER_MI))
+ else if (gdb_interpreter_current_is_named_p (GDB_INTERPRETER_MI))
command_loop_hook = mi2_command_loop;
else
return 0;
return MI_CMD_ERROR;
}
- interp_to_use = gdb_lookup_interpreter (argv[0]);
+ interp_to_use = gdb_interpreter_lookup (argv[0]);
if (interp_to_use == NULL)
{
xasprintf (&mi_error_message,
if (mi1_interp == NULL)
{
mi1_interp =
- gdb_new_interpreter (GDB_INTERPRETER_MI1, NULL, mi_out_new (1),
+ gdb_interpreter_new (GDB_INTERPRETER_MI1, NULL, mi_out_new (1),
&procs);
if (mi1_interp == NULL)
error
("Couldn't allocate a new interpreter for the mi1 interpreter\n");
- if (gdb_add_interpreter (mi1_interp) != 1)
+ if (gdb_interpreter_add (mi1_interp) != 1)
error ("Couldn't add the mi1 interpreter to gdb.\n");
}
if (mi2_interp == NULL)
{
mi2_interp =
- gdb_new_interpreter (GDB_INTERPRETER_MI2, NULL, mi_out_new (2),
+ gdb_interpreter_new (GDB_INTERPRETER_MI2, NULL, mi_out_new (2),
&procs);
if (mi2_interp == NULL)
error
("Couldn't allocate a new interpreter for the mi2 interpreter\n");
- if (gdb_add_interpreter (mi2_interp) != 1)
+ if (gdb_interpreter_add (mi2_interp) != 1)
error ("Couldn't add the mi2 interpreter to gdb.\n");
}
if (mi_interp == NULL)
{
mi_interp =
- gdb_new_interpreter (GDB_INTERPRETER_MI, NULL, mi_out_new (3),
+ gdb_interpreter_new (GDB_INTERPRETER_MI, NULL, mi_out_new (3),
&procs);
if (mi_interp == NULL)
error
("Couldn't allocate a new interpreter for the mi interpreter\n");
- if (gdb_add_interpreter (mi_interp) != 1)
+ if (gdb_interpreter_add (mi_interp) != 1)
error ("Couldn't add the mi interpreter to gdb.\n");
}
}
mi_execute_cli_command ("%s", context->command);
/* If we changed interpreters, DON'T print out anything. */
- if (gdb_current_interpreter_is_named (GDB_INTERPRETER_MI)
- || gdb_current_interpreter_is_named (GDB_INTERPRETER_MI1)
- || gdb_current_interpreter_is_named (GDB_INTERPRETER_MI2))
+ if (gdb_interpreter_current_is_named_p (GDB_INTERPRETER_MI)
+ || gdb_interpreter_current_is_named_p (GDB_INTERPRETER_MI2)
+ || gdb_interpreter_current_is_named_p (GDB_INTERPRETER_MI1))
{
/* print the result */
/* FIXME: Check for errors here. */
static char *previous_sect_name = NULL;
int new_section;
- if (!gdb_current_interpreter_is_named (GDB_INTERPRETER_MI)
- && !gdb_current_interpreter_is_named (GDB_INTERPRETER_MI1)
- && !gdb_current_interpreter_is_named (GDB_INTERPRETER_MI2))
+ if (!gdb_interpreter_current_is_named_p (GDB_INTERPRETER_MI)
+ && !gdb_interpreter_current_is_named_p (GDB_INTERPRETER_MI2)
+ && !gdb_interpreter_current_is_named_p (GDB_INTERPRETER_MI1))
return;
update_threshold.tv_sec = 0;
/* All the interpreters should have had a look at things by now.
Initialize the selected interpreter. */
{
+
+ /* There will always be an interpreter. Either the one specified
+ by the user at start up or the console. */
+
struct gdb_interpreter *interp;
if (interpreter_p == NULL)
interpreter_p = xstrdup (GDB_INTERPRETER_CONSOLE);
- interp = gdb_lookup_interpreter (interpreter_p);
+ interp = gdb_interpreter_lookup (interpreter_p);
if (interp == NULL)
{
interpreter_p);
exit (1);
}
- if (!gdb_set_interpreter (interp))
+ if (!gdb_interpreter_set (interp))
{
fprintf_unfiltered (gdb_stderr, "Interpreter `%s' failed to initialize.\n",
interpreter_p);