From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 98691 invoked by alias); 19 May 2016 19:28:28 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 98677 invoked by uid 89); 19 May 2016 19:28:27 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_PASS autolearn=ham version=3.3.2 spammy=whichever X-HELO: usplmg20.ericsson.net Received: from usplmg20.ericsson.net (HELO usplmg20.ericsson.net) (198.24.6.45) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Thu, 19 May 2016 19:28:25 +0000 Received: from EUSAAHC004.ericsson.se (Unknown_Domain [147.117.188.84]) by usplmg20.ericsson.net (Symantec Mail Security) with SMTP id 6C.14.09012.98B0E375; Thu, 19 May 2016 20:52:58 +0200 (CEST) Received: from [142.133.110.144] (147.117.188.8) by smtp-am.internal.ericsson.com (147.117.188.86) with Microsoft SMTP Server id 14.3.248.2; Thu, 19 May 2016 15:28:17 -0400 Subject: Re: [PATCH v3 08/34] Always run async signal handlers in the main UI To: Pedro Alves , References: <1462538104-19109-1-git-send-email-palves@redhat.com> <1462538104-19109-9-git-send-email-palves@redhat.com> From: Simon Marchi Message-ID: <573E13D0.7010104@ericsson.com> Date: Thu, 19 May 2016 19:28:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: <1462538104-19109-9-git-send-email-palves@redhat.com> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2016-05/txt/msg00341.txt.bz2 On 16-05-06 08:34 AM, Pedro Alves wrote: > Async signal handlers have no connection to whichever was the current > UI, and thus always run on the main one. > > gdb/ChangeLog: > yyyy-mm-dd Pedro Alves > > * event-loop.c: Include top.h. > (invoke_async_signal_handlers): Switch to the main UI. > * event-top.c (main_ui_): Update comment. > (main_ui): New global. > * top.h (main_ui): Declare. > --- > gdb/event-loop.c | 4 ++++ > gdb/event-top.c | 5 ++--- > gdb/top.h | 5 +++++ > 3 files changed, 11 insertions(+), 3 deletions(-) > > diff --git a/gdb/event-loop.c b/gdb/event-loop.c > index 60ef2a5..fe28305 100644 > --- a/gdb/event-loop.c > +++ b/gdb/event-loop.c > @@ -35,6 +35,7 @@ > #include "gdb_sys_time.h" > #include "gdb_select.h" > #include "observer.h" > +#include "top.h" > > /* Tell create_file_handler what events we are interested in. > This is used by the select version of the event loop. */ > @@ -967,6 +968,9 @@ invoke_async_signal_handlers (void) > break; > any_ready = 1; > async_handler_ptr->ready = 0; > + /* Async signal handlers have no connection to whichever was the > + current UI, and thus always run on the main one. */ > + current_ui = main_ui; > (*async_handler_ptr->proc) (async_handler_ptr->client_data); > } > > diff --git a/gdb/event-top.c b/gdb/event-top.c > index c6e3b7e..63f6896 100644 > --- a/gdb/event-top.c > +++ b/gdb/event-top.c > @@ -437,11 +437,10 @@ top_level_prompt (void) > return xstrdup (prompt); > } > > -/* 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_; > 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.