diff options
author | Simon Marchi <simon.marchi@efficios.com> | 2023-04-20 14:02:28 -0400 |
---|---|---|
committer | Simon Marchi <simon.marchi@efficios.com> | 2023-05-30 15:07:26 -0400 |
commit | d6bd2ef5f4c2027a68810f4a9dbe871b61e819ab (patch) | |
tree | 28be60b8ea2a22e80e492ce3bf329ee3c7261954 | |
parent | 8782926771b1212acb90b944f7402466c998d592 (diff) | |
download | gdb-d6bd2ef5f4c2027a68810f4a9dbe871b61e819ab.zip gdb-d6bd2ef5f4c2027a68810f4a9dbe871b61e819ab.tar.gz gdb-d6bd2ef5f4c2027a68810f4a9dbe871b61e819ab.tar.bz2 |
gdb: add interp::on_signal_exited method
Same as previous patch, but for signal_exited. Remove the signal_exited
observable, since nothing uses it anymore, and we don't have anything
coming that will use it.
Change-Id: I0dca1eab76338bf27be755786e3dad3241698b10
-rw-r--r-- | gdb/cli/cli-interp.c | 17 | ||||
-rw-r--r-- | gdb/cli/cli-interp.h | 3 | ||||
-rw-r--r-- | gdb/infrun.c | 2 | ||||
-rw-r--r-- | gdb/interps.c | 8 | ||||
-rw-r--r-- | gdb/interps.h | 8 | ||||
-rw-r--r-- | gdb/mi/mi-interp.c | 20 | ||||
-rw-r--r-- | gdb/mi/mi-interp.h | 1 | ||||
-rw-r--r-- | gdb/observable.c | 1 | ||||
-rw-r--r-- | gdb/observable.h | 3 |
9 files changed, 27 insertions, 36 deletions
diff --git a/gdb/cli/cli-interp.c b/gdb/cli/cli-interp.c index 9508171..aba73f1 100644 --- a/gdb/cli/cli-interp.c +++ b/gdb/cli/cli-interp.c @@ -134,19 +134,10 @@ cli_interp_base::on_signal_received (enum gdb_signal siggnal) print_signal_received_reason (this->interp_ui_out (), siggnal); } -/* Observer for the signalled notification. */ - -static void -cli_base_on_signal_exited (enum gdb_signal siggnal) +void +cli_interp_base::on_signal_exited (gdb_signal sig) { - SWITCH_THRU_ALL_UIS () - { - cli_interp_base *cli = as_cli_interp_base (top_level_interpreter ()); - if (cli == nullptr) - continue; - - print_signal_exited_reason (cli->interp_ui_out (), siggnal); - } + print_signal_exited_reason (this->interp_ui_out (), sig); } /* Observer for the exited notification. */ @@ -388,8 +379,6 @@ _initialize_cli_interp () interp_factory_register (INTERP_CONSOLE, cli_interp_factory); /* Note these all work for both the CLI and TUI interpreters. */ - gdb::observers::signal_exited.attach (cli_base_on_signal_exited, - "cli-interp-base"); gdb::observers::exited.attach (cli_base_on_exited, "cli-interp-base"); gdb::observers::no_history.attach (cli_base_on_no_history, "cli-interp-base"); gdb::observers::sync_execution_done.attach (cli_base_on_sync_execution_done, diff --git a/gdb/cli/cli-interp.h b/gdb/cli/cli-interp.h index 4fca801..6342efa 100644 --- a/gdb/cli/cli-interp.h +++ b/gdb/cli/cli-interp.h @@ -34,7 +34,8 @@ public: bool supports_command_editing () override; void on_signal_received (gdb_signal sig) override; - void on_normal_stop(bpstat *bs, int print_frame) override; + void on_signal_exited (gdb_signal sig) override; + void on_normal_stop (bpstat *bs, int print_frame) override; private: struct saved_output_files diff --git a/gdb/infrun.c b/gdb/infrun.c index 9c4417f..295f399 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -5755,7 +5755,7 @@ handle_inferior_event (struct execution_control_state *ecs) "signal number."); } - gdb::observers::signal_exited.notify (ecs->ws.sig ()); + interps_notify_signal_exited (ecs->ws.sig ()); } gdb_flush (gdb_stdout); diff --git a/gdb/interps.c b/gdb/interps.c index 80160bc..566b5e1 100644 --- a/gdb/interps.c +++ b/gdb/interps.c @@ -409,6 +409,14 @@ interps_notify_signal_received (gdb_signal sig) /* See interps.h. */ void +interps_notify_signal_exited (gdb_signal sig) +{ + interps_notify (&interp::on_signal_exited, sig); +} + +/* See interps.h. */ + +void interps_notify_normal_stop (bpstat *bs, int print_frame) { interps_notify (&interp::on_normal_stop, bs, print_frame); diff --git a/gdb/interps.h b/gdb/interps.h index dd5a9b7..752f2e8 100644 --- a/gdb/interps.h +++ b/gdb/interps.h @@ -87,6 +87,10 @@ public: SIG. */ virtual void on_signal_received (gdb_signal sig) {} + /* Notify the interpreter that the current inferior has exited with signal + SIG. */ + virtual void on_signal_exited (gdb_signal sig) {} + /* Notify the interpreter that the current inferior has stopped normally. */ virtual void on_normal_stop (bpstat *bs, int print_frame) {} @@ -182,6 +186,10 @@ extern void interpreter_completer (struct cmd_list_element *ignore, SIG. */ extern void interps_notify_signal_received (gdb_signal sig); +/* Notify all interpreters that the current inferior has exited with signal + SIG. */ +extern void interps_notify_signal_exited (gdb_signal sig); + /* Notify all interpreters that the current inferior has stopped normally. */ extern void interps_notify_normal_stop (bpstat *bs, int print_frame); diff --git a/gdb/mi/mi-interp.c b/gdb/mi/mi-interp.c index e3cb159..ba9297e 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_on_signal_exited (enum gdb_signal siggnal); static void mi_on_exited (int exitstatus); static void mi_on_no_history (void); @@ -530,21 +529,11 @@ mi_interp::on_signal_received (enum gdb_signal siggnal) print_signal_received_reason (this->cli_uiout, siggnal); } -/* Observer for the signal_exited notification. */ - -static void -mi_on_signal_exited (enum gdb_signal siggnal) +void +mi_interp::on_signal_exited (gdb_signal sig) { - SWITCH_THRU_ALL_UIS () - { - struct mi_interp *mi = find_mi_interp (); - - if (mi == NULL) - continue; - - print_signal_exited_reason (mi->mi_uiout, siggnal); - print_signal_exited_reason (mi->cli_uiout, siggnal); - } + print_signal_exited_reason (this->mi_uiout, sig); + print_signal_exited_reason (this->cli_uiout, sig); } /* Observer for the exited notification. */ @@ -1275,7 +1264,6 @@ _initialize_mi_interp () interp_factory_register (INTERP_MI4, mi_interp_factory); interp_factory_register (INTERP_MI, mi_interp_factory); - gdb::observers::signal_exited.attach (mi_on_signal_exited, "mi-interp"); gdb::observers::exited.attach (mi_on_exited, "mi-interp"); gdb::observers::no_history.attach (mi_on_no_history, "mi-interp"); gdb::observers::new_thread.attach (mi_new_thread, "mi-interp"); diff --git a/gdb/mi/mi-interp.h b/gdb/mi/mi-interp.h index 51e6298..2b825e7 100644 --- a/gdb/mi/mi-interp.h +++ b/gdb/mi/mi-interp.h @@ -43,6 +43,7 @@ public: void pre_command_loop () override; void on_signal_received (gdb_signal sig) override; + void on_signal_exited (gdb_signal sig) override; void on_normal_stop (struct bpstat *bs, int print_frame) override; /* MI's output channels */ diff --git a/gdb/observable.c b/gdb/observable.c index 82563e3..8cbf037 100644 --- a/gdb/observable.c +++ b/gdb/observable.c @@ -34,7 +34,6 @@ bool observer_debug = false; DEFINE_OBSERVABLE (normal_stop); DEFINE_OBSERVABLE (signal_received); -DEFINE_OBSERVABLE (signal_exited); DEFINE_OBSERVABLE (exited); DEFINE_OBSERVABLE (no_history); DEFINE_OBSERVABLE (sync_execution_done); diff --git a/gdb/observable.h b/gdb/observable.h index e4e6f02..aaf1ddd 100644 --- a/gdb/observable.h +++ b/gdb/observable.h @@ -57,9 +57,6 @@ extern observable<struct bpstat */* bs */, int /* print_frame */> normal_stop; /* The inferior was stopped by a signal. */ extern observable<enum gdb_signal /* siggnal */> signal_received; -/* The inferior was terminated by a signal. */ -extern observable<enum gdb_signal /* siggnal */> signal_exited; - /* The inferior program is finished. */ extern observable<int /* exitstatus */> exited; |