No behavior changes expected.
Change-Id: I2bd15b70425326a3b499b9346217b93f76175999
---
gdb/interps.c | 22 ++--------------------
gdb/ui.c | 12 ++++++++++++
gdb/ui.h | 4 ++++
3 files changed, 18 insertions(+), 20 deletions(-)
@@ -41,11 +41,6 @@
#include "gdbsupport/buildargv.h"
#include "gdbsupport/scope-exit.h"
-/* The magic initialization routine for this module. */
-
-static struct interp *interp_lookup_existing (struct ui *ui,
- const char *name);
-
interp::interp (const char *name)
: m_name (name)
{
@@ -93,7 +88,7 @@ interp_factory_register (const char *name, interp_factory_func func)
static void
interp_add (struct ui *ui, struct interp *interp)
{
- gdb_assert (interp_lookup_existing (ui, interp->name ()) == NULL);
+ gdb_assert (ui->lookup_existing_interp (interp->name ()) == nullptr);
ui->interp_list.push_back (*interp);
}
@@ -158,19 +153,6 @@ interp_set (struct interp *interp, bool top_level)
"to a newer version of MI."));
}
-/* Look up the interpreter for NAME. If no such interpreter exists,
- return NULL, otherwise return a pointer to the interpreter. */
-
-static struct interp *
-interp_lookup_existing (struct ui *ui, const char *name)
-{
- for (interp &interp : ui->interp_list)
- if (strcmp (interp.name (), name) == 0)
- return &interp;
-
- return nullptr;
-}
-
/* See interps.h. */
struct interp *
@@ -180,7 +162,7 @@ interp_lookup (struct ui *ui, const char *name)
return NULL;
/* Only create each interpreter once per top level. */
- struct interp *interp = interp_lookup_existing (ui, name);
+ interp *interp = ui->lookup_existing_interp (name);
if (interp != NULL)
return interp;
@@ -147,6 +147,18 @@ ui::register_file_handler ()
string_printf ("ui-%d", num), true);
}
+/* See ui.h. */
+
+interp *
+ui::lookup_existing_interp (const char *name) const
+{
+ for (interp &interp : this->interp_list)
+ if (strcmp (interp.name (), name) == 0)
+ return &interp;
+
+ return nullptr;
+}
+
/* See top.h. */
void
@@ -158,6 +158,10 @@ struct ui : public intrusive_list_node<ui>
/* Return true if this UI's input fd is a tty. */
bool input_interactive_p () const;
+
+ /* Look up the interpreter for NAME. If no such interpreter exists,
+ return nullptr, otherwise return a pointer to the interpreter. */
+ interp *lookup_existing_interp (const char *name) const;
};
/* The main UI. This is the UI that is bound to stdin/stdout/stderr.