From: Simon Marchi Date: Thu, 20 Apr 2023 18:02:28 +0000 (-0400) Subject: gdb: add interp::on_signal_exited method X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d6bd2ef5f4c2027a68810f4a9dbe871b61e819ab;p=binutils-gdb.git 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 --- diff --git a/gdb/cli/cli-interp.c b/gdb/cli/cli-interp.c index 9508171e87d..aba73f142af 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 4fca801d4fd..6342efa2dd5 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 9c4417f1eae..295f399791d 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 80160bc45f3..566b5e1195a 100644 --- a/gdb/interps.c +++ b/gdb/interps.c @@ -408,6 +408,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) { diff --git a/gdb/interps.h b/gdb/interps.h index dd5a9b70e33..752f2e8ea61 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 e3cb159e0fa..ba9297e54c5 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 51e62982d7b..2b825e7d9d8 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 82563e3fab4..8cbf0377b0b 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 e4e6f021f1a..aaf1ddda4d4 100644 --- a/gdb/observable.h +++ b/gdb/observable.h @@ -57,9 +57,6 @@ extern observable normal_stop; /* The inferior was stopped by a signal. */ extern observable signal_received; -/* The inferior was terminated by a signal. */ -extern observable signal_exited; - /* The inferior program is finished. */ extern observable exited;