[PATCH 20/21] gdb: make set_top_level_interpreter a method of struct ui

Simon Marchi simon.marchi@efficios.com
Fri Sep 8 18:23:14 GMT 2023


No behavior changes expected.

Change-Id: Ie3ab2a2f2191a9df769c51ea81d564724789c6f6
---
 gdb/interps.c | 14 --------------
 gdb/interps.h |  6 ------
 gdb/main.c    |  2 +-
 gdb/ui.c      | 17 ++++++++++++++++-
 gdb/ui.h      |  6 ++++++
 5 files changed, 23 insertions(+), 22 deletions(-)

diff --git a/gdb/interps.c b/gdb/interps.c
index f954d503538c..f30357405877 100644
--- a/gdb/interps.c
+++ b/gdb/interps.c
@@ -80,20 +80,6 @@ find_interp_factory (const char *name)
   return nullptr;
 }
 
-/* See interps.h.  */
-
-void
-set_top_level_interpreter (ui *ui, const char *name)
-{
-  /* Find it.  */
-  struct interp *interp = ui->lookup_interp (name);
-
-  if (interp == NULL)
-    error (_("Interpreter `%s' unrecognized"), name);
-  /* Install it.  */
-  ui->set_current_interpreter (interp, true);
-}
-
 void
 current_interp_set_logging (ui_file_up logfile, bool logging_redirect,
 			    bool debug_redirect)
diff --git a/gdb/interps.h b/gdb/interps.h
index 4c094bf33e32..8416d657fb9a 100644
--- a/gdb/interps.h
+++ b/gdb/interps.h
@@ -215,12 +215,6 @@ class interp : public intrusive_list_node<interp>
   bool inited = false;
 };
 
-/* Set UI's top level interpreter to the interpreter named NAME.
-
-   Throws an error if NAME is not a known interpreter or the interpreter fails
-   to initialize.  */
-extern void set_top_level_interpreter (ui *ui, const char *name);
-
 /* Temporarily set the current interpreter, and reset it on
    destruction.  */
 class scoped_restore_interp
diff --git a/gdb/main.c b/gdb/main.c
index cf46f6acb208..58a79c518999 100644
--- a/gdb/main.c
+++ b/gdb/main.c
@@ -1136,7 +1136,7 @@ captured_main_1 (struct captured_main_args *context)
 
   /* Install the default UI.  All the interpreters should have had a
      look at things by now.  Initialize the default interpreter.  */
-  set_top_level_interpreter (interpreter_p.c_str ());
+  current_ui->set_top_level_interpreter (interpreter_p.c_str ());
 
   if (!quiet)
     {
diff --git a/gdb/ui.c b/gdb/ui.c
index 2db899eb9c31..ec74cc91cd21 100644
--- a/gdb/ui.c
+++ b/gdb/ui.c
@@ -223,6 +223,21 @@ ui::set_current_interpreter (interp *interp, bool top_level)
 
 /* See ui.h.  */
 
+void
+ui::set_top_level_interpreter (const char *name)
+{
+  /* Find it.  */
+  struct interp *interp = this->lookup_interp (name);
+
+  if (interp == NULL)
+    error (_("Interpreter `%s' unrecognized"), name);
+
+  /* Install it.  */
+  this->set_current_interpreter (interp, true);
+}
+
+/* See ui.h.  */
+
 void
 ui::unregister_file_handler ()
 {
@@ -278,7 +293,7 @@ new_ui_command (const char *args, int from_tty)
 
     current_ui = ui.get ();
 
-    set_top_level_interpreter (interpreter_name);
+    current_ui->set_top_level_interpreter (interpreter_name);
 
     top_level_interpreter ()->pre_command_loop ();
 
diff --git a/gdb/ui.h b/gdb/ui.h
index 4f6a32991d6d..cebf112f971c 100644
--- a/gdb/ui.h
+++ b/gdb/ui.h
@@ -179,6 +179,12 @@ struct ui : public intrusive_list_node<ui>
      events such as target stops and new thread creation, even if they
      are caused by CLI commands.  */
   void set_current_interpreter (interp *interp, bool top_level);
+
+  /* Set this UI's top level interpreter to the interpreter named NAME.
+
+     Throws an error if NAME is not a known interpreter or the interpreter fails
+     to initialize.  */
+  void set_top_level_interpreter (const char *name);
 };
 
 /* The main UI.  This is the UI that is bound to stdin/stdout/stderr.
-- 
2.42.0



More information about the Gdb-patches mailing list