This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH v3 07/34] Make the intepreters output to all UIs
- From: Pedro Alves <palves at redhat dot com>
- To: Simon Marchi <simon dot marchi at ericsson dot com>, gdb-patches at sourceware dot org
- Date: Thu, 26 May 2016 19:11:53 +0100
- Subject: Re: [PATCH v3 07/34] Make the intepreters output to all UIs
- Authentication-results: sourceware.org; auth=none
- References: <1462538104-19109-1-git-send-email-palves at redhat dot com> <1462538104-19109-8-git-send-email-palves at redhat dot com> <573DD8A7 dot 60806 at ericsson dot com>
On 05/19/2016 04:15 PM, Simon Marchi wrote:
> On 16-05-06 08:34 AM, Pedro Alves wrote:
>> + /* Traverse through all UI, and switch the current UI to the one
>> + being iterated. */
>> +#define SWITCH_THRU_ALL_UIS(STATE) \
>> + for (switch_thru_all_uis_init (&STATE); \
>> + switch_thru_all_uis_cond (&STATE); \
>> + switch_thru_all_uis_next (&STATE)) \
>
> The last backslash is not necessary I think.
Thanks, indeed. I've removed it.
>
> I was wondering why you did not name this "ALL_UIS", using the same pattern
> as ALL_INFERIORS & al, but then I realized it's because this one actually
> sets current_ui before each iteration (and restores it at the end).
Exactly.
>
> I guess the reason you need to do this is because, again, everything relies on
> accessing the global current_ui, whereas it should be passed down as a parameter.
It goes deeper than straight access of current_ui directly. It goes all the
way to gdb_stdout, etc., which are really fields of current_ui. I don't
ever see us passing down a current_ui to _all_ functions that might want
to do I/O. That'd mean passing it around _everywhere_. So basically, if
you're calling a function that may do output, and you want that output
to be duplicated to all UIs, you need to use SWITCH_THRU_ALL_UIS.
Note, we can't just call such functions once, with output redirected to
a buffer, and then print that buffer on all UI's streams, because each
UI's ui_out may want to print differently, and also run through distinct
code paths, due to ui_out_is_mi_like_p.
> I am not saying it should be done in this series (it's a big task in itself), but
> we can probably tackle it after. They way you did things should make it easy to
> improve things later on.
Thanks,
Pedro Alves