aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdb/cli/cli-setshow.c13
-rw-r--r--gdb/interps.c8
-rw-r--r--gdb/interps.h6
-rw-r--r--gdb/mi/mi-interp.c34
-rw-r--r--gdb/mi/mi-interp.h1
-rw-r--r--gdb/observable.c1
-rw-r--r--gdb/observable.h7
-rw-r--r--gdb/source.c5
8 files changed, 35 insertions, 40 deletions
diff --git a/gdb/cli/cli-setshow.c b/gdb/cli/cli-setshow.c
index 07233e3..ecb739b 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 d572f92..3cb89b1 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 6fda2ba..948b6f5 100644
--- a/gdb/interps.h
+++ b/gdb/interps.h
@@ -175,6 +175,9 @@ public:
/* 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 73a193d..e15ac81 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);
@@ -793,36 +792,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. */
@@ -973,7 +961,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 8ec8bc0..c190fc1 100644
--- a/gdb/mi/mi-interp.h
+++ b/gdb/mi/mi-interp.h
@@ -69,6 +69,7 @@ public:
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 3535e69..a18b863 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 1c7ba0a..f6047a2 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 98d02d4..9997ccc 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
@@ -454,8 +455,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);
}