From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01on2083.outbound.protection.outlook.com [40.107.14.83]) by sourceware.org (Postfix) with ESMTPS id D565B3858CD1 for ; Mon, 31 Jul 2023 12:27:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D565B3858CD1 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=qJ8f9urf4A8Az+7MRJlwYia8cqUvic00WJnQEmVeL2E=; b=I+sdPJ4y9Xm22wudMbM+KwS8mEJmqTCu+Ew+LHIoW3rHS9yUOppIejTOHFbanZnr5l7g2YPqmFJpQQnQWgw1qrubAPCH8DGNAD5h0gcYCj8758pL+hhQTLFQ4R1KWWoI4Fn6rrP8Arxn3uxFxb0ALbYfEdjAColaUb4drqc7Sd8= Received: from AM6P194CA0089.EURP194.PROD.OUTLOOK.COM (2603:10a6:209:8f::30) by AS8PR08MB8252.eurprd08.prod.outlook.com (2603:10a6:20b:53c::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6631.42; Mon, 31 Jul 2023 12:27:43 +0000 Received: from AM7EUR03FT037.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:8f:cafe::eb) by AM6P194CA0089.outlook.office365.com (2603:10a6:209:8f::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6631.43 via Frontend Transport; Mon, 31 Jul 2023 12:27:43 +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 AM7EUR03FT037.mail.protection.outlook.com (100.127.140.225) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6631.44 via Frontend Transport; Mon, 31 Jul 2023 12:27:43 +0000 Received: ("Tessian outbound ba2f3d95109c:v145"); Mon, 31 Jul 2023 12:27:43 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 0c60952450dc9048 X-CR-MTA-TID: 64aa7808 Received: from e24dc30fb7bf.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 36F64AB5-8C7A-442C-8105-16CB37CBBBD4.1; Mon, 31 Jul 2023 12:27:36 +0000 Received: from EUR03-DBA-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id e24dc30fb7bf.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 31 Jul 2023 12:27:36 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DQ2L5VN5NqKVrG5I70dzNch8ehqyXVzkMmwZoA+8Kddqo5VilXe+DTRH4BQZXKHMl0AUci/xBiovZuBHIj+OWIWm1KvwTExWeVvTfasSug+GnKszhwdirPytJDwfbbmdPSZMXvsY7M1FzPwjJ6nr3hFkauM4wKQQgusnVBmRpKP7n1eJXlQws1Cjiu0s4DeS3u+A67B1q4Q6ey6bkG3bLhBzYGzxIW8BN8L7RLUMYppYpG+/dP7J1zFi/VQlbxJVgqTuGwxz1QN+drEQkzMYH3M7cVi4WW6WAkHnXQXDlcHpLdWwCEhNZLTJmefkft+RsoPBN8TJhHaEBCKnFkvWUA== 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=qJ8f9urf4A8Az+7MRJlwYia8cqUvic00WJnQEmVeL2E=; b=Kgg1G9OQP5/7dFvxvRuaROwsSZb1/XfYoj13qWBkH2jibnsTl5Xo3WD1ARViO7AJ5SDhX+WTY5EIW5xNh9b72xvC+a+9sqcD7chCVBTOgyl0yThz17GYUDhJgCuMjfKioAxiViJsdECTpJwVeN9j8f2Xlqmg1kjzFUQZ/+k6B6p6Z4/LnKvULG68fxxFuDHqjoiRbCwcjS1KLFl9TT9hZ7IzQikrmXlafDI9SujkRZX/NZV5TyRiTHxsJni3Szkz8uGR3EheHL8DzFsB+00xI/971qqFalK3SDFgJD5mb9Cf4zB05Zr+KhZ2A8mG+W8YMyz94peCgYRMIl261dwprQ== 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=qJ8f9urf4A8Az+7MRJlwYia8cqUvic00WJnQEmVeL2E=; b=I+sdPJ4y9Xm22wudMbM+KwS8mEJmqTCu+Ew+LHIoW3rHS9yUOppIejTOHFbanZnr5l7g2YPqmFJpQQnQWgw1qrubAPCH8DGNAD5h0gcYCj8758pL+hhQTLFQ4R1KWWoI4Fn6rrP8Arxn3uxFxb0ALbYfEdjAColaUb4drqc7Sd8= 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 DU0PR08MB8884.eurprd08.prod.outlook.com (2603:10a6:10:47f::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6631.42; Mon, 31 Jul 2023 12:27:33 +0000 Received: from VI1PR08MB3919.eurprd08.prod.outlook.com ([fe80::d216:34d8:ae2a:fe17]) by VI1PR08MB3919.eurprd08.prod.outlook.com ([fe80::d216:34d8:ae2a:fe17%4]) with mapi id 15.20.6631.043; Mon, 31 Jul 2023 12:27:33 +0000 Message-ID: <4e1bca4d-83b4-0db5-170f-a9a6ee08fe23@arm.com> Date: Mon, 31 Jul 2023 13:27:27 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH v3 10/16] [gdb/aarch64] sme: Fixup sigframe gdbarch when vg/svg changes Content-Language: en-US To: Thiago Jung Bauermann Cc: gdb-patches@sourceware.org References: <20230630134616.1238105-1-luis.machado@arm.com> <20230630134616.1238105-11-luis.machado@arm.com> <87jzuk7sst.fsf@linaro.org> From: Luis Machado In-Reply-To: <87jzuk7sst.fsf@linaro.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-ClientProxiedBy: SN4PR0501CA0110.namprd05.prod.outlook.com (2603:10b6:803:42::27) To VI1PR08MB3919.eurprd08.prod.outlook.com (2603:10a6:803:c4::31) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: VI1PR08MB3919:EE_|DU0PR08MB8884:EE_|AM7EUR03FT037:EE_|AS8PR08MB8252:EE_ X-MS-Office365-Filtering-Correlation-Id: 711578da-5eb2-4def-3221-08db91c18a20 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: iuGd+QgXKLKzC2SVnylpTr36xZylGmbTqRTKd4Bpb5l1gYmSyPZoex18HEO4YKzDtC5VS2OcOfklY7F/g7O1TiKmq/KaktFtuhRZySiN7er3MzBHz8RHsjCh91bLFpxMaGTRB8vJP+6FU6gSm8R0RgPH+U7GS+UHBP9Gke8QhDcb6MHN5WNf/0Qs265ehm14XVe6PMjSQK+8IhNngvS2LmOCOG5BPdHgTbWcl40ZUMAuuVq/MIwLMorJ5s1X6iJRMHNw7JbSf8+2Q5QYYDHwzbmySGTly/EGE+LfSTRPbHGoIzCDx82jjXZbJuC1ZSqHZw6nVCtUoP7cB11Jw2NEPIJZ4higMTaBrzyKvvuHL48vprC9PHkkB0zcYDG4gl0UX+V2xjRQbUi9mJp8kq7tqZWnyODObJj02VVPSt/vFp1MaDakR6Ww9iz9ptKgQaQG/ZTrzOII3WgQjrM9dxNNBZvQ1DUhdEMnrOt4m7nmLibtMdwuHTZ/q4YMYEiBaFGQ6d6Etw7xG2VxaCQrpwSK6DaqvlU2SMvnsjkYJxe5u4P6sVJD3JtMaTwI5zxszHRsoaEVPXT/ftq3vgN+COQDgP8DINqiAmI8u/uBaMstbocrTLQI7V5VGxFVDfqBD/fflEQmNp1L3nSLuF+jk19DCw== 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:(13230028)(4636009)(346002)(366004)(136003)(39860400002)(396003)(376002)(451199021)(31686004)(2616005)(5660300002)(38100700002)(36756003)(2906002)(26005)(44832011)(83380400001)(316002)(478600001)(186003)(8676002)(6506007)(53546011)(8936002)(6512007)(41300700001)(6666004)(6486002)(86362001)(31696002)(6916009)(66946007)(66556008)(4326008)(66476007)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB8884 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: AM7EUR03FT037.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 71b045d3-2d2a-4a61-3d9d-08db91c183ff X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: cx2a0lqKQTPK9VOrRt5Ta5pi5rvIGP1WtNQ0Qa4vLd5Rk97CgEr9drsNSwNfXy8zMq5nAxcr6LtDpxDBUFT4gHr7WJ5ZjHGUVQuuUiYVvghLyjeRrCgMZnVhDp27tOmyfVHe9sbbIsMF2HxDQg6mXNzDC/nxXz3pbfIVjKUcUWlX4YMk8vtGpp4qpQwqtEnBqeau52kbj760IWipNJ2p0vz2+fD6NrjV+qt32CvNq7tJsDQ7EBChQY4V3TR7OJl/IIRYeyPUP1cT66RgsW09OQCQo7NrAFIj1CNkVvyny91LXau2TkgUQVlo0WmFlzR8oUkVocG7vBg5fi9KtnAWMdQtFnFcJsjISkRwt0xUmG+Rdh1WAMXNxPinp/AkX4NRPyh3KKrx4MZzxr9oc02Pgh0bwXoz/jXwk8iWHGgqTUQIC/XpOB3YhGJiZhSSEB+YrKJ+z2LP6rPHu5QNRn5q50cvJZA/TLRtvCIq1Rm1RPBG+1yJ7X8pB2mc1fWj5vHCrRpRQq6TyNwB24HWm9sPn7XR7eniduG1elWbGvajnNsqbCBhtEGbuo+CKERVOyAfz3+o19kQ3PzC8guLgDDWqP+7h5p9WueSJxIpDlq1tWE/4KwknJfYue/Ywy7nHTivYQF6YHlNo2u3zk4DD5LAG/OXYbiu/KPTRKIPR176hKAxYiK5PbeEVe8H8WGSHuXtwZihNnMHanZBNj44n8joeKW2gjcAXXkt1RlVqdqW/HA1axOMfVLimH8f5HJL+AB9n04GiQ0FytCLfH0ZP3IEQA== 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:(13230028)(4636009)(396003)(376002)(346002)(39860400002)(136003)(451199021)(82310400008)(36840700001)(46966006)(40470700004)(31696002)(86362001)(31686004)(8676002)(6862004)(8936002)(316002)(4326008)(5660300002)(356005)(41300700001)(81166007)(70206006)(70586007)(82740400003)(478600001)(2906002)(6666004)(44832011)(36756003)(47076005)(36860700001)(6512007)(6486002)(6506007)(26005)(83380400001)(186003)(336012)(40480700001)(40460700003)(53546011)(2616005)(43740500002);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Jul 2023 12:27:43.4669 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 711578da-5eb2-4def-3221-08db91c18a20 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: AM7EUR03FT037.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB8252 X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,FORGED_SPF_HELO,GIT_PATCH_0,KAM_DMARC_NONE,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE,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 List-Id: On 7/28/23 02:01, Thiago Jung Bauermann wrote: > > Luis Machado via Gdb-patches writes: > >> case AARCH64_SVE_MAGIC: >> { >> /* Check if the section is followed by a full SVE dump, and set >> sve_regs if it is. */ >> gdb_byte buf[4]; >> - uint16_t flags; >> - >> - if (!tdep->has_sve ()) >> - break; >> >> + /* Extract the vector length. */ >> if (target_read_memory (section + AARCH64_SVE_CONTEXT_VL_OFFSET, >> buf, 2) != 0) >> { >> + warning (_("Failed to read the vector length from the SVE " >> + " signal frame context.")); > > Extraneous space between "SVE" and "signal". > Fixed. >> section += size; >> break; >> } > >> case AARCH64_ZA_MAGIC: >> { >> - if (!tdep->has_sme ()) >> - { >> - section += size; >> - break; >> - } >> - >> /* Check if the section is followed by a full ZA dump, and set >> za_state if it is. */ >> gdb_byte buf[2]; >> >> + /* Extract the streaming vector length. */ >> if (target_read_memory (section + AARCH64_SVE_CONTEXT_VL_OFFSET, > > Same comment from the previous patch about using the SME macro instead > of the SVE one. > >> buf, 2) != 0) >> { >> + warning (_("Failed to read the streaming vector length from " >> + " ZA signal frame context.")); > > Extraneous space between "SVE" and "signal". > Fixed. >> section += size; >> break; >> } > >> @@ -477,11 +499,49 @@ aarch64_linux_sigframe_init (const struct tramp_frame *self, >> if (!extra_found && section > section_end) >> break; >> } >> +} >> + >> +/* Implement the "init" method of struct tramp_frame. */ >> + >> +static void >> +aarch64_linux_sigframe_init (const struct tramp_frame *self, >> + frame_info_ptr this_frame, >> + struct trad_frame_cache *this_cache, >> + CORE_ADDR func) >> +{ >> + /* Read the signal context information. */ >> + struct aarch64_linux_sigframe signal_frame; >> + aarch64_linux_read_signal_frame_info (this_frame, signal_frame); >> + >> + /* Now we have all the data required to restore the registers from the >> + signal frame. */ >> + >> + /* Restore the general purpose registers. */ >> + CORE_ADDR offset >> + = signal_frame.sigcontext_address + AARCH64_SIGCONTEXT_XO_OFFSET; > > You can simplify the above to > > CORE_ADDR offset = signal_frame.gpr_section; > Yep. Agreed. Changed it now. >> + for (int i = 0; i < 31; i++) >> + { >> + trad_frame_set_reg_addr (this_cache, AARCH64_X0_REGNUM + i, offset); >> + offset += AARCH64_SIGCONTEXT_REG_SIZE; >> + } >> + trad_frame_set_reg_addr (this_cache, AARCH64_SP_REGNUM, offset); >> + offset += AARCH64_SIGCONTEXT_REG_SIZE; >> + trad_frame_set_reg_addr (this_cache, AARCH64_PC_REGNUM, offset); > >> diff --git a/gdb/tramp-frame.h b/gdb/tramp-frame.h >> index fa0241acb2d..563c34ae595 100644 >> --- a/gdb/tramp-frame.h >> +++ b/gdb/tramp-frame.h >> @@ -42,6 +42,13 @@ struct trad_frame_cache; >> instruction sequence. */ >> #define TRAMP_SENTINEL_INSN ULONGEST_MAX >> >> +/* Assuming the frame chain: (outer) prev <-> this <-> next (inner); >> + use THIS frame, and implicitly the NEXT frame's register unwind >> + method, return PREV frame's architecture. */ > > Maybe s/return/to return/ ? > Yes, "to return" is what I had in mind. >> + >> +typedef struct gdbarch *(frame_prev_arch_ftype) (frame_info_ptr this_frame, >> + void **this_prologue_cache); >> + >> struct tramp_frame >> { >> /* The trampoline's type, some a signal trampolines, some are normal >> @@ -75,6 +82,11 @@ struct tramp_frame >> int (*validate) (const struct tramp_frame *self, >> frame_info_ptr this_frame, >> CORE_ADDR *pc); >> + >> + /* Given the current frame in THIS_FRAME and a frame cache in FRAME_CACHE, >> + return the architecture of the previous frame. */ >> + struct gdbarch *(*prev_arch) (frame_info_ptr this_frame, >> + void **frame_cache); > > Shouldn't the typedef defined above be used here? > Yep. Change it to use the typedef now. >> }; > Thanks!