From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 5vDdOAcLKGXd8isAWB0awg (envelope-from ) for ; Thu, 12 Oct 2023 11:04:39 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=armh.onmicrosoft.com header.i=@armh.onmicrosoft.com header.a=rsa-sha256 header.s=selector2-armh-onmicrosoft-com header.b=cOt4R2Dp; dkim=pass (1024-bit key) header.d=armh.onmicrosoft.com header.i=@armh.onmicrosoft.com header.a=rsa-sha256 header.s=selector2-armh-onmicrosoft-com header.b=cOt4R2Dp; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id DEDB21E0C1; Thu, 12 Oct 2023 11:04:39 -0400 (EDT) Received: from server2.sourceware.org (ip-8-43-85-97.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 962831E00F for ; Thu, 12 Oct 2023 11:04:37 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 003183858404 for ; Thu, 12 Oct 2023 15:04:37 +0000 (GMT) Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on2088.outbound.protection.outlook.com [40.107.6.88]) by sourceware.org (Postfix) with ESMTPS id A51FD3857BA4 for ; Thu, 12 Oct 2023 15:04:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A51FD3857BA4 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=SPmVCiDOJSASyQkSwEoz9JQrK9vHyAwBFqiPSBqKdto=; b=cOt4R2DpJqmYE4CfXubNBRCus9o8l2bamJdcaIWja1S0zrrPc5UQmdJiroFZbqHGyQieYZWeH8tkVlMZp/NUtnjxvm5BTiaK+SUGL4gEKXytCQOy/lO7Te3y/lpzyXSX5dHGJ8umVyOOX4FOJVG3TecR52kRpjS4A2JEFhKfceg= Received: from AS8PR07CA0045.eurprd07.prod.outlook.com (2603:10a6:20b:459::16) by DU0PR08MB9701.eurprd08.prod.outlook.com (2603:10a6:10:447::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.42; Thu, 12 Oct 2023 15:04:15 +0000 Received: from AM7EUR03FT061.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:459:cafe::b3) by AS8PR07CA0045.outlook.office365.com (2603:10a6:20b:459::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6886.30 via Frontend Transport; Thu, 12 Oct 2023 15:04:15 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; pr=C Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM7EUR03FT061.mail.protection.outlook.com (100.127.140.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6886.23 via Frontend Transport; Thu, 12 Oct 2023 15:04:15 +0000 Received: ("Tessian outbound ab4fc72d2cd4:v211"); Thu, 12 Oct 2023 15:04:15 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 5bd4e33557ce7f89 X-CR-MTA-TID: 64aa7808 Received: from 159f2c1f86ff.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 9124068B-45FA-48AB-97E6-606E75840346.1; Thu, 12 Oct 2023 15:04:08 +0000 Received: from EUR03-DBA-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 159f2c1f86ff.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 12 Oct 2023 15:04:08 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JfTkTe2uxPUwux2GyZKouzq6JFny/MpGHyeH9puvDiMMSkDeqU1uxmng/p/LTyNkvK2RgzQPgh/fMMi2B/B72aDo8B3HF+EinFA6q1BKX1F5DguByY0Lva34jDCefUqI9uQCRLMRvvWKuRzMqzP/p7c2bEnqBSk2/Xul7xJT2HIWd2/KVKOdU06H/7mOBHiFdAugPf4iEzSiAogjZdCzRhg2VQjzm325LWyVcWb4cGoJawbfke+aVekaqVUt3AjIbjN9sY7IwfrmbhddptV8a3riIb5cJxAr0q/CGtOeAt+i1tm00dmGq3/BJT96xb5P3mSpyMesXv1Fko77UGWenA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=SPmVCiDOJSASyQkSwEoz9JQrK9vHyAwBFqiPSBqKdto=; b=W7mvrL0rKHiSdzJTFLdTqC7v7KeN0D8RdmQdtIiClgC+6v4owcCGUrWuDCe9PIMZBcunTKffaALKxZuSVv/cesfq40CiWG8QKMjF37ZX7xwpgNQy7CsuMlfIaGg1ETvsMQsuS7ePmMhNXLY2LPvIimq6VDgKgy2wPF+Wqi2w4hjD2OA+WNJI80a/lkxP7JqLirs72V5+I56pcB/AkSJIJ62DN8KqlgT0+O1H6j93OylaWPyhf+NYIx8S6UtM4aSZUTmPVZAy9ypC8h7yDYQJ0GTPtCltH0/shxMxz9zS9dpoPD2PjadS/hmK6gsKiyEvAFAsTJuQ6aR7DCbMJ/loug== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=SPmVCiDOJSASyQkSwEoz9JQrK9vHyAwBFqiPSBqKdto=; b=cOt4R2DpJqmYE4CfXubNBRCus9o8l2bamJdcaIWja1S0zrrPc5UQmdJiroFZbqHGyQieYZWeH8tkVlMZp/NUtnjxvm5BTiaK+SUGL4gEKXytCQOy/lO7Te3y/lpzyXSX5dHGJ8umVyOOX4FOJVG3TecR52kRpjS4A2JEFhKfceg= Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; Received: from VI1PR08MB3919.eurprd08.prod.outlook.com (2603:10a6:803:c4::31) by VI1PR08MB9982.eurprd08.prod.outlook.com (2603:10a6:800:1c4::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.38; Thu, 12 Oct 2023 15:04:07 +0000 Received: from VI1PR08MB3919.eurprd08.prod.outlook.com ([fe80::c126:1009:20a5:195]) by VI1PR08MB3919.eurprd08.prod.outlook.com ([fe80::c126:1009:20a5:195%4]) with mapi id 15.20.6863.032; Thu, 12 Oct 2023 15:04:06 +0000 Message-ID: Date: Thu, 12 Oct 2023 16:04:02 +0100 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 References: From: Luis Machado In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-ClientProxiedBy: LO4P123CA0680.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:351::9) To VI1PR08MB3919.eurprd08.prod.outlook.com (2603:10a6:803:c4::31) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: VI1PR08MB3919:EE_|VI1PR08MB9982:EE_|AM7EUR03FT061:EE_|DU0PR08MB9701:EE_ X-MS-Office365-Filtering-Correlation-Id: a975e738-3d4b-418d-941a-08dbcb34803b x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: HuwtZIs2scRoSxPYX2ix7Znfh2hfxV4yvvZyu7fv7kAJTQ4HYzRigFxUOX9/BtUC1J2kx8gcQAz0gcQ1KcOxbJB3yz3qimb5aDOjKs75j6VxTWxwmP3YZjg3B1S/a6J/SdRWMSs812MjB0gX2vD0i5NYtuXYvUVQQMcAEKffGgKwpqXVq70uAYFavfXktNrgw81ToRgRZl8mirm0KTOKiZvdT939rPlGt8HLiqztieCMT2SnjxGyZn+lDpubxUoY5DquS47pLBZwTvpv0AevJ+F8e2glwVn/T7TF7gnVUlt2fctSKHJUjwrtGzORSmXqvHuBaXcoinIRyiNOhdqtjYBZSro+GyulMemF6eXjARmkY9BxsuzE6RMSWuwztdFalDJj/TY4IVrD4+eCa9ZUplJuCFoKqL4MmPAsOsPaMb16COHg6hbUCssNnHcXLyGHtQNcHjvfbc6v3DnKYor+3a5CF8dEt7u1kjzH/QvSvjwtvPVT7+qWPttmt4mjuexqhVZZQMZLVch1wMngVtBG69dfRL5FgdSFiUVcjoQ4UbYKnT85cGRCvSK+IHVaaRCrD2tCq78SAdoC1rTDgR7FrNkWQMtGS62jfLszfAhUSSJC/wE1Tb+q/0XZ3C3kYS3iY8DLGOOY5KYvK6zZjUsggQ== X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR08MB3919.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(376002)(346002)(136003)(366004)(396003)(39850400004)(230922051799003)(1800799009)(186009)(451199024)(64100799003)(6506007)(2616005)(36756003)(31696002)(6666004)(478600001)(26005)(86362001)(2906002)(83380400001)(53546011)(6512007)(966005)(38100700002)(6486002)(41300700001)(44832011)(5660300002)(66946007)(66556008)(66476007)(316002)(8676002)(31686004)(8936002)(43740500002)(45980500001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB9982 Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT061.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: eeeda61b-e766-4f50-c9b4-08dbcb347ae8 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5QWJsj+BCVblyCJWh8Emj/gn5B6+I10FfcSE2JFp/xUkItbOMUMa5MPnSNNcCTK7Bb3ePld5MsX07JQTELEVR6/Rh593i3x96/uRKX8KPKr1sp0j9TOfpOr3dAlP+ved7QjIjYCBmL+zVtMdDeVnzTjO8sGsjMo0yQ2TsdHaNNBpuCoEqevAWrf++BkpdxOFuus/DBVFLwEbPpKRlVukxEDI8IUL0sV+/tuJIS8E0Vd3zY7/YVDFCoVmDbmVgrgQ/G/L2nr9ufp7hFU6FnckCsy5q9E/8eAJ0B7+ZifL2ZBN+kJnFgqA1zq0r3S+xixFHbe1rxG4GpGRmXnHqpzSqkv4PPzNFcciZuF1QmOD42bvAT6DkcM3dk2liv2tSUy2wPgfTp7dyB8HKBwj6kNy9LBDtbtxu7KfiPRctzu9xR59pNqkWDPYbNetFUgd9W2yJLi/fwTMXdGtN6hKMFh9Ja8a8xT18dGt1htCLIshLuxV/HKjTIx2txy/OGV/dSr55n6pUxmbCNSOfkvaNyCZgJkixNvPwytDpjtazwJB5Trj0EmEctEJlPnD2dk5e3TXLUA/WTGqxat6WkTxvO+6p0YznhnM145dois2f5S09lkOYKaOa2Qtw0MdNAMD+ggAy07WTItnolO/l/nSGZrtS59YGiBAThOU8kZEcdZD20fZTyOq4PbiMEd1WUcXaRdSvJHcdTMrd+bHqh7pxh4ClbPR8aQw4+xHtTxXGABcF7E862tMp2Oqzx32g21eMwIS X-Forefront-Antispam-Report: CIP:63.35.35.123; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:64aa7808-outbound-1.mta.getcheckrecipient.com; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; CAT:NONE; SFS:(13230031)(4636009)(136003)(346002)(376002)(396003)(39860400002)(230922051799003)(451199024)(82310400011)(1800799009)(186009)(64100799003)(46966006)(36840700001)(40470700004)(47076005)(36860700001)(2906002)(44832011)(82740400003)(40460700003)(36756003)(86362001)(31696002)(81166007)(40480700001)(356005)(41300700001)(316002)(31686004)(53546011)(966005)(6666004)(26005)(70206006)(2616005)(6506007)(70586007)(6512007)(6486002)(8936002)(83380400001)(5660300002)(478600001)(8676002)(336012)(43740500002); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Oct 2023 15:04:15.2402 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a975e738-3d4b-418d-941a-08dbcb34803b X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: AM7EUR03FT061.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB9701 X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, FORGED_SPF_HELO, GIT_PATCH_0, KAM_DMARC_NONE, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_NONE, TXREP, UNPARSEABLE_RELAY 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 10/12/23 15: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); > > 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 I've confirmed this works as intended on a SVE-enabled target with multiple threads. Reviewed-by: Luis Machado Tested-by: Luis Machado