+2014-05-29 Pedro Alves <palves@redhat.com>
+
+ * cli/cli-interp.c (cli_interpreter_display_prompt_p): Delete.
+ (_initialize_cli_interp): Adjust.
+ * event-loop.c: Include "observer.h".
+ (start_event_loop): Notify 'command_error' observers instead of
+ calling display_gdb_prompt. Remove FIXME comment.
+ * event-top.c (display_gdb_prompt): Remove call into the
+ interpreters.
+ * inf-loop.c: Include "observer.h".
+ (inferior_event_handler): Notify 'command_error' observers instead
+ of calling display_gdb_prompt.
+ * infrun.c (fetch_inferior_event): Notify 'sync_execution_done'
+ observers instead of calling display_gdb_prompt.
+ * interps.c (interp_set): Don't call display_gdb_prompt.
+ (current_interp_display_prompt_p): Delete.
+ * interps.h (interp_prompt_p): Delete declaration.
+ (interp_prompt_p_ftype): Delete.
+ (struct interp_procs) <prompt_proc_p>: Delete field.
+ (current_interp_display_prompt_p): Delete declaration.
+ * mi-interp.c (mi_interpreter_prompt_p): Delete.
+ (_initialize_mi_interp): Adjust.
+ * tui-interp.c (tui_init): Install 'sync_execution_done' and
+ 'command_error' observers.
+ (tui_on_sync_execution_done, tui_on_command_error): New
+ functions.
+ (tui_display_prompt_p): Delete.
+ (_initialize_tui_interp): Adjust.
+
2014-05-29 Pedro Alves <palves@redhat.com>
PR gdb/13860
print_no_history_reason (cli_uiout);
}
+/* Observer for the sync_execution_done notification. */
+
+static void
+cli_on_sync_execution_done (void)
+{
+ if (!interp_quiet_p (cli_interp))
+ display_gdb_prompt (NULL);
+}
+
+/* Observer for the command_error notification. */
+
+static void
+cli_on_command_error (void)
+{
+ if (!interp_quiet_p (cli_interp))
+ display_gdb_prompt (NULL);
+}
+
/* These implement the cli out interpreter: */
static void *
observer_attach_signal_exited (cli_on_signal_exited);
observer_attach_exited (cli_on_exited);
observer_attach_no_history (cli_on_no_history);
+ observer_attach_sync_execution_done (cli_on_sync_execution_done);
+ observer_attach_command_error (cli_on_command_error);
return NULL;
}
return 1;
}
-/* Don't display the prompt if we are set quiet. */
-static int
-cli_interpreter_display_prompt_p (void *data)
-{
- if (interp_quiet_p (NULL))
- return 0;
- else
- return 1;
-}
-
static struct gdb_exception
cli_interpreter_exec (void *data, const char *command_str)
{
cli_interpreter_resume, /* resume_proc */
cli_interpreter_suspend, /* suspend_proc */
cli_interpreter_exec, /* exec_proc */
- cli_interpreter_display_prompt_p, /* prompt_proc_p */
cli_ui_out, /* ui_out_proc */
NULL, /* set_logging_proc */
cli_command_loop /* command_loop_proc */
+2014-05-29 Pedro Alves <palves@redhat.com>
+
+ * observer.texi (sync_execution_done, command_error): New
+ subjects.
+
2014-05-29 Pedro Alves <palves@redhat.com>
PR gdb/13860
Reverse execution: target ran out of history info.
@end deftypefun
+@deftypefun void sync_execution_done (void)
+A synchronous command finished.
+@end deftypefun
+
+@deftypefun void command_error (void)
+An error was caught while executing a command.
+@end deftypefun
+
@deftypefun void target_changed (struct target_ops *@var{target})
The target's register contents have changed.
@end deftypefun
#include "exceptions.h"
#include "gdb_assert.h"
#include "gdb_select.h"
+#include "observer.h"
/* Tell create_file_handler what events we are interested in.
This is used by the select version of the event loop. */
/* If we long-jumped out of do_one_event, we probably didn't
get around to resetting the prompt, which leaves readline
in a messed-up state. Reset it here. */
- /* FIXME: this should really be a call to a hook that is
- interface specific, because interfaces can display the
- prompt in their own way. */
- display_gdb_prompt (0);
+ observer_notify_command_error ();
/* This call looks bizarre, but it is required. If the user
entered a command that caused an error,
after_char_processing_hook won't be called from
/* Reset the nesting depth used when trace-commands is set. */
reset_command_nest_depth ();
- /* Each interpreter has its own rules on displaying the command
- prompt. */
- if (!current_interp_display_prompt_p ())
- return;
-
old_chain = make_cleanup (free_current_contents, &actual_gdb_prompt);
/* Do not call the python hook on an explicit prompt change as
#include "continuations.h"
#include "interps.h"
#include "top.h"
+#include "observer.h"
static int fetch_inferior_event_wrapper (gdb_client_data client_data);
do_all_intermediate_continuations (1);
do_all_continuations (1);
async_enable_stdin ();
- display_gdb_prompt (0);
+ observer_notify_command_error ();
}
break;
restore the prompt (a synchronous execution command has finished,
and we're ready for input). */
if (interpreter_async && was_sync && !sync_execution)
- display_gdb_prompt (0);
+ observer_notify_sync_execution_done ();
if (cmd_done
&& !was_sync
return 0;
}
- /* Finally, put up the new prompt to show that we are indeed here.
- Also, display_gdb_prompt for the console does some readline magic
- which is needed for the console interpreter, at least... */
-
- if (!first_time)
+ if (!first_time && !interp_quiet_p (interp))
{
- if (!interp_quiet_p (interp))
- {
- xsnprintf (buffer, sizeof (buffer),
- "Switching to interpreter \"%.24s\".\n", interp->name);
- ui_out_text (current_uiout, buffer);
- }
- display_gdb_prompt (NULL);
+ xsnprintf (buffer, sizeof (buffer),
+ "Switching to interpreter \"%.24s\".\n", interp->name);
+ ui_out_text (current_uiout, buffer);
}
return 1;
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. */
-int
-current_interp_display_prompt_p (void)
-{
- if (current_interpreter == NULL
- || current_interpreter->procs->prompt_proc_p == NULL)
- return 0;
- else
- return current_interpreter->procs->prompt_proc_p (current_interpreter->
- data);
-}
-
/* The interpreter that is active while `interp_exec' is active, NULL
at all other times. */
static struct interp *command_interpreter;
extern int interp_resume (struct interp *interp);
extern int interp_suspend (struct interp *interp);
-extern int interp_prompt_p (struct interp *interp);
extern struct gdb_exception interp_exec (struct interp *interp,
const char *command);
extern int interp_quiet_p (struct interp *interp);
typedef void *(interp_init_ftype) (struct interp *self, int top_level);
typedef int (interp_resume_ftype) (void *data);
typedef int (interp_suspend_ftype) (void *data);
-typedef int (interp_prompt_p_ftype) (void *data);
typedef struct gdb_exception (interp_exec_ftype) (void *data,
const char *command);
typedef void (interp_command_loop_ftype) (void *data);
interp_resume_ftype *resume_proc;
interp_suspend_ftype *suspend_proc;
interp_exec_ftype *exec_proc;
- interp_prompt_p_ftype *prompt_proc_p;
/* Returns the ui_out currently used to collect results for this
interpreter. It can be a formatter for stdout, as is the case
extern struct interp *interp_set_temp (const char *name);
extern int current_interp_named_p (const char *name);
-extern int current_interp_display_prompt_p (void);
+
extern void current_interp_command_loop (void);
/* Call this function to give the current interpreter an opportunity
return exception_none;
}
-/* Never display the default GDB prompt in MI case. */
-
-static int
-mi_interpreter_prompt_p (void *data)
-{
- return 0;
-}
-
void
mi_cmd_interpreter_exec (char *command, char **argv, int argc)
{
mi_interpreter_resume, /* resume_proc */
mi_interpreter_suspend, /* suspend_proc */
mi_interpreter_exec, /* exec_proc */
- mi_interpreter_prompt_p, /* prompt_proc_p */
mi_ui_out, /* ui_out_proc */
mi_set_logging, /* set_logging_proc */
mi_command_loop /* command_loop_proc */
print_no_history_reason (tui_ui_out (tui_interp));
}
+/* Observer for the sync_execution_done notification. */
+
+static void
+tui_on_sync_execution_done (void)
+{
+ if (!interp_quiet_p (tui_interp))
+ display_gdb_prompt (NULL);
+}
+
+/* Observer for the command_error notification. */
+
+static void
+tui_on_command_error (void)
+{
+ if (!interp_quiet_p (tui_interp))
+ display_gdb_prompt (NULL);
+}
+
/* These implement the TUI interpreter. */
static void *
observer_attach_signal_exited (tui_on_signal_exited);
observer_attach_exited (tui_on_exited);
observer_attach_no_history (tui_on_no_history);
+ observer_attach_sync_execution_done (tui_on_sync_execution_done);
+ observer_attach_command_error (tui_on_command_error);
return NULL;
}
return 1;
}
-/* Display the prompt if we are silent. */
-
-static int
-tui_display_prompt_p (void *data)
-{
- if (interp_quiet_p (NULL))
- return 0;
- else
- return 1;
-}
-
static struct ui_out *
tui_ui_out (struct interp *self)
{
tui_resume,
tui_suspend,
tui_exec,
- tui_display_prompt_p,
tui_ui_out,
NULL,
cli_command_loop