along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "defs.h"
+#include "cli/cli-interp.h"
#include "interps.h"
#include "top.h"
#include "event-top.h"
#include "tui/tui-io.h"
#include "infrun.h"
#include "observer.h"
+#include "gdbthread.h"
static struct ui_out *tui_ui_out (struct interp *self);
static void
tui_on_normal_stop (struct bpstats *bs, int print_frame)
{
- struct switch_thru_all_uis state;
+ if (!print_frame)
+ return;
- SWITCH_THRU_ALL_UIS (state)
+ SWITCH_THRU_ALL_UIS ()
{
- struct interp *tui = as_tui_interp (top_level_interpreter ());
+ struct interp *interp = top_level_interpreter ();
+ struct interp *tui = as_tui_interp (interp);
+ struct thread_info *thread;
if (tui == NULL)
continue;
- if (print_frame)
+ thread = inferior_thread ();
+ if (should_print_stop_to_console (interp, thread))
print_stop_event (tui_ui_out (tui));
}
}
static void
tui_on_signal_received (enum gdb_signal siggnal)
{
- struct switch_thru_all_uis state;
-
- SWITCH_THRU_ALL_UIS (state)
+ SWITCH_THRU_ALL_UIS ()
{
struct interp *tui = as_tui_interp (top_level_interpreter ());
static void
tui_on_end_stepping_range (void)
{
- struct switch_thru_all_uis state;
-
- SWITCH_THRU_ALL_UIS (state)
+ SWITCH_THRU_ALL_UIS ()
{
struct interp *tui = as_tui_interp (top_level_interpreter ());
static void
tui_on_signal_exited (enum gdb_signal siggnal)
{
- struct switch_thru_all_uis state;
-
- SWITCH_THRU_ALL_UIS (state)
+ SWITCH_THRU_ALL_UIS ()
{
struct interp *tui = as_tui_interp (top_level_interpreter ());
static void
tui_on_exited (int exitstatus)
{
- struct switch_thru_all_uis state;
-
- SWITCH_THRU_ALL_UIS (state)
+ SWITCH_THRU_ALL_UIS ()
{
struct interp *tui = as_tui_interp (top_level_interpreter ());
static void
tui_on_no_history (void)
{
- struct switch_thru_all_uis state;
-
- SWITCH_THRU_ALL_UIS (state)
+ SWITCH_THRU_ALL_UIS ()
{
struct interp *tui = as_tui_interp (top_level_interpreter ());
display_gdb_prompt (NULL);
}
+/* Observer for the user_selected_context_changed notification. */
+
+static void
+tui_on_user_selected_context_changed (user_selected_what selection)
+{
+ struct thread_info *tp;
+
+ /* This event is suppressed. */
+ if (cli_suppress_notification.user_selected_context)
+ return;
+
+ tp = find_thread_ptid (inferior_ptid);
+
+ SWITCH_THRU_ALL_UIS ()
+ {
+ struct interp *tui = as_tui_interp (top_level_interpreter ());
+
+ if (tui == NULL)
+ continue;
+
+ if (selection & USER_SELECTED_INFERIOR)
+ print_selected_inferior (tui_ui_out (tui));
+
+ if (tp != NULL
+ && ((selection & (USER_SELECTED_THREAD | USER_SELECTED_FRAME))))
+ print_selected_thread_frame (tui_ui_out (tui), selection);
+
+ }
+}
+
/* These implement the TUI interpreter. */
static void *
static int
tui_resume (void *data)
{
+ struct ui *ui = current_ui;
struct ui_file *stream;
/* gdb_setup_readline will change gdb_stdout. If the TUI was
previously writing to gdb_stdout, then set it to the new
gdb_stdout afterwards. */
- stream = cli_out_set_stream (tui_old_uiout, gdb_stdout);
+ stream = tui_old_uiout->set_stream (gdb_stdout);
if (stream != gdb_stdout)
{
- cli_out_set_stream (tui_old_uiout, stream);
+ tui_old_uiout->set_stream (stream);
stream = NULL;
}
- gdb_setup_readline ();
+ gdb_setup_readline (1);
+
+ ui->input_handler = command_line_handler;
if (stream != NULL)
- cli_out_set_stream (tui_old_uiout, gdb_stdout);
+ tui_old_uiout->set_stream (gdb_stdout);
if (tui_start_enabled)
tui_enable ();
tui_exec,
tui_ui_out,
NULL,
- cli_command_loop
+ cli_interpreter_pre_command_loop,
+ cli_interpreter_supports_command_editing,
};
/* Factory for TUI interpreters. */
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);
+ observer_attach_user_selected_context_changed
+ (tui_on_user_selected_context_changed);
}