Simplify starting the command event loop

All interpreter types (CLI/TUI/MI) print the prompt, and then call
start_event_loop.

Because we'll need an interpreter hook to display the
interpreter-specific prompt before going back to the event loop,
without actually starting an event loop, this patch moves the
start_event_loop call to common code, and replaces the command_loop
hook with a pre_command_look hook, that now just prints the prompt.

Turns out to be a cleanup on its own right anyway.

gdb/ChangeLog:
2016-06-21  Pedro Alves  <palves@redhat.com>

	* cli/cli-interp.c (cli_interpreter_pre_command_loop): New
	function.
	(cli_interp_procs): Install it instead of cli_command_loop.
	* cli/cli-interp.h (cli_interpreter_pre_command_loop): Declare.
	* event-top.c (cli_command_loop): Delete.
	* interps.c (interp_new): Remove reference to command_loop_proc.
	(current_interp_command_loop): Delete.
	(interp_pre_command_loop): New function.
	(interp_command_loop_ftype): Delete.
	* interps.h (interp_pre_command_loop_ftype): New typedef.
	(struct interp_procs) <command_loop_proc>: Delele field.
	<pre_command_loop_proc>: New field.
	(current_interp_command_loop): Delete declaration.
	(interp_pre_command_loop): New declaration.
	* main.c (captured_command_loop): Call interp_pre_command_loop
	instead of current_interp_command_loop and start an event loop.
	* mi/mi-interp.c (mi_command_loop): Delete.
	(mi_interpreter_pre_command_loop): New.
	(mi_interp_procs): Update.
	* tui/tui-interp.c (tui_interp_procs): Install
	cli_interpreter_pre_command_loop instead of cli_command_loop.
This commit is contained in:
Pedro Alves
2016-06-21 01:11:51 +01:00
parent 9204d6922c
commit b2d86570b3
9 changed files with 59 additions and 36 deletions

View File

@@ -117,9 +117,6 @@ interp_new (const char *name, const struct interp_procs *procs, void *data)
new_interp->procs = procs;
new_interp->inited = 0;
/* Check for required procs. */
gdb_assert (procs->command_loop_proc != NULL);
return new_interp;
}
@@ -411,16 +408,15 @@ command_interp (void)
return ui_interp->current_interpreter;
}
/* Run the current command interpreter's main loop. */
/* See interps.h. */
void
current_interp_command_loop (void)
interp_pre_command_loop (struct interp *interp)
{
struct ui_interp_info *ui_interp = get_current_interp_info ();
struct interp *interp = ui_interp->current_interpreter;
gdb_assert (interp != NULL);
gdb_assert (ui_interp->current_interpreter != NULL);
interp->procs->command_loop_proc (interp->data);
if (interp->procs->pre_command_loop_proc != NULL)
interp->procs->pre_command_loop_proc (interp);
}
/* See interp.h */