This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH v3 08/34] Always run async signal handlers in the main UI
- 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:13:17 +0100
- Subject: Re: [PATCH v3 08/34] Always run async signal handlers in the main UI
- Authentication-results: sourceware.org; auth=none
- References: <1462538104-19109-1-git-send-email-palves at redhat dot com> <1462538104-19109-9-git-send-email-palves at redhat dot com> <573E13D0 dot 7010104 at ericsson dot com>
On 05/19/2016 08:28 PM, Simon Marchi wrote:
> On 16-05-06 08:34 AM, Pedro Alves wrote:
>> -/* The main UI. This is the UI that is bound to stdin/stdout/stderr.
>> - It always exists and is created automatically when GDB starts
>> - up. */
>> +/* The main UI. */
>> static struct ui main_ui_;
>>
>> +struct ui *main_ui = &main_ui_;
>
> I'd suggest making the pointer const, to show (and make sure) that the main ui
> never changes throughout the lifetime of the gdb instance:
>
> +struct ui * const main_ui = &main_ui_;
Hmm, that wouldn't work, because later on the series, main_ui
becomes heap allocated:
https://sourceware.org/ml/gdb-patches/2016-05/msg00125.html
Guess we could instead have:
struct ui *get_main_ui (void);
To make it clearer that this is not supposed to be an lvalue.
And likewise maybe:
struct ui *get_current_ui (void);
void set_current_ui (struct ui *);
Though unless I'm in for some other major rework of the series,
at this point I'd rather defer that to a follow up patch.
I've gone through renaming these objects throughout the whole
series a few times already, and it's quite painful. WDYT?
>
>> struct ui *current_ui = &main_ui_;
>> struct ui *ui_list = &main_ui_;
>
> ui_list could be const for the same reason, while we're at it.
>
Likewise, this becomes heap allocated. (I don't see much point
in changing this one, the only point of making it extern is
to be able to access it in the implementation of ALL_UIS.)
Thanks,
Pedro Alves