From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id TkRFL+puKWW20iwAWB0awg (envelope-from ) for ; Fri, 13 Oct 2023 12:23:06 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; secure) header.d=lancelotsix.com header.i=@lancelotsix.com header.a=rsa-sha256 header.s=2021 header.b=ZaNlOmL/; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id B47511E0C1; Fri, 13 Oct 2023 12:23:06 -0400 (EDT) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 3939F1E091 for ; Fri, 13 Oct 2023 12:23:04 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C5894385770F for ; Fri, 13 Oct 2023 16:23:03 +0000 (GMT) Received: from lndn.lancelotsix.com (lndn.lancelotsix.com [51.195.220.111]) by sourceware.org (Postfix) with ESMTPS id 431BE3858D1E for ; Fri, 13 Oct 2023 16:22:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 431BE3858D1E Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=lancelotsix.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=lancelotsix.com Received: from octopus (cust120-dsl54.idnet.net [212.69.54.120]) by lndn.lancelotsix.com (Postfix) with ESMTPSA id CE8EA864F6; Fri, 13 Oct 2023 16:22:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=lancelotsix.com; s=2021; t=1697214170; bh=0ny4rHJSlNf7PmDyD1xVDYsYb6wMvb1CPdMjLr0IPoc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ZaNlOmL/cvTprc6M2LwU/xGDNj/0dy8t0byCWZ74xScw9c83DrdBEQB41stFesL7Q M+nxMYeD1NUuZRvCVFkHNpD6cbtVa4dO1RP3yqR0tR+MGc9HBmrds1L6+ESCo3bFch T5LWiFdwTYO3WrrgCtqIacsPb2cEVR7UIqCe5lWVkdV2XQEuRKr4ROMbOc8s3crJ1J zIsIORixu48Br0if/XG5OmIoHIdjkrhfC4N8Vz7ZuU2n7VIvocfBQ2FglK6Zt+yV9r vuhE4sagi2jdlm6UOo7ZN6QGnF9b2FQjz53FJ3r/Ogli0beUEa+kJBFFHPh3oNa3AS Q6XZyzO8TsFyA== Date: Fri, 13 Oct 2023 17:22:45 +0100 From: Lancelot SIX To: Andrew Burgess Cc: gdb-patches@sourceware.org, Luis Machado Subject: Re: [PATCH] gdb: replace architecture_changed with new_architecture observer Message-ID: <20231013162245.33b2vblnd32774i4@octopus> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.6.2 (lndn.lancelotsix.com [0.0.0.0]); Fri, 13 Oct 2023 16:22:50 +0000 (UTC) X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, 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.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Hi Andrew, On Thu, Oct 12, 2023 at 03:22:18PM +0100, Andrew Burgess wrote: > This commit replaces the architecture_changed observer with a > new_architecture observer. > > Currently the only user of the architecture_changed observer is the > Python code, which uses this observer to register the Python unwinder > with the architecture. > > The problem is that the architecture_changed observer is triggered > from inferior::set_arch(), which only sees the inferior-wide gdbarch > value. For targets that use thread-specific architectures, these > never trigger the architecture_changed observer, and so never have the > Python unwinder registered with them. > > When it comes to unwinding GDB makes use of the frame's gdbarch, which > is based on the thread's regcache gdbarch, which is set in > get_thread_regcache to the value returned from > target_thread_architecture, which is not always the inferiors gdbarch > value, it might be a thread-specific gdbarch which has not passed > through inferior::set_arch(). > > The new_architecture observer will be triggered from > gdbarch_find_by_info, whenever a new gdbarch is created and > initialised. As GDB caches and reuses gdbarch values, we should > expect to see each new architecture trigger the new_architecture > observer just once. > > After this commit, targets that make use of thread-specific > architectures should be able to make use of Python unwinders. > > As I don't have access to a machine that makes use of thread-specific > architectures right now, I asked Luis to confirm that an AArch64 > target that uses SVE/SME can't use the Python unwinders in threads > that are using a thread-specific architectures, and he confirmed that > this is indeed the case, see this discussion: FYI, I have also tested this patch with AMDGPU which uses thread-specific gdbarch for the GPU threads (a.k.a waves). Without the patch, the unwinder you provided in the other thread is not executed, but it is after applying this patch. > > https://inbox.sourceware.org/gdb/87wmvsat8i.fsf@redhat.com > --- > gdb/arch-utils.c | 2 ++ > gdb/inferior.c | 1 - > gdb/observable.c | 2 +- > gdb/observable.h | 7 +++---- > gdb/python/py-unwind.c | 6 +++--- > 5 files changed, 9 insertions(+), 9 deletions(-) > > diff --git a/gdb/python/py-unwind.c b/gdb/python/py-unwind.c > index f8b142dd52c..4de81c0a7eb 100644 > --- a/gdb/python/py-unwind.c > +++ b/gdb/python/py-unwind.c > @@ -945,7 +945,7 @@ static const registry::key pyuw_gdbarch_data; > intermediary. */ > > static void > -pyuw_on_new_gdbarch (inferior *inf, gdbarch *newarch) > +pyuw_on_new_gdbarch (gdbarch *newarch) > { > struct pyuw_gdbarch_data_type *data = pyuw_gdbarch_data.get (newarch); > if (data == nullptr) > @@ -974,8 +974,8 @@ pyuw_on_new_gdbarch (inferior *inf, gdbarch *newarch) > static int CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION > gdbpy_initialize_unwind (void) > { > - gdb::observers::architecture_changed.attach (pyuw_on_new_gdbarch, > - "py-unwind"); > + gdb::observers::new_architecture.attach (pyuw_on_new_gdbarch, > + "py-unwind"); Just one nit here, with the observer rename, this can fix in a single line. Tested-By: Lancelot Six Best, Laneclot. > > if (PyType_Ready (&pending_frame_object_type) < 0) > return -1; > > base-commit: b8ead7d503a7b3719716d42164299c02abd658cf > -- > 2.25.4 >