From: Simon Marchi <simon.marchi@efficios.com>
To: gdb-patches@sourceware.org
Cc: Simon Marchi <simon.marchi@efficios.com>
Subject: [PATCH 29/30] gdb: add interp::on_param_changed method
Date: Tue, 2 May 2023 16:50:09 -0400 [thread overview]
Message-ID: <20230502205011.132151-30-simon.marchi@efficios.com> (raw)
In-Reply-To: <20230502205011.132151-1-simon.marchi@efficios.com>
Same idea as previous patches, but for command_param_changed.
Change-Id: I7c2196343423360da05f016f8ffa871c064092bb
---
gdb/cli/cli-setshow.c | 13 +++++++------
gdb/interps.c | 8 ++++++++
gdb/interps.h | 6 ++++++
gdb/mi/mi-interp.c | 34 ++++++++++------------------------
gdb/mi/mi-interp.h | 1 +
gdb/observable.c | 1 -
gdb/observable.h | 7 -------
gdb/source.c | 5 +++--
8 files changed, 35 insertions(+), 40 deletions(-)
diff --git a/gdb/cli/cli-setshow.c b/gdb/cli/cli-setshow.c
index 07233e36a380..ecb739b94e90 100644
--- a/gdb/cli/cli-setshow.c
+++ b/gdb/cli/cli-setshow.c
@@ -21,6 +21,7 @@
#include <ctype.h>
#include "arch-utils.h"
#include "observable.h"
+#include "interps.h"
#include "ui-out.h"
@@ -521,18 +522,18 @@ do_set_command (const char *arg, int from_tty, struct cmd_list_element *c)
case var_string_noescape:
case var_filename:
case var_optional_filename:
- gdb::observers::command_param_changed.notify
+ interps_notify_param_changed
(name, c->var->get<std::string> ().c_str ());
break;
case var_enum:
- gdb::observers::command_param_changed.notify
+ interps_notify_param_changed
(name, c->var->get<const char *> ());
break;
case var_boolean:
{
const char *opt = c->var->get<bool> () ? "on" : "off";
- gdb::observers::command_param_changed.notify (name, opt);
+ interps_notify_param_changed (name, opt);
}
break;
case var_auto_boolean:
@@ -540,7 +541,7 @@ do_set_command (const char *arg, int from_tty, struct cmd_list_element *c)
const char *s
= auto_boolean_enums[c->var->get<enum auto_boolean> ()];
- gdb::observers::command_param_changed.notify (name, s);
+ interps_notify_param_changed (name, s);
}
break;
case var_uinteger:
@@ -548,7 +549,7 @@ do_set_command (const char *arg, int from_tty, struct cmd_list_element *c)
char s[64];
xsnprintf (s, sizeof s, "%u", c->var->get<unsigned int> ());
- gdb::observers::command_param_changed.notify (name, s);
+ interps_notify_param_changed (name, s);
}
break;
case var_integer:
@@ -557,7 +558,7 @@ do_set_command (const char *arg, int from_tty, struct cmd_list_element *c)
char s[64];
xsnprintf (s, sizeof s, "%d", c->var->get<int> ());
- gdb::observers::command_param_changed.notify (name, s);
+ interps_notify_param_changed (name, s);
}
break;
}
diff --git a/gdb/interps.c b/gdb/interps.c
index d572f92f4aa0..3cb89b113a3b 100644
--- a/gdb/interps.c
+++ b/gdb/interps.c
@@ -583,6 +583,14 @@ interps_notify_breakpoint_modified (breakpoint *b)
interps_notify (&interp::on_breakpoint_modified, b);
}
+/* See interps.h. */
+
+void
+interps_notify_param_changed (const char *param, const char *value)
+{
+ interps_notify (&interp::on_param_changed, param, value);
+}
+
/* This just adds the "interpreter-exec" command. */
void _initialize_interpreter ();
void
diff --git a/gdb/interps.h b/gdb/interps.h
index 6fda2ba372f1..948b6f520df0 100644
--- a/gdb/interps.h
+++ b/gdb/interps.h
@@ -175,6 +175,9 @@ class interp : public intrusive_list_node<interp>
/* Notify the interpreter that breakpoint B was modified. */
virtual void on_breakpoint_modified (breakpoint *b) {}
+ /* Notify the interpreter that parameter PARAM changed to VALUE. */
+ virtual void on_param_changed (const char *param, const char *value) {}
+
private:
/* The memory for this is static, it comes from literal strings (e.g. "cli"). */
const char *m_name;
@@ -353,6 +356,9 @@ extern void interps_notify_breakpoint_deleted (breakpoint *b);
/* Notify all interpreters that breakpoint B was modified. */
extern void interps_notify_breakpoint_modified (breakpoint *b);
+/* Notify all interpreters that parameter PARAM changed to VALUE. */
+extern void interps_notify_param_changed (const char *param, const char *value);
+
/* well-known interpreters */
#define INTERP_CONSOLE "console"
#define INTERP_MI2 "mi2"
diff --git a/gdb/mi/mi-interp.c b/gdb/mi/mi-interp.c
index 2e30b15a4862..c6e70a779648 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_command_param_changed (const char *param, const char *value);
static void mi_memory_changed (struct inferior *inf, CORE_ADDR memaddr,
ssize_t len, const bfd_byte *myaddr);
@@ -792,36 +791,25 @@ mi_interp::on_solib_unloaded (so_list *solib)
gdb_flush (this->event_channel);
}
-/* Emit notification about the command parameter change. */
-
-static void
-mi_command_param_changed (const char *param, const char *value)
+void
+mi_interp::on_param_changed (const char *param, const char *value)
{
if (mi_suppress_notification.cmd_param_changed)
return;
- SWITCH_THRU_ALL_UIS ()
- {
- struct mi_interp *mi = as_mi_interp (top_level_interpreter ());
- struct ui_out *mi_uiout;
-
- if (mi == NULL)
- continue;
-
- mi_uiout = top_level_interpreter ()->interp_ui_out ();
+ ui_out *mi_uiout = this->interp_ui_out ();
- target_terminal::scoped_restore_terminal_state term_state;
- target_terminal::ours_for_output ();
+ target_terminal::scoped_restore_terminal_state term_state;
+ target_terminal::ours_for_output ();
- gdb_printf (mi->event_channel, "cmd-param-changed");
+ gdb_printf (this->event_channel, "cmd-param-changed");
- ui_out_redirect_pop redir (mi_uiout, mi->event_channel);
+ ui_out_redirect_pop redir (mi_uiout, this->event_channel);
- mi_uiout->field_string ("param", param);
- mi_uiout->field_string ("value", value);
+ mi_uiout->field_string ("param", param);
+ mi_uiout->field_string ("value", value);
- gdb_flush (mi->event_channel);
- }
+ gdb_flush (this->event_channel);
}
/* Emit notification about the target memory change. */
@@ -972,7 +960,5 @@ _initialize_mi_interp ()
interp_factory_register (INTERP_MI4, mi_interp_factory);
interp_factory_register (INTERP_MI, mi_interp_factory);
- gdb::observers::command_param_changed.attach (mi_command_param_changed,
- "mi-interp");
gdb::observers::memory_changed.attach (mi_memory_changed, "mi-interp");
}
diff --git a/gdb/mi/mi-interp.h b/gdb/mi/mi-interp.h
index 52cce4c7cf4c..51f22b2ef112 100644
--- a/gdb/mi/mi-interp.h
+++ b/gdb/mi/mi-interp.h
@@ -69,6 +69,7 @@ class mi_interp final : public interp
void on_breakpoint_created (breakpoint *b) override;
void on_breakpoint_deleted (breakpoint *b) override;
void on_breakpoint_modified (breakpoint *b) override;
+ void on_param_changed (const char *param, const char *value) override;
/* MI's output channels */
mi_console_file *out;
diff --git a/gdb/observable.c b/gdb/observable.c
index 3535e69f7f54..a18b863fb471 100644
--- a/gdb/observable.c
+++ b/gdb/observable.c
@@ -61,7 +61,6 @@ DEFINE_OBSERVABLE (inferior_removed);
DEFINE_OBSERVABLE (memory_changed);
DEFINE_OBSERVABLE (before_prompt);
DEFINE_OBSERVABLE (gdb_datadir_changed);
-DEFINE_OBSERVABLE (command_param_changed);
DEFINE_OBSERVABLE (inferior_call_pre);
DEFINE_OBSERVABLE (inferior_call_post);
DEFINE_OBSERVABLE (register_changed);
diff --git a/gdb/observable.h b/gdb/observable.h
index 1c7ba0a1ba67..f6047a239cd6 100644
--- a/gdb/observable.h
+++ b/gdb/observable.h
@@ -183,13 +183,6 @@ extern observable<const char */* current_prompt */> before_prompt;
change. */
extern observable<> gdb_datadir_changed;
-/* The parameter of some 'set' commands in console are changed.
- This method is called after a command 'set param value'. PARAM
- is the parameter of 'set' command, and VALUE is the value of
- changed parameter. */
-extern observable<const char */* param */, const char */* value */>
- command_param_changed;
-
/* An inferior function at ADDRESS is about to be called in thread
THREAD. */
extern observable<ptid_t /* thread */, CORE_ADDR /* address */>
diff --git a/gdb/source.c b/gdb/source.c
index 4d297c82ea9c..d0bb3c126f3e 100644
--- a/gdb/source.c
+++ b/gdb/source.c
@@ -51,6 +51,7 @@
#include "build-id.h"
#include "debuginfod-support.h"
#include "gdbsupport/buildargv.h"
+#include "interps.h"
#define OPEN_MODE (O_RDONLY | O_BINARY)
#define FDOPEN_MODE FOPEN_RB
@@ -462,8 +463,8 @@ directory_command (const char *dirname, int from_tty)
}
if (value_changed)
{
- gdb::observers::command_param_changed.notify ("directories",
- source_path.c_str ());
+ interps_notify_param_changed ("directories", source_path.c_str ());
+
if (from_tty)
show_directories_1 (gdb_stdout, (char *) 0, from_tty);
}
--
2.40.1
next prev parent reply other threads:[~2023-05-02 20:56 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-02 20:49 [PATCH 00/30] Switch interpreters to use virtual methods Simon Marchi
2023-05-02 20:49 ` [PATCH 01/30] gdb/mi: fix ^running record with multiple MI interpreters Simon Marchi
2023-05-03 14:42 ` Alexandra Petlanova Hajkova
2023-05-03 15:02 ` Simon Marchi
2023-05-29 14:53 ` Simon Marchi
2023-05-02 20:49 ` [PATCH 02/30] gdb/mi: make current_token a field of mi_interp Simon Marchi
2023-05-04 12:31 ` Alexandra Petlanova Hajkova
2023-05-02 20:49 ` [PATCH 03/30] gdb: add interp::on_signal_received method Simon Marchi
2023-05-04 14:38 ` Alexandra Petlanova Hajkova
2023-05-02 20:49 ` [PATCH 04/30] gdb: add interp::on_normal_stop method Simon Marchi
2023-05-02 20:49 ` [PATCH 05/30] gdb: add interp::on_signal_exited method Simon Marchi
2023-05-02 20:49 ` [PATCH 06/30] gdb: add interp::on_exited method Simon Marchi
2023-05-02 20:49 ` [PATCH 07/30] gdb: add interp::on_no_history method Simon Marchi
2023-05-02 20:49 ` [PATCH 08/30] gdb: add interp::on_sync_execution_done method Simon Marchi
2023-05-02 20:49 ` [PATCH 09/30] gdb: add interp::on_command_error method Simon Marchi
2023-05-02 20:49 ` [PATCH 10/30] gdb: add interp::on_user_selected_context_changed method Simon Marchi
2023-05-02 20:49 ` [PATCH 11/30] gdb: add interp::on_new_thread method Simon Marchi
2023-05-02 20:49 ` [PATCH 12/30] gdb: add interp::on_thread_exited method Simon Marchi
2023-05-02 20:49 ` [PATCH 13/30] gdb: add interp::on_inferior_added method Simon Marchi
2023-05-02 20:49 ` [PATCH 14/30] gdb: add interp::on_inferior_appeared method Simon Marchi
2023-05-02 20:49 ` [PATCH 15/30] gdb: add interp::on_inferior_disappeared method Simon Marchi
2023-05-02 20:49 ` [PATCH 16/30] gdb: add interp::on_inferior_removed method Simon Marchi
2023-05-02 20:49 ` [PATCH 17/30] gdb: add interp::on_record_changed method Simon Marchi
2023-05-02 20:49 ` [PATCH 18/30] gdb: add interp::on_target_resumed method Simon Marchi
2023-05-02 20:49 ` [PATCH 19/30] gdb: add interp::on_solib_loaded method Simon Marchi
2023-05-02 20:50 ` [PATCH 20/30] gdb: add interp::on_solib_unloaded method Simon Marchi
2023-05-02 20:50 ` [PATCH 21/30] gdb: add interp::on_about_to_proceed method Simon Marchi
2023-05-02 20:50 ` [PATCH 22/30] gdb: add interp::on_traceframe_changed method Simon Marchi
2023-05-02 20:50 ` [PATCH 23/30] gdb: add interp::on_tsv_created method Simon Marchi
2023-05-02 20:50 ` [PATCH 24/30] gdb: add interp::on_tsv_deleted method Simon Marchi
2023-05-02 20:50 ` [PATCH 25/30] gdb: add interp::on_tsv_modified method Simon Marchi
2023-05-02 20:50 ` [PATCH 26/30] gdb: add interp::on_breakpoint_created method Simon Marchi
2023-05-02 20:50 ` [PATCH 27/30] gdb: add interp::on_breakpoint_deleted method Simon Marchi
2023-05-02 20:50 ` [PATCH 28/30] gdb: add interp::on_breakpoint_modified method Simon Marchi
2023-05-02 20:50 ` Simon Marchi [this message]
2023-05-02 20:50 ` [PATCH 30/30] gdb: add interp::on_memory_changed method Simon Marchi
2023-05-02 20:50 ` [PATCH 00/30] Make interpreters use virtual methods (instead of observers) Simon Marchi
2023-05-23 12:43 ` [PATCH 00/30] Switch interpreters to use virtual methods Simon Marchi
2023-05-30 19:09 ` Simon Marchi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230502205011.132151-30-simon.marchi@efficios.com \
--to=simon.marchi@efficios.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).