From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) by sourceware.org (Postfix) with ESMTPS id 0EF253858438 for ; Mon, 18 Jul 2022 18:51:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 0EF253858438 Received: by mail-ej1-x635.google.com with SMTP id os14so23003741ejb.4 for ; Mon, 18 Jul 2022 11:51:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=iINOtWmNQyRxb9DLKj7jTmrQAa/f7T81+HkD3X2NEXE=; b=th/jA2vIXULPitI/8GO1jbrfN1e0qqprNqlo/+nukNhJTxBJhL2MmieKvCNN/3HywU kCiwciivOQ/D1tafewUIIfNy113/7iBB3gpqdc1g2J6mH9xuQcsZQ4rqWJUgmbH4mpCD ZKAa1R33wz294OdIi9w09itaR39j+VPt+P1TKMt2g6Xd96ex19Mx374Z9TIhGyUTvWac F9vbeOgrEb7WCN1Id4eaYCvytbrdEB1pr1TcLlJCnUtHqXbgnjj+4pEDD36f6RnCOw53 xbXhCtHuA4tajH/WHtD//1p5h76z2vPYTE3/FFXLV2+fYY7KgB1tYzp9e9muE8BFmBgw /iYQ== X-Gm-Message-State: AJIora8L5x8v1HyhLmxxdPYhSb72qK+q5DREJs2hp7iufMTvKnLoUnb4 LmW/taMA4NFbduh+RaVTD90fEcF5iKY3cjQ2NCcGqxaY X-Google-Smtp-Source: AGRyM1t9FrDBaiNnzIX6uZ6LW8p2OkjJMUdgmyNqSfybz5LaqWE+yovV5o2g68TNT4d2T28KHewYyfI0Pd62moXu88I= X-Received: by 2002:a17:907:a056:b0:72b:1964:fbcc with SMTP id gz22-20020a170907a05600b0072b1964fbccmr27266783ejc.489.1658170317527; Mon, 18 Jul 2022 11:51:57 -0700 (PDT) MIME-Version: 1.0 References: <20220419220135.1714665-1-mikaela.szekely@qyriad.me> In-Reply-To: From: Mikaela Szekely Date: Mon, 18 Jul 2022 12:51:46 -0600 Message-ID: Subject: Re: [PATCH][PR gdb/28874] gdb/remote: switch to added threads if there isn't one already To: gdb-patches@sourceware.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-10.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Jul 2022 18:52:01 -0000 Is there anything specific that's blocking this patch from being accepted? This is still an active bug in GDB. On Sat, Jun 25, 2022 at 11:29 AM Mikaela Szekely wrote: > > Are there any thoughts on this? I'm happy to answer any questions if > there are any. > > On Tue, Apr 19, 2022 at 4:01 PM Mikaela Szekely > wrote: > > > > Bug PR gdb/28874 reports a failed assertion when attaching to remote > > targets. This assertion is checked after a call to > > gdb::observers::new_thread.notify from set_running. > > The call to set_running in remote_target::remote_add_thread, however, > > appears to always be called before any call to switch_to_thread > > for remote targets that have set non-stop off. > > > > This commit proposes a new internal function has_inferior_thread in > > gdb/thread.c, which allows remote_target::remote_add_thread to check if > > the current thread has been set or not. And thus I have also adjusted > > the logic of ::remote_add_thread to call switch_to_thread upon thread > > creation if has_inferior_thread returns false. > > > > Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=28874 > > --- > > gdb/gdbthread.h | 3 +++ > > gdb/remote.c | 6 ++++++ > > gdb/thread.c | 7 +++++++ > > 3 files changed, 16 insertions(+) > > > > diff --git a/gdb/gdbthread.h b/gdb/gdbthread.h > > index 1a33eb61221..bf230410a12 100644 > > --- a/gdb/gdbthread.h > > +++ b/gdb/gdbthread.h > > @@ -875,6 +875,9 @@ class scoped_restore_current_thread > > enum language m_lang; > > }; > > > > +/* Returns true if there is a current inferior thread. */ > > +extern bool has_inferior_thread (void); > > + > > /* Returns a pointer into the thread_info corresponding to > > INFERIOR_PTID. INFERIOR_PTID *must* be in the thread list. */ > > extern struct thread_info* inferior_thread (void); > > diff --git a/gdb/remote.c b/gdb/remote.c > > index aa6a67a96e0..d35387650b3 100644 > > --- a/gdb/remote.c > > +++ b/gdb/remote.c > > @@ -2572,6 +2572,12 @@ remote_target::remote_add_thread (ptid_t ptid, bool running, bool executing, > > else > > thread = add_thread (this, ptid); > > > > + /* If there isn't already an active thread, then switch to the > > + thread we just added, so bare-metal targets don't assert the > > + current thread as null. */ > > + if (!has_inferior_thread()) > > + switch_to_thread(thread); > > + > > /* We start by assuming threads are resumed. That state then gets updated > > when we process a matching stop reply. */ > > get_remote_thread_info (thread)->set_resumed (); > > diff --git a/gdb/thread.c b/gdb/thread.c > > index 9d0693bd0b8..e7b418b1c85 100644 > > --- a/gdb/thread.c > > +++ b/gdb/thread.c > > @@ -79,6 +79,13 @@ is_current_thread (const thread_info *thr) > > return thr == current_thread_; > > } > > > > + > > +bool > > +has_inferior_thread (void) > > +{ > > + return current_thread_ != nullptr; > > +} > > + > > struct thread_info* > > inferior_thread (void) > > { > > -- > > 2.35.1 > >