Same idea as previous patches, but for command_param_changed.
Change-Id: I7c2196343423360da05f016f8ffa871c064092bb
#include <ctype.h>
#include "arch-utils.h"
#include "observable.h"
+#include "interps.h"
#include "ui-out.h"
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:
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:
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:
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;
}
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
/* 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;
/* 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"
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);
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. */
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");
}
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;
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);
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 */>
#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
}
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);
}