[10/21] gdb/mi: use m_ui instead of current_ui in mi_interp::init

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

Commit Message

Simon Marchi Sept. 8, 2023, 6:23 p.m. UTC
  gdb_stdout accesses current_ui under the hood.  Use m_ui to get the
stdout file instead.  Add an stdout method to ui to help with that (it
would feel wrong to access ui::m_gdb_stdout directly).

Change-Id: I03739df387c8de01bc692d7ddddbb66544555630
---
 gdb/mi/mi-interp.c | 2 +-
 gdb/ui.h           | 3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)
  

Patch

diff --git a/gdb/mi/mi-interp.c b/gdb/mi/mi-interp.c
index 3095301b2f11..f260d98837cf 100644
--- a/gdb/mi/mi-interp.c
+++ b/gdb/mi/mi-interp.c
@@ -86,7 +86,7 @@  mi_interp::init (bool top_level)
   /* Store the current output channel, so that we can create a console
      channel that encapsulates and prefixes all gdb_output-type bits
      coming from the rest of the debugger.  */
-  mi->raw_stdout = gdb_stdout;
+  mi->raw_stdout = m_ui->stdout ();
 
   /* Create MI console channels, each with a different prefix so they
      can be distinguished.  */
diff --git a/gdb/ui.h b/gdb/ui.h
index b9ca9c0c80a0..be89ab3d6848 100644
--- a/gdb/ui.h
+++ b/gdb/ui.h
@@ -150,6 +150,9 @@  struct ui : public intrusive_list_node<ui>
   /* The current ui_out.  */
   struct ui_out *m_current_uiout = nullptr;
 
+  ui_file *stdout ()
+  { return m_gdb_stdout; }
+
   /* Register the UI's input file descriptor in the event loop.  */
   void register_file_handler ();