Re: [PATCH v3 08/34] Always run async signal handlers in the main UI

Pedro Alves
2016-05-26T18:13:25Z

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