From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id +GwcOA/9LGWJNC8AWB0awg (envelope-from ) for ; Mon, 16 Oct 2023 05:06:23 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=GVmds9En; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id E1D261E0C1; Mon, 16 Oct 2023 05:06:23 -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 D45941E00F for ; Mon, 16 Oct 2023 05:06:21 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 83BE3385701C for ; Mon, 16 Oct 2023 09:06:21 +0000 (GMT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id B92133858418 for ; Mon, 16 Oct 2023 09:06:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B92133858418 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org B92133858418 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697447170; cv=none; b=it5dyRt8oMPg3+/Z86ILzBoXTxNPvGo2V+2R7qJI9e+bdU6q19d7Jc6mlkyOsceNDibLHk+hiMPbDMtOL55qeqDV1R8bJ6ONIoidlzuWI90QuWSc89LJUj6DJOlwzS/KZR7KntoEf0qI1gm0aHvxf4V/BBo5xcZ4UNesJQaR6EE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697447170; c=relaxed/simple; bh=hm1tMtomtwq/xaqo7eOZ2RBg/sUNbdqKVP4e8XKNJZE=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=q/2Ev2iQ/k9XA+XsDgl+RraSLHtRPigMuI0YVo8eNylb1ubzHnNkI+SSeH0wEw2qHr4fu/+ys9JtW/7mNbcFsT9TAN5Cm5xbP8OJCzAkPSiz3Fm4lgfaQKIKJ+mQdba3JO2yeDlUOkF4JU9qi9PICC0hmW4Oze0x6mS97ebW4qU= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697447168; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=7hd71LEwgxsCLUQhMCC0nMP4Iex+iFO46xoFJxrwcPA=; b=GVmds9EnZV8lbhN5HJ9bs581tZCw2m9+uJq5udWmG3JWDvvNwuMpO53usvoKLh0MycTTu7 /hUAdyFeujQSAkSI6YpEtezkSC+3ayiLh12XMutj7hM3RMDQh/bpCa0n1n9ALkPnpyFfFI N/HfYawgAMAiSg5fyvvPCmYFN7GPWgo= Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-52-nVhaL4PNNxW4JKPvcUsKxQ-1; Mon, 16 Oct 2023 05:06:06 -0400 X-MC-Unique: nVhaL4PNNxW4JKPvcUsKxQ-1 Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-9c4485166beso42882066b.3 for ; Mon, 16 Oct 2023 02:06:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697447165; x=1698051965; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=7hd71LEwgxsCLUQhMCC0nMP4Iex+iFO46xoFJxrwcPA=; b=NxQFnCQ2wT0z9IGI8JRgpjxolFrXD6QgpLvJUQqzOJ98dVq0e1QL9K0imjbZjAuaF4 KQa5SX32I1He+TCG57/L8XGALFVHxM55s8530MwdE84hDi5vS5J3TpJ5oOyHfO7dKE+5 zkl78oDsfVyfUT7+duRHphk+wI4LPIYOx9EOnMf4VkTQLzUCPuipaREHd7yvCylDnhz3 L3+xIMo5jQ+sqvm3gSBZqoNQBsXK6o/XdMxuzaVp8RBOHqENk9WjcI7wypj9RxgUGzZt KYbfdHIPtdOOf5Zz/r9/V8m5TSCwxJUALMVZVZUkQRhMiK59gRRdtNnU7dXLD9nYn7Aj FoNQ== X-Gm-Message-State: AOJu0YzHBF/jSbzgirJDIK3Wcol9eqwvZvF1mRC0CmzoTeGxBKyyYQLv GHANvtXJ4vx0gENpwDmZSAlb8E3qLcBvEC1fM67G5tl7EbYbC0/ok9Q6GSmEeA8//Sz3PtpeAmt sXTVmvIRL3/7kQkliGpgifXFM10p6gprjcjEriheF+YkuY8j4udNpUQ4ZSSh9i1m90VDneLWiU+ EpxPQp5w== X-Received: by 2002:a17:907:6d08:b0:9be:85c9:43ef with SMTP id sa8-20020a1709076d0800b009be85c943efmr5496127ejc.62.1697447164830; Mon, 16 Oct 2023 02:06:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGDFvFR0kYP5Ed55yA1PCJxYg+Fy/dn1Y4ODkS7Xbs5ms1NRq2/vLRaV6kClZW/VU9Ivr0m0g== X-Received: by 2002:a17:907:6d08:b0:9be:85c9:43ef with SMTP id sa8-20020a1709076d0800b009be85c943efmr5496101ejc.62.1697447164399; Mon, 16 Oct 2023 02:06:04 -0700 (PDT) Received: from localhost ([31.111.84.209]) by smtp.gmail.com with ESMTPSA id e5-20020a17090681c500b00977cad140a8sm3634097ejx.218.2023.10.16.02.06.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 02:06:03 -0700 (PDT) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Luis Machado , Simon Marchi , Lancelot SIX Subject: Re: [PATCH] gdb: replace architecture_changed with new_architecture observer In-Reply-To: References: Date: Mon, 16 Oct 2023 10:06:02 +0100 Message-ID: <87mswjgcn9.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, 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 Andrew Burgess writes: > This commit replaces the architecture_changed observer with a > new_architecture observer. Thanks all for the feedback. I made the changes suggested by Simon and Lancelot, and pushed this patch. Thanks, Andrew > > 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); > > diff --git a/gdb/inferior.c b/gdb/inferior.c > index efe57cceae3..1778723863e 100644 > --- a/gdb/inferior.c > +++ b/gdb/inferior.c > @@ -179,7 +179,6 @@ inferior::set_arch (gdbarch *arch) > gdb_assert (arch != nullptr); > gdb_assert (gdbarch_initialized_p (arch)); > m_gdbarch = arch; > - gdb::observers::architecture_changed.notify (this, arch); > > process_stratum_target *proc_target = this->process_target (); > if (proc_target != nullptr) > diff --git a/gdb/observable.c b/gdb/observable.c > index 09613b2ddda..f2e65b11604 100644 > --- a/gdb/observable.c > +++ b/gdb/observable.c > @@ -52,7 +52,7 @@ DEFINE_OBSERVABLE (about_to_proceed); > DEFINE_OBSERVABLE (breakpoint_created); > DEFINE_OBSERVABLE (breakpoint_deleted); > DEFINE_OBSERVABLE (breakpoint_modified); > -DEFINE_OBSERVABLE (architecture_changed); > +DEFINE_OBSERVABLE (new_architecture); > DEFINE_OBSERVABLE (thread_ptid_changed); > DEFINE_OBSERVABLE (inferior_added); > DEFINE_OBSERVABLE (inferior_appeared); > diff --git a/gdb/observable.h b/gdb/observable.h > index acb05e9b535..a535eedcd38 100644 > --- a/gdb/observable.h > +++ b/gdb/observable.h > @@ -153,10 +153,9 @@ extern observable breakpoint_deleted; > is the modified breakpoint. */ > extern observable breakpoint_modified; > > -/* INF's architecture has changed. The argument NEWARCH is a > - pointer to the new architecture. */ > -extern observable > - architecture_changed; > +/* GDB has instantiated a new architecture, NEWARCH is a pointer to the new > + architecture. */ > +extern observable new_architecture; > > /* The thread's ptid has changed. The OLD_PTID parameter specifies > the old value, and NEW_PTID specifies the new value. */ > 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"); > > if (PyType_Ready (&pending_frame_object_type) < 0) > return -1; > > base-commit: b8ead7d503a7b3719716d42164299c02abd658cf > -- > 2.25.4