From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 38478 invoked by alias); 30 May 2019 13:57:03 -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 38469 invoked by uid 89); 30 May 2019 13:57:03 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=0.1 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE,UNSUBSCRIBE_BODY autolearn=no version=3.3.1 spammy= X-HELO: mail-wm1-f68.google.com Received: from mail-wm1-f68.google.com (HELO mail-wm1-f68.google.com) (209.85.128.68) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 30 May 2019 13:57:02 +0000 Received: by mail-wm1-f68.google.com with SMTP id e19so6044667wme.1 for ; Thu, 30 May 2019 06:57:02 -0700 (PDT) Return-Path: Received: from ?IPv6:2001:8a0:f913:f700:4eeb:42ff:feef:f164? ([2001:8a0:f913:f700:4eeb:42ff:feef:f164]) by smtp.gmail.com with ESMTPSA id x7sm1657200wmc.44.2019.05.30.06.56.58 (version=TLS1_3 cipher=AEAD-AES128-GCM-SHA256 bits=128/128); Thu, 30 May 2019 06:56:58 -0700 (PDT) Subject: Re: [PATCH v3 5/8] Introduce run_on_main_thread To: Tom Tromey References: <20190529212916.23721-1-tom@tromey.com> <20190529212916.23721-6-tom@tromey.com> <9f9ea56d-349f-dc19-6201-9241fee71e49@redhat.com> <87h89cw02c.fsf@tromey.com> Cc: gdb-patches@sourceware.org From: Pedro Alves Message-ID: Date: Thu, 30 May 2019 13:57:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <87h89cw02c.fsf@tromey.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2019-05/txt/msg00692.txt.bz2 On 5/30/19 2:20 PM, Tom Tromey wrote: > Pedro> Can Python's gdb.post_event be built on top of this? > Pedro> It would fix that nasty "atomically enough" race in gdbpy_run_events, > Pedro> I guess. > > Yes, and actually I wrote a patch to do this once, but I dropped it from > this series because it was unrelated. > >>> + for (auto &item : local) >>> + item (); > > Pedro> I'd think this should swallow errors when calling > Pedro> each item, instead of letting an exception escape and > Pedro> discard all other items, since each item call should be > Pedro> in principle logically unrelated? > > Pedro> Maybe we could unit test this code. > > I wasn't sure how. In a unit test, the main thread code could spawn a thread that calls run_on_main_thread. The main thread would then nest an event loop to run the main-thread events. The posted event would write to a global that would unlock the nested event loop. Something similar to wait_sync_command_done. > But for this maybe the callback should be noexcept. Hmm, maybe. But then if someone forgets to try/catch, we end up aborting gdb. Pick what you prefer, as long as we decide and document something. Thanks, Pedro Alves