From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id ItR3EsURKGVw+CsAWB0awg (envelope-from ) for ; Thu, 12 Oct 2023 11:33:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simark.ca; s=mail; t=1697124805; bh=WdnW7evSrUzNMLg1cc+SiwV6guaiP0YHotVi/k2lMNk=; h=Date:Subject:To:Cc:References:From:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=LNjJDnV7WQs0P7KLgq/ciREwb92LmuaK1fFcSqJbJ+LTSuUHSj7nTz+4oH7ffDvsx yLIyAO8oNSlthl0vIcagaB+/4V7aXNtR/zlsJxOMymKW0zSUTSKyahNzvifNcJY884 OukcOwGBRdF/p+UQ5PZgGtWH/yhe7texiewoSJ5g= Received: by simark.ca (Postfix, from userid 112) id 420131E0C1; Thu, 12 Oct 2023 11:33:25 -0400 (EDT) Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=simark.ca header.i=@simark.ca header.a=rsa-sha256 header.s=mail header.b=GOlOSmNo; dkim-atps=neutral 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 28A6B1E091 for ; Thu, 12 Oct 2023 11:33:23 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C3438385CC98 for ; Thu, 12 Oct 2023 15:33:22 +0000 (GMT) Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 66C61385840C for ; Thu, 12 Oct 2023 15:33:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 66C61385840C Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=simark.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=simark.ca DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simark.ca; s=mail; t=1697124791; bh=WdnW7evSrUzNMLg1cc+SiwV6guaiP0YHotVi/k2lMNk=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=GOlOSmNoWjgsY7PejcwsUNyM77guv4JmWoU41aMpxz4YRTlA3dFQKD66MCV+pe91M l16GyTosZWSIGkeoA5vWc1c4dbn6U+aqf3cbCBuxy/8Bj5c7d23rHeVclimXpGCr3+ g04ZIrsni6RebY2Q0KinBHU+MyDrLIvNvp7K/BwA= Received: from [10.0.0.11] (modemcable238.237-201-24.mc.videotron.ca [24.201.237.238]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 026E61E091; Thu, 12 Oct 2023 11:33:10 -0400 (EDT) Message-ID: Date: Thu, 12 Oct 2023 11:33:10 -0400 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] gdb: replace architecture_changed with new_architecture observer Content-Language: en-US To: Andrew Burgess , gdb-patches@sourceware.org Cc: Luis Machado References: From: Simon Marchi In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-10.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_PASS, 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 On 2023-10-12 10:22, 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: > > 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/arch-utils.c b/gdb/arch-utils.c > index 60a50ea5b2c..1c83bbe3a58 100644 > --- a/gdb/arch-utils.c > +++ b/gdb/arch-utils.c > @@ -1476,6 +1476,8 @@ gdbarch_find_by_info (struct gdbarch_info info) > verify_gdbarch (new_gdbarch); > new_gdbarch->initialized_p = true; > > + gdb::observers::new_architecture.notify (new_gdbarch); > + > if (gdbarch_debug) > gdbarch_dump (new_gdbarch, gdb_stdlog); Just a detail, but I would put the notify after the gdbarch_dump call. This way gdbarch_find_by_info does all it needs to do, and then it lets other parts of GDB do their thing. Otherwise, that looks sensible to me: Approved-By: Simon Marchi Simon