+2016-10-21 Tom Tromey <tom@tromey.com>
+
+ * tui/tui-interp.c (tui_on_normal_stop, tui_on_signal_received)
+ (tui_on_end_stepping_range, tui_on_signal_exited, tui_on_exited)
+ (tui_on_no_history, tui_on_user_selected_context_changed):
+ Update.
+ * top.h (switch_thru_all_uis): New class.
+ (SWITCH_THRU_ALL_UIS): Rewrite.
+ (make_cleanup_restore_current_ui, switch_thru_all_uis_init)
+ (switch_thru_all_uis_cond, switch_thru_all_uis_next): Don't
+ declare.
+ * mi/mi-interp.c (mi_new_thread, mi_thread_exit)
+ (mi_record_changed, mi_inferior_added, mi_inferior_appeared)
+ (mi_inferior_exit, mi_inferior_removed, mi_on_signal_received)
+ (mi_on_end_stepping_range, mi_on_signal_exited, mi_on_exited)
+ (mi_on_no_history, mi_on_normal_stop, mi_traceframe_changed)
+ (mi_tsv_created, mi_tsv_deleted, mi_tsv_modified)
+ (mi_breakpoint_created, mi_breakpoint_deleted)
+ (mi_breakpoint_modified, mi_output_running_pid, mi_on_resume)
+ (mi_solib_loaded, mi_solib_unloaded, mi_command_param_changed)
+ (mi_memory_changed, mi_user_selected_context_changed): Update.
+ * infrun.c (all_uis_check_sync_execution_done)
+ (all_uis_on_sync_execution_starting, normal_stop): Update.
+ * event-top.c (restore_ui_cleanup)
+ (make_cleanup_restore_current_ui, switch_thru_all_uis_init)
+ (switch_thru_all_uis_cond, switch_thru_all_uis_next): Remove.
+ * cli/cli-interp.c (cli_on_normal_stop, cli_on_signal_received)
+ (cli_on_end_stepping_range, cli_on_signal_exited, cli_on_exited)
+ (cli_on_no_history, cli_on_user_selected_context_changed):
+ Update.
+ * breakpoint.c (watchpoint_check): Update.
+
2016-10-21 Tom Tromey <tom@tromey.com>
* xcoffread.c (record_minimal_symbol, scan_xcoff_symtab): Add
}
else
{
- struct switch_thru_all_uis state;
-
/* This seems like the only logical thing to do because
if we temporarily ignored the watchpoint, then when
we reenter the block in which it is valid it contains
already. So we have no choice but print the information
here. */
- SWITCH_THRU_ALL_UIS (state)
+ SWITCH_THRU_ALL_UIS ()
{
struct ui_out *uiout = current_uiout;
case 0:
/* Error from catch_errors. */
{
- struct switch_thru_all_uis state;
-
- SWITCH_THRU_ALL_UIS (state)
+ SWITCH_THRU_ALL_UIS ()
{
printf_filtered (_("Watchpoint %d deleted.\n"),
b->base.number);
static void
cli_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 *interp = top_level_interpreter ();
struct cli_interp *cli = as_cli_interp (interp);
static void
cli_on_signal_received (enum gdb_signal siggnal)
{
- struct switch_thru_all_uis state;
-
- SWITCH_THRU_ALL_UIS (state)
+ SWITCH_THRU_ALL_UIS ()
{
struct cli_interp *cli = as_cli_interp (top_level_interpreter ());
static void
cli_on_end_stepping_range (void)
{
- struct switch_thru_all_uis state;
-
- SWITCH_THRU_ALL_UIS (state)
+ SWITCH_THRU_ALL_UIS ()
{
struct cli_interp *cli = as_cli_interp (top_level_interpreter ());
static void
cli_on_signal_exited (enum gdb_signal siggnal)
{
- struct switch_thru_all_uis state;
-
- SWITCH_THRU_ALL_UIS (state)
+ SWITCH_THRU_ALL_UIS ()
{
struct cli_interp *cli = as_cli_interp (top_level_interpreter ());
static void
cli_on_exited (int exitstatus)
{
- struct switch_thru_all_uis state;
-
- SWITCH_THRU_ALL_UIS (state)
+ SWITCH_THRU_ALL_UIS ()
{
struct cli_interp *cli = as_cli_interp (top_level_interpreter ());
static void
cli_on_no_history (void)
{
- struct switch_thru_all_uis state;
-
- SWITCH_THRU_ALL_UIS (state)
+ SWITCH_THRU_ALL_UIS ()
{
struct cli_interp *cli = as_cli_interp (top_level_interpreter ());
static void
cli_on_user_selected_context_changed (user_selected_what selection)
{
- struct switch_thru_all_uis state;
struct thread_info *tp;
/* This event is suppressed. */
tp = find_thread_ptid (inferior_ptid);
- SWITCH_THRU_ALL_UIS (state)
+ SWITCH_THRU_ALL_UIS ()
{
struct cli_interp *cli = as_cli_interp (top_level_interpreter ());
struct ui *current_ui;
struct ui *ui_list;
-/* A cleanup handler that restores the current UI. */
-
-static void
-restore_ui_cleanup (void *data)
-{
- current_ui = (struct ui *) data;
-}
-
-/* See top.h. */
-
-struct cleanup *
-make_cleanup_restore_current_ui (void)
-{
- return make_cleanup (restore_ui_cleanup, current_ui);
-}
-
-/* See top.h. */
-
-void
-switch_thru_all_uis_init (struct switch_thru_all_uis *state)
-{
- state->iter = ui_list;
- state->old_chain = make_cleanup_restore_current_ui ();
-}
-
-/* See top.h. */
-
-int
-switch_thru_all_uis_cond (struct switch_thru_all_uis *state)
-{
- if (state->iter != NULL)
- {
- current_ui = state->iter;
- return 1;
- }
- else
- {
- do_cleanups (state->old_chain);
- return 0;
- }
-}
-
-/* See top.h. */
-
-void
-switch_thru_all_uis_next (struct switch_thru_all_uis *state)
-{
- state->iter = state->iter->next;
-}
-
/* Get a pointer to the current UI's line buffer. This is used to
construct a whole line of input from partial input. */
void
all_uis_check_sync_execution_done (void)
{
- struct switch_thru_all_uis state;
-
- SWITCH_THRU_ALL_UIS (state)
+ SWITCH_THRU_ALL_UIS ()
{
check_curr_ui_sync_execution_done ();
}
void
all_uis_on_sync_execution_starting (void)
{
- struct switch_thru_all_uis state;
-
- SWITCH_THRU_ALL_UIS (state)
+ SWITCH_THRU_ALL_UIS ()
{
if (current_ui->prompt_state == PROMPT_NEEDED)
async_disable_stdin ();
ptid_t last_ptid;
struct cleanup *old_chain = make_cleanup (null_cleanup, NULL);
ptid_t pid_ptid;
- struct switch_thru_all_uis state;
get_last_target_status (&last_ptid, &last);
&& last.kind != TARGET_WAITKIND_EXITED
&& last.kind != TARGET_WAITKIND_NO_RESUMED)
{
- SWITCH_THRU_ALL_UIS (state)
+ SWITCH_THRU_ALL_UIS ()
{
target_terminal_ours_for_output ();
printf_filtered (_("[Switching to %s]\n"),
if (last.kind == TARGET_WAITKIND_NO_RESUMED)
{
- SWITCH_THRU_ALL_UIS (state)
+ SWITCH_THRU_ALL_UIS ()
if (current_ui->prompt_state == PROMPT_BLOCKED)
{
target_terminal_ours_for_output ();
if (stopped_by_random_signal)
disable_current_display ();
- SWITCH_THRU_ALL_UIS (state)
+ SWITCH_THRU_ALL_UIS ()
{
async_enable_stdin ();
}
mi_new_thread (struct thread_info *t)
{
struct inferior *inf = find_inferior_ptid (t->ptid);
- struct switch_thru_all_uis state;
gdb_assert (inf);
- SWITCH_THRU_ALL_UIS (state)
+ SWITCH_THRU_ALL_UIS ()
{
struct mi_interp *mi = as_mi_interp (top_level_interpreter ());
struct cleanup *old_chain;
static void
mi_thread_exit (struct thread_info *t, int silent)
{
- struct switch_thru_all_uis state;
-
if (silent)
return;
- SWITCH_THRU_ALL_UIS (state)
+ SWITCH_THRU_ALL_UIS ()
{
struct mi_interp *mi = as_mi_interp (top_level_interpreter ());
struct cleanup *old_chain;
mi_record_changed (struct inferior *inferior, int started, const char *method,
const char *format)
{
- struct switch_thru_all_uis state;
-
- SWITCH_THRU_ALL_UIS (state)
+ SWITCH_THRU_ALL_UIS ()
{
struct mi_interp *mi = as_mi_interp (top_level_interpreter ());
struct cleanup *old_chain;
static void
mi_inferior_added (struct inferior *inf)
{
- struct switch_thru_all_uis state;
-
- SWITCH_THRU_ALL_UIS (state)
+ SWITCH_THRU_ALL_UIS ()
{
struct interp *interp;
struct mi_interp *mi;
static void
mi_inferior_appeared (struct inferior *inf)
{
- struct switch_thru_all_uis state;
-
- SWITCH_THRU_ALL_UIS (state)
+ SWITCH_THRU_ALL_UIS ()
{
struct mi_interp *mi = as_mi_interp (top_level_interpreter ());
struct cleanup *old_chain;
static void
mi_inferior_exit (struct inferior *inf)
{
- struct switch_thru_all_uis state;
-
- SWITCH_THRU_ALL_UIS (state)
+ SWITCH_THRU_ALL_UIS ()
{
struct mi_interp *mi = as_mi_interp (top_level_interpreter ());
struct cleanup *old_chain;
static void
mi_inferior_removed (struct inferior *inf)
{
- struct switch_thru_all_uis state;
-
- SWITCH_THRU_ALL_UIS (state)
+ SWITCH_THRU_ALL_UIS ()
{
struct mi_interp *mi = as_mi_interp (top_level_interpreter ());
struct cleanup *old_chain;
static void
mi_on_signal_received (enum gdb_signal siggnal)
{
- struct switch_thru_all_uis state;
-
- SWITCH_THRU_ALL_UIS (state)
+ SWITCH_THRU_ALL_UIS ()
{
struct mi_interp *mi = find_mi_interp ();
static void
mi_on_end_stepping_range (void)
{
- struct switch_thru_all_uis state;
-
- SWITCH_THRU_ALL_UIS (state)
+ SWITCH_THRU_ALL_UIS ()
{
struct mi_interp *mi = find_mi_interp ();
static void
mi_on_signal_exited (enum gdb_signal siggnal)
{
- struct switch_thru_all_uis state;
-
- SWITCH_THRU_ALL_UIS (state)
+ SWITCH_THRU_ALL_UIS ()
{
struct mi_interp *mi = find_mi_interp ();
static void
mi_on_exited (int exitstatus)
{
- struct switch_thru_all_uis state;
-
- SWITCH_THRU_ALL_UIS (state)
+ SWITCH_THRU_ALL_UIS ()
{
struct mi_interp *mi = find_mi_interp ();
static void
mi_on_no_history (void)
{
- struct switch_thru_all_uis state;
-
- SWITCH_THRU_ALL_UIS (state)
+ SWITCH_THRU_ALL_UIS ()
{
struct mi_interp *mi = find_mi_interp ();
static void
mi_on_normal_stop (struct bpstats *bs, int print_frame)
{
- struct switch_thru_all_uis state;
-
- SWITCH_THRU_ALL_UIS (state)
+ SWITCH_THRU_ALL_UIS ()
{
if (as_mi_interp (top_level_interpreter ()) == NULL)
continue;
static void
mi_traceframe_changed (int tfnum, int tpnum)
{
- struct switch_thru_all_uis state;
-
if (mi_suppress_notification.traceframe)
return;
- SWITCH_THRU_ALL_UIS (state)
+ SWITCH_THRU_ALL_UIS ()
{
struct mi_interp *mi = as_mi_interp (top_level_interpreter ());
struct cleanup *old_chain;
static void
mi_tsv_created (const struct trace_state_variable *tsv)
{
- struct switch_thru_all_uis state;
-
- SWITCH_THRU_ALL_UIS (state)
+ SWITCH_THRU_ALL_UIS ()
{
struct mi_interp *mi = as_mi_interp (top_level_interpreter ());
struct cleanup *old_chain;
static void
mi_tsv_deleted (const struct trace_state_variable *tsv)
{
- struct switch_thru_all_uis state;
-
- SWITCH_THRU_ALL_UIS (state)
+ SWITCH_THRU_ALL_UIS ()
{
struct mi_interp *mi = as_mi_interp (top_level_interpreter ());
struct cleanup *old_chain;
static void
mi_tsv_modified (const struct trace_state_variable *tsv)
{
- struct switch_thru_all_uis state;
-
- SWITCH_THRU_ALL_UIS (state)
+ SWITCH_THRU_ALL_UIS ()
{
struct mi_interp *mi = as_mi_interp (top_level_interpreter ());
struct ui_out *mi_uiout;
static void
mi_breakpoint_created (struct breakpoint *b)
{
- struct switch_thru_all_uis state;
-
if (mi_suppress_notification.breakpoint)
return;
if (b->number <= 0)
return;
- SWITCH_THRU_ALL_UIS (state)
+ SWITCH_THRU_ALL_UIS ()
{
struct mi_interp *mi = as_mi_interp (top_level_interpreter ());
struct ui_out *mi_uiout;
static void
mi_breakpoint_deleted (struct breakpoint *b)
{
- struct switch_thru_all_uis state;
-
if (mi_suppress_notification.breakpoint)
return;
if (b->number <= 0)
return;
- SWITCH_THRU_ALL_UIS (state)
+ SWITCH_THRU_ALL_UIS ()
{
struct mi_interp *mi = as_mi_interp (top_level_interpreter ());
struct cleanup *old_chain;
static void
mi_breakpoint_modified (struct breakpoint *b)
{
- struct switch_thru_all_uis state;
-
if (mi_suppress_notification.breakpoint)
return;
if (b->number <= 0)
return;
- SWITCH_THRU_ALL_UIS (state)
+ SWITCH_THRU_ALL_UIS ()
{
struct mi_interp *mi = as_mi_interp (top_level_interpreter ());
struct cleanup *old_chain;
mi_output_running_pid (struct thread_info *info, void *arg)
{
ptid_t *ptid = (ptid_t *) arg;
- struct switch_thru_all_uis state;
- SWITCH_THRU_ALL_UIS (state)
+ SWITCH_THRU_ALL_UIS ()
{
struct mi_interp *mi = as_mi_interp (top_level_interpreter ());
mi_on_resume (ptid_t ptid)
{
struct thread_info *tp = NULL;
- struct switch_thru_all_uis state;
if (ptid_equal (ptid, minus_one_ptid) || ptid_is_pid (ptid))
tp = inferior_thread ();
if (tp->control.in_infcall)
return;
- SWITCH_THRU_ALL_UIS (state)
+ SWITCH_THRU_ALL_UIS ()
{
struct mi_interp *mi = as_mi_interp (top_level_interpreter ());
struct cleanup *old_chain;
static void
mi_solib_loaded (struct so_list *solib)
{
- struct switch_thru_all_uis state;
-
- SWITCH_THRU_ALL_UIS (state)
+ SWITCH_THRU_ALL_UIS ()
{
struct mi_interp *mi = as_mi_interp (top_level_interpreter ());
struct ui_out *uiout;
static void
mi_solib_unloaded (struct so_list *solib)
{
- struct switch_thru_all_uis state;
-
- SWITCH_THRU_ALL_UIS (state)
+ SWITCH_THRU_ALL_UIS ()
{
struct mi_interp *mi = as_mi_interp (top_level_interpreter ());
struct ui_out *uiout;
static void
mi_command_param_changed (const char *param, const char *value)
{
- struct switch_thru_all_uis state;
-
if (mi_suppress_notification.cmd_param_changed)
return;
- SWITCH_THRU_ALL_UIS (state)
+ SWITCH_THRU_ALL_UIS ()
{
struct mi_interp *mi = as_mi_interp (top_level_interpreter ());
struct ui_out *mi_uiout;
mi_memory_changed (struct inferior *inferior, CORE_ADDR memaddr,
ssize_t len, const bfd_byte *myaddr)
{
- struct switch_thru_all_uis state;
-
if (mi_suppress_notification.memory)
return;
- SWITCH_THRU_ALL_UIS (state)
+ SWITCH_THRU_ALL_UIS ()
{
struct mi_interp *mi = as_mi_interp (top_level_interpreter ());
struct ui_out *mi_uiout;
static void
mi_user_selected_context_changed (user_selected_what selection)
{
- struct switch_thru_all_uis state;
struct thread_info *tp;
/* Don't send an event if we're responding to an MI command. */
tp = find_thread_ptid (inferior_ptid);
- SWITCH_THRU_ALL_UIS (state)
+ SWITCH_THRU_ALL_UIS ()
{
struct mi_interp *mi = as_mi_interp (top_level_interpreter ());
struct ui_out *mi_uiout;
/* The list of all UIs. */
extern struct ui *ui_list;
-/* State for SWITCH_THRU_ALL_UIS. Declared here because it is meant
- to be created on the stack, but should be treated as opaque. */
-struct switch_thru_all_uis
+/* State for SWITCH_THRU_ALL_UIS. */
+class switch_thru_all_uis
{
- struct ui *iter;
- struct cleanup *old_chain;
+public:
+
+ switch_thru_all_uis () : m_iter (ui_list), m_save_ui (¤t_ui)
+ {
+ current_ui = ui_list;
+ }
+
+ /* If done iterating, return true; otherwise return false. */
+ bool done () const
+ {
+ return m_iter == NULL;
+ }
+
+ /* Move to the next UI, setting current_ui if iteration is not yet
+ complete. */
+ void next ()
+ {
+ m_iter = m_iter->next;
+ if (m_iter != NULL)
+ current_ui = m_iter;
+ }
+
+ private:
+
+ /* No need for these. They are intentionally not defined
+ anywhere. */
+ switch_thru_all_uis &operator= (const switch_thru_all_uis &);
+ switch_thru_all_uis (const switch_thru_all_uis &);
+
+ /* Used to iterate through the UIs. */
+ struct ui *m_iter;
+
+ /* Save and restore current_ui. */
+ scoped_restore_tmpl<struct ui *> m_save_ui;
};
-/* Functions to drive SWITCH_THRU_ALL_UIS. Though declared here by
- necessity, these functions should not be used other than via the
- SWITCH_THRU_ALL_UIS macro defined below. */
-extern void switch_thru_all_uis_init (struct switch_thru_all_uis *state);
-extern int switch_thru_all_uis_cond (struct switch_thru_all_uis *state);
-extern void switch_thru_all_uis_next (struct switch_thru_all_uis *state);
-
/* Traverse through all UI, and switch the current UI to the one
being iterated. */
-#define SWITCH_THRU_ALL_UIS(STATE) \
- for (switch_thru_all_uis_init (&STATE); \
- switch_thru_all_uis_cond (&STATE); \
- switch_thru_all_uis_next (&STATE))
+#define SWITCH_THRU_ALL_UIS() \
+ for (switch_thru_all_uis stau_state; !stau_state.done (); stau_state.next ())
/* Traverse over all UIs. */
#define ALL_UIS(UI) \
/* Cleanup that deletes a UI. */
extern struct cleanup *make_delete_ui_cleanup (struct ui *ui);
-/* Make a cleanup that restores the current UI. */
-extern struct cleanup *make_cleanup_restore_current_ui (void);
-
/* Register the UI's input file descriptor in the event loop. */
extern void ui_register_input_event_handler (struct ui *ui);
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 *interp = top_level_interpreter ();
struct interp *tui = as_tui_interp (interp);
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 ());
static void
tui_on_user_selected_context_changed (user_selected_what selection)
{
- struct switch_thru_all_uis state;
struct thread_info *tp;
/* This event is suppressed. */
tp = find_thread_ptid (inferior_ptid);
- SWITCH_THRU_ALL_UIS (state)
+ SWITCH_THRU_ALL_UIS ()
{
struct interp *tui = as_tui_interp (top_level_interpreter ());