From 7603ea6afa41382cefeab1e1c85f74a588fcc6ab Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Fri, 21 Apr 2023 09:45:30 -0400 Subject: [PATCH] gdb: add interp::on_about_to_proceed method Same idea as previous patches, but for about_to_proceed. We only need (and want, as far as the mi_interp implementation is concerned) to notify the interpreter that caused the proceed. Change-Id: Id259bca10dbc3d43d46607ff7b95243a9cbe2f89 --- gdb/infrun.c | 12 +++++++++++- gdb/interps.h | 4 ++++ gdb/mi/mi-interp.c | 13 +++---------- gdb/mi/mi-interp.h | 1 + 4 files changed, 19 insertions(+), 11 deletions(-) diff --git a/gdb/infrun.c b/gdb/infrun.c index d4334302a99..4d6df757d23 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -2894,6 +2894,16 @@ clear_proceed_status_thread (struct thread_info *tp) bpstat_clear (&tp->control.stop_bpstat); } +/* Notify the current interpreter and observers that the target is about to + proceed. */ + +static void +notify_about_to_proceed () +{ + top_level_interpreter ()->on_about_to_proceed (); + gdb::observers::about_to_proceed.notify (); +} + void clear_proceed_status (int step) { @@ -2936,7 +2946,7 @@ clear_proceed_status (int step) inferior->control.stop_soon = NO_STOP_QUIETLY; } - gdb::observers::about_to_proceed.notify (); + notify_about_to_proceed (); } /* Returns true if TP is still stopped at a breakpoint that needs diff --git a/gdb/interps.h b/gdb/interps.h index 3339ae3d301..a88c40581bb 100644 --- a/gdb/interps.h +++ b/gdb/interps.h @@ -149,6 +149,10 @@ public: /* Notify the interpreter that solib SO has been unloaded. */ virtual void on_solib_unloaded (so_list *so) {} + /* Notify the interpreter that a command it is executing is about to cause + the inferior to proceed. */ + virtual void on_about_to_proceed () {} + private: /* The memory for this is static, it comes from literal strings (e.g. "cli"). */ const char *m_name; diff --git a/gdb/mi/mi-interp.c b/gdb/mi/mi-interp.c index 072002d4969..dd17fd5c42d 100644 --- a/gdb/mi/mi-interp.c +++ b/gdb/mi/mi-interp.c @@ -60,7 +60,6 @@ static int mi_interp_query_hook (const char *ctlstr, va_list ap) static void mi_insert_notify_hooks (void); static void mi_remove_notify_hooks (void); -static void mi_about_to_proceed (void); static void mi_traceframe_changed (int tfnum, int tpnum); static void mi_tsv_created (const struct trace_state_variable *tsv); static void mi_tsv_deleted (const struct trace_state_variable *tsv); @@ -469,8 +468,8 @@ mi_interp::on_normal_stop (struct bpstat *bs, int print_frame) gdb_flush (this->raw_stdout); } -static void -mi_about_to_proceed (void) +void +mi_interp::on_about_to_proceed () { /* Suppress output while calling an inferior function. */ @@ -482,12 +481,7 @@ mi_about_to_proceed (void) return; } - mi_interp *mi = as_mi_interp (top_level_interpreter ()); - - if (mi == nullptr) - return; - - mi->mi_proceeded = 1; + this->mi_proceeded = 1; } /* When the element is non-zero, no MI notifications will be emitted in @@ -1061,7 +1055,6 @@ _initialize_mi_interp () interp_factory_register (INTERP_MI4, mi_interp_factory); interp_factory_register (INTERP_MI, mi_interp_factory); - gdb::observers::about_to_proceed.attach (mi_about_to_proceed, "mi-interp"); gdb::observers::traceframe_changed.attach (mi_traceframe_changed, "mi-interp"); gdb::observers::tsv_created.attach (mi_tsv_created, "mi-interp"); diff --git a/gdb/mi/mi-interp.h b/gdb/mi/mi-interp.h index 704f2d9bc83..33177fcf5be 100644 --- a/gdb/mi/mi-interp.h +++ b/gdb/mi/mi-interp.h @@ -61,6 +61,7 @@ public: void on_target_resumed (ptid_t ptid) override; void on_solib_loaded (so_list *so) override; void on_solib_unloaded (so_list *so) override; + void on_about_to_proceed () override; /* MI's output channels */ mi_console_file *out; -- 2.30.2