[11/21] gdb/cli: use m_ui instead of current_ui in cli_interp::resume

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

Commit Message

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

Change-Id: I7fd944c99d249b3080d74d949186fe92795568eb
---
 gdb/cli/cli-interp.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
  

Comments

Andrew Burgess Sept. 12, 2023, 10:40 a.m. UTC | #1
Simon Marchi via Gdb-patches <gdb-patches@sourceware.org> writes:

> No behavior changes expected.
>
> Change-Id: I7fd944c99d249b3080d74d949186fe92795568eb
> ---
>  gdb/cli/cli-interp.c | 9 +++------
>  1 file changed, 3 insertions(+), 6 deletions(-)
>
> diff --git a/gdb/cli/cli-interp.c b/gdb/cli/cli-interp.c
> index f0fa26919e76..8f1dbef56a6e 100644
> --- a/gdb/cli/cli-interp.c
> +++ b/gdb/cli/cli-interp.c
> @@ -190,25 +190,22 @@ cli_interp::init (bool top_level)
>  void
>  cli_interp::resume ()
>  {
> -  struct ui *ui = current_ui;
> -  struct ui_file *stream;
> -
>    /*sync_execution = 1; */
>  
>    /* gdb_setup_readline will change gdb_stdout.  If the CLI was
>       previously writing to gdb_stdout, then set it to the new
>       gdb_stdout afterwards.  */
>  
> -  stream = m_cli_uiout->set_stream (gdb_stdout);
> +  ui_file *stream = m_cli_uiout->set_stream (gdb_stdout);

In the previous patch you changed an explicit reference to gdb_stdout to
m_ui->stdout ().  It's not clear why you haven't done that here, and in
other places in this function.

Thanks,
Andrew

>    if (stream != gdb_stdout)
>      {
>        m_cli_uiout->set_stream (stream);
>        stream = NULL;
>      }
>  
> -  gdb_setup_readline (ui, 1);
> +  gdb_setup_readline (m_ui, 1);
>  
> -  ui->input_handler = command_line_handler;
> +  m_ui->input_handler = command_line_handler;
>  
>    if (stream != NULL)
>      m_cli_uiout->set_stream (gdb_stdout);
> -- 
> 2.42.0
  
Simon Marchi Sept. 12, 2023, 3:42 p.m. UTC | #2
On 9/12/23 06:40, Andrew Burgess via Gdb-patches wrote:
> Simon Marchi via Gdb-patches <gdb-patches@sourceware.org> writes:
> 
>> No behavior changes expected.
>>
>> Change-Id: I7fd944c99d249b3080d74d949186fe92795568eb
>> ---
>>  gdb/cli/cli-interp.c | 9 +++------
>>  1 file changed, 3 insertions(+), 6 deletions(-)
>>
>> diff --git a/gdb/cli/cli-interp.c b/gdb/cli/cli-interp.c
>> index f0fa26919e76..8f1dbef56a6e 100644
>> --- a/gdb/cli/cli-interp.c
>> +++ b/gdb/cli/cli-interp.c
>> @@ -190,25 +190,22 @@ cli_interp::init (bool top_level)
>>  void
>>  cli_interp::resume ()
>>  {
>> -  struct ui *ui = current_ui;
>> -  struct ui_file *stream;
>> -
>>    /*sync_execution = 1; */
>>  
>>    /* gdb_setup_readline will change gdb_stdout.  If the CLI was
>>       previously writing to gdb_stdout, then set it to the new
>>       gdb_stdout afterwards.  */
>>  
>> -  stream = m_cli_uiout->set_stream (gdb_stdout);
>> +  ui_file *stream = m_cli_uiout->set_stream (gdb_stdout);
> 
> In the previous patch you changed an explicit reference to gdb_stdout to
> m_ui->stdout ().  It's not clear why you haven't done that here, and in
> other places in this function.

gdb_stdout uses current_ui under the hood, so I think I should change it
here as well (as well as in the other patches, as you have noted).

For v2, I will add a preparatory patch that adds all the necessary
getters and setters in struct ui for stdout, stdin, etc, and I will go
over these patches to uncover uses of current_ui hidden behind these
macros.

Simon
  

Patch

diff --git a/gdb/cli/cli-interp.c b/gdb/cli/cli-interp.c
index f0fa26919e76..8f1dbef56a6e 100644
--- a/gdb/cli/cli-interp.c
+++ b/gdb/cli/cli-interp.c
@@ -190,25 +190,22 @@  cli_interp::init (bool top_level)
 void
 cli_interp::resume ()
 {
-  struct ui *ui = current_ui;
-  struct ui_file *stream;
-
   /*sync_execution = 1; */
 
   /* gdb_setup_readline will change gdb_stdout.  If the CLI was
      previously writing to gdb_stdout, then set it to the new
      gdb_stdout afterwards.  */
 
-  stream = m_cli_uiout->set_stream (gdb_stdout);
+  ui_file *stream = m_cli_uiout->set_stream (gdb_stdout);
   if (stream != gdb_stdout)
     {
       m_cli_uiout->set_stream (stream);
       stream = NULL;
     }
 
-  gdb_setup_readline (ui, 1);
+  gdb_setup_readline (m_ui, 1);
 
-  ui->input_handler = command_line_handler;
+  m_ui->input_handler = command_line_handler;
 
   if (stream != NULL)
     m_cli_uiout->set_stream (gdb_stdout);