Same idea as the previous patch, but for the normal_stop event.
Change-Id: I4fc8ca8a51c63829dea390a2b6ce30b77f9fb863
interpreter-exec), print nothing. These are named "cli_base" as
they print to both CLI interpreters and TUI interpreters. */
-/* Observer for the normal_stop notification. */
-
-static void
-cli_base_on_normal_stop (struct bpstat *bs, int print_frame)
+void
+cli_interp_base::on_normal_stop (struct bpstat *bs, int print_frame)
{
if (!print_frame)
return;
if (cli_suppress_notification.normal_stop)
return;
- SWITCH_THRU_ALL_UIS ()
- {
- struct interp *interp = top_level_interpreter ();
- cli_interp_base *cli = as_cli_interp_base (interp);
- if (cli == nullptr)
- continue;
+ thread_info *thread = inferior_thread ();
+ if (should_print_stop_to_console (this, thread))
+ print_stop_event (this->interp_ui_out ());
- thread_info *thread = inferior_thread ();
- if (should_print_stop_to_console (interp, thread))
- print_stop_event (cli->interp_ui_out ());
- }
}
void
interp_factory_register (INTERP_CONSOLE, cli_interp_factory);
/* Note these all work for both the CLI and TUI interpreters. */
- gdb::observers::normal_stop.attach (cli_base_on_normal_stop,
- "cli-interp-base");
gdb::observers::signal_exited.attach (cli_base_on_signal_exited,
"cli-interp-base");
gdb::observers::exited.attach (cli_base_on_exited, "cli-interp-base");
bool supports_command_editing () override;
void on_signal_received (gdb_signal sig) override;
+ void on_normal_stop(bpstat *bs, int print_frame) override;
private:
struct saved_output_files
gdb::observers::signal_received.notify (sig);
}
+/* See infrun.h. */
+
+void
+notify_normal_stop (bpstat *bs, int print_frame)
+{
+ interps_notify_normal_stop (bs, print_frame);
+ gdb::observers::normal_stop.notify (bs, print_frame);
+}
+
/* Come here when the program has stopped with a signal. */
static void
/* Notify observers about the stop. This is where the interpreters
print the stop event. */
- if (inferior_ptid != null_ptid)
- gdb::observers::normal_stop.notify (inferior_thread ()->control.stop_bpstat,
- stop_print_frame);
- else
- gdb::observers::normal_stop.notify (nullptr, stop_print_frame);
-
+ notify_normal_stop ((inferior_ptid != null_ptid
+ ? inferior_thread ()->control.stop_bpstat
+ : nullptr),
+ stop_print_frame);
annotate_stopped ();
if (target_has_execution ())
signal SIG. */
extern void notify_signal_received (gdb_signal sig);
+/* Notify interpreters and observers that the current inferior has stopped
+ normally. */
+extern void notify_normal_stop (bpstat *bs, int print_frame);
+
/* Several print_*_reason helper functions to print why the inferior
has stopped to the passed in UIOUT. */
interps_notify (&interp::on_signal_received, sig);
}
+/* See interps.h. */
+
+void
+interps_notify_normal_stop (bpstat *bs, int print_frame)
+{
+ interps_notify (&interp::on_normal_stop, bs, print_frame);
+}
+
/* This just adds the "interpreter-exec" command. */
void _initialize_interpreter ();
void
#include "gdbsupport/intrusive_list.h"
+struct bpstat;
struct ui_out;
struct interp;
struct ui;
SIG. */
virtual void on_signal_received (gdb_signal sig) {}
+ /* Notify the interpreter that the current inferior has stopped normally. */
+ virtual void on_normal_stop (bpstat *bs, int print_frame) {}
+
private:
/* The memory for this is static, it comes from literal strings (e.g. "cli"). */
const char *m_name;
SIG. */
extern void interps_notify_signal_received (gdb_signal sig);
+/* Notify all interpreters that the current inferior has stopped normally. */
+extern void interps_notify_normal_stop (bpstat *bs, int print_frame);
+
/* well-known interpreters */
#define INTERP_CONSOLE "console"
#define INTERP_MI2 "mi2"
static void mi_on_signal_exited (enum gdb_signal siggnal);
static void mi_on_exited (int exitstatus);
-static void mi_on_normal_stop (struct bpstat *bs, int print_frame);
static void mi_on_no_history (void);
static void mi_new_thread (struct thread_info *t);
}
}
-static void
-mi_on_normal_stop_1 (struct bpstat *bs, int print_frame)
+void
+mi_interp::on_normal_stop (struct bpstat *bs, int print_frame)
{
/* Since this can be called when CLI command is executing,
using cli interpreter, be sure to use MI uiout for output,
not the current one. */
- struct ui_out *mi_uiout = top_level_interpreter ()->interp_ui_out ();
- struct mi_interp *mi = (struct mi_interp *) top_level_interpreter ();
+ ui_out *mi_uiout = this->interp_ui_out ();
if (print_frame)
{
- struct thread_info *tp;
- int core;
- struct interp *console_interp;
-
- tp = inferior_thread ();
+ thread_info *tp = inferior_thread ();
if (tp->thread_fsm () != nullptr
&& tp->thread_fsm ()->finished_p ())
{
- enum async_reply_reason reason;
-
- reason = tp->thread_fsm ()->async_reply_reason ();
+ async_reply_reason reason
+ = tp->thread_fsm ()->async_reply_reason ();
mi_uiout->field_string ("reason", async_reason_lookup (reason));
}
- console_interp = interp_lookup (current_ui, INTERP_CONSOLE);
+ interp *console_interp = interp_lookup (current_ui, INTERP_CONSOLE);
+
/* We only want to print the displays once, and we want it to
look just how it would on the console, so we use this to
decide whether the MI stop should include them. */
print_stop_event (mi_uiout, !console_print);
if (console_print)
- print_stop_event (mi->cli_uiout);
+ print_stop_event (this->cli_uiout);
mi_uiout->field_signed ("thread-id", tp->global_num);
if (non_stop)
else
mi_uiout->field_string ("stopped-threads", "all");
- core = target_core_of_thread (tp->ptid);
+ int core = target_core_of_thread (tp->ptid);
if (core != -1)
mi_uiout->field_signed ("core", core);
}
-
- gdb_puts ("*stopped", mi->raw_stdout);
- mi_out_put (mi_uiout, mi->raw_stdout);
- mi_out_rewind (mi_uiout);
- mi_print_timing_maybe (mi->raw_stdout);
- gdb_puts ("\n", mi->raw_stdout);
- gdb_flush (mi->raw_stdout);
-}
-static void
-mi_on_normal_stop (struct bpstat *bs, int print_frame)
-{
- SWITCH_THRU_ALL_UIS ()
- {
- if (as_mi_interp (top_level_interpreter ()) == NULL)
- continue;
-
- mi_on_normal_stop_1 (bs, print_frame);
- }
+ gdb_puts ("*stopped", this->raw_stdout);
+ mi_out_put (mi_uiout, this->raw_stdout);
+ mi_out_rewind (mi_uiout);
+ mi_print_timing_maybe (this->raw_stdout);
+ gdb_puts ("\n", this->raw_stdout);
+ gdb_flush (this->raw_stdout);
}
static void
gdb::observers::inferior_exit.attach (mi_inferior_exit, "mi-interp");
gdb::observers::inferior_removed.attach (mi_inferior_removed, "mi-interp");
gdb::observers::record_changed.attach (mi_record_changed, "mi-interp");
- gdb::observers::normal_stop.attach (mi_on_normal_stop, "mi-interp");
gdb::observers::target_resumed.attach (mi_on_resume, "mi-interp");
gdb::observers::solib_loaded.attach (mi_solib_loaded, "mi-interp");
gdb::observers::solib_unloaded.attach (mi_solib_unloaded, "mi-interp");
void pre_command_loop () override;
void on_signal_received (gdb_signal sig) override;
+ void on_normal_stop (struct bpstat *bs, int print_frame) override;
/* MI's output channels */
mi_console_file *out;
if (signal_print_state (sig))
notify_signal_received (sig);
}
- gdb::observers::normal_stop.notify (NULL, 1);
+
+ notify_normal_stop (nullptr, 1);
}
/* Process all initial stop replies the remote side sent in response