[03/21] gdb: make interp_add a method of struct ui

Message ID 20230908190227.96319-4-simon.marchi@efficios.com
State New
Headers
Series ui / interp cleansup |

Commit Message

Simon Marchi Sept. 8, 2023, 6:22 p.m. UTC
  No behavior changes expected.

Change-Id: Ice8958068fd4025e23bff87bcdee45a5f64a41c4
---
 gdb/interps.c | 12 +-----------
 gdb/ui.c      | 10 ++++++++++
 gdb/ui.h      |  4 ++++
 3 files changed, 15 insertions(+), 11 deletions(-)
  

Patch

diff --git a/gdb/interps.c b/gdb/interps.c
index 3ddcfe9566fe..b05a6c4eb875 100644
--- a/gdb/interps.c
+++ b/gdb/interps.c
@@ -83,16 +83,6 @@  interp_factory_register (const char *name, interp_factory_func func)
   interpreter_factories.emplace_back (name, func);
 }
 
-/* Add interpreter INTERP to the gdb interpreter list.  The
-   interpreter must not have previously been added.  */
-static void
-interp_add (struct ui *ui, struct interp *interp)
-{
-  gdb_assert (ui->lookup_existing_interp (interp->name ()) == nullptr);
-
-  ui->interp_list.push_back (*interp);
-}
-
 /* This sets the current interpreter to be INTERP.  If INTERP has not
    been initialized, then this will also run the init method.
 
@@ -170,7 +160,7 @@  interp_lookup (struct ui *ui, const char *name)
     if (strcmp (factory.name, name) == 0)
       {
 	interp = factory.func (factory.name);
-	interp_add (ui, interp);
+	ui->add_interp (interp);
 	return interp;
       }
 
diff --git a/gdb/ui.c b/gdb/ui.c
index ae87dcda2453..624187ac73c3 100644
--- a/gdb/ui.c
+++ b/gdb/ui.c
@@ -159,6 +159,16 @@  ui::lookup_existing_interp (const char *name) const
   return nullptr;
 }
 
+/* See ui.h.  */
+
+void
+ui::add_interp (interp *interp)
+{
+  gdb_assert (this->lookup_existing_interp (interp->name ()) == nullptr);
+
+  this->interp_list.push_back (*interp);
+}
+
 /* See top.h.  */
 
 void
diff --git a/gdb/ui.h b/gdb/ui.h
index 23c6b2e1a3d9..48cad96b3fb8 100644
--- a/gdb/ui.h
+++ b/gdb/ui.h
@@ -162,6 +162,10 @@  struct ui : public intrusive_list_node<ui>
   /* 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;
+
+  /* Add interpreter INTERP to this UI's interpreter list.  The
+     interpreter must not have previously been added.  */
+  void add_interp (interp *interp);
 };
 
 /* The main UI.  This is the UI that is bound to stdin/stdout/stderr.