From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02on2076.outbound.protection.outlook.com [40.107.247.76]) by sourceware.org (Postfix) with ESMTPS id 183593858404 for ; Thu, 13 Oct 2022 11:22:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 183593858404 ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=Bbi6wALz8rFm/wuEUg9YQNJ7F+lYt9Zr/4E6mmG+VyjCWNRVi2EvL2fqBqvPEVSMRdZpoQl6egVPXnDhexfrZBtSD2aAuMb/0zUhPMJvId4sKOPfx1olb3sFik/Ryv/v56wIkNGnfARasCX8TlKWo1Oc9UHjB3wlf21qNCcmEAvwlx+S2uWrHc3xG1uk3b4xkFAm1NqYGhShwp8KSo3Ra05H8YpbO8rM6LH+OfmC7a38hv8srQNDQOFszS9upoezoJCS0GqnZwLk6gUQREToVygntvJ3g2/Z87y1f9gnFY4DX3UYIc8jvzbM6FPvXzBmdcm2001mGJ5k5lWiNEUzaQ== ARC-Message-Signature: i=2; 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=eF3Ju2oNeev+ZgZHH87A7HBQkIwX06S/jVOQsF7iluM=; b=Z3jEznSS164jaFOt0OHz09cTTrRHHkMEV/mL3jKHGriZhc0Oz/OvdpU9qiO0UK5Qub6adc94/7d5byOXATuK4LiOOp7UZ30sT0pfq2RdH9Wl/dgC21RH8FUYqTxbxMMZ97y8VxFiniDt5JXnKSlh+wlLOHLUFIYpced7EdNbLljcFFQm90ibEm0/UUW1NqQdU+/vf1g1pSneigdg5+NPkx4Q3oopeMKtcu5hrfFsqskXouS+6hpdzHtBt62Aq73slGNOBcjLbA1wZTc/ZQLCX73wUC+pl12+kj1IXDcJmXO9taigqDULjsWEeDyV6KZq+5zfld2rLi4lkhd2P27vxQ== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=sourceware.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com]) Received: from AM6PR08CA0037.eurprd08.prod.outlook.com (2603:10a6:20b:c0::25) by AS8PR08MB6374.eurprd08.prod.outlook.com (2603:10a6:20b:338::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5709.21; Thu, 13 Oct 2022 11:22:29 +0000 Received: from AM7EUR03FT022.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:c0:cafe::de) by AM6PR08CA0037.outlook.office365.com (2603:10a6:20b:c0::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.26 via Frontend Transport; Thu, 13 Oct 2022 11:22:29 +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 AM7EUR03FT022.mail.protection.outlook.com (100.127.140.217) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5709.10 via Frontend Transport; Thu, 13 Oct 2022 11:22:29 +0000 Received: ("Tessian outbound d354c7aef2bc:v128"); Thu, 13 Oct 2022 11:22:29 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 148915c30476eaff X-CR-MTA-TID: 64aa7808 Received: from 1e148910f89a.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 4FC72E19-CC2B-46FE-B22B-76142A5F2024.1; Thu, 13 Oct 2022 11:22:22 +0000 Received: from EUR03-AM7-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 1e148910f89a.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 13 Oct 2022 11:22:22 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RKBk+MEZV5MgWQmeMS+VibWMHZgKybTzsmuyRqxjiENPMXWfvDcbKCuW8jrHWsRZoaTukfj7ipAOXrcbYaE1QaPnhfPcdfKZLzg0rEqeewGBt4JwBxuMLlaXFE2BZ332C1FdBtGWX51+RKK/thFhmpI09RVmMW6e2paoPI1IJoWaCClv09LB+/ymezt1Dvegkt6TPCoCZQj5Ki3F8r5kPbz8/FRmLzs38vWjrjgGUPY1E66qEzitl9wbFKf1RFNVjTryDKhQrMqwb5zFOHv3l8hJIe7jlqLjuoMNDtKLgqnRJhu+VAEzcGPo9I5/GqgcjmKKuH6s6NH5T/iHU4wSfQ== 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=eF3Ju2oNeev+ZgZHH87A7HBQkIwX06S/jVOQsF7iluM=; b=B5ioyCAi0+6hRMvO3RhJhov1HWXKHZAbro6mZkPm/AbM+Wq1i1YtfpsXh4x4gk82aIBmsl7BX82kvFKITrVX88skCM6YfHB+RPWMpkQq4BXw6KXSQzTIfMFX+bZjuQ/CxexIQsxlAj4q2xFfY0a753DJG6nSd7SNSpd2Bc5Wjswpsw7TQ7jv1S4PK2wpm/JCc/nOok1an3DBu+2XYTml4GlhZQIi8Fy1H2J6bCXW575k2vqlFb851duzGpwcD+fY0aR1W3AhYLtnXWiPpfbsgbmKAwIZbl/RcwyGeWHtkCnnFfTzwCzx2ZE8GYyteH0bEjXKmVxQBqsmEZB4kGlAHQ== 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 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 DB8PR08MB5369.eurprd08.prod.outlook.com (2603:10a6:10:11c::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.26; Thu, 13 Oct 2022 11:22:20 +0000 Received: from VI1PR08MB3919.eurprd08.prod.outlook.com ([fe80::bbeb:a49e:d969:5d2]) by VI1PR08MB3919.eurprd08.prod.outlook.com ([fe80::bbeb:a49e:d969:5d2%6]) with mapi id 15.20.5709.021; Thu, 13 Oct 2022 11:22:19 +0000 Message-ID: <03f076b5-1555-e982-f782-a6af3e085968@arm.com> Date: Thu, 13 Oct 2022 12:22:17 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH v3] gdb/arm: Stop unwinding on error, but do not assert Content-Language: en-US To: =?UTF-8?Q?Torbj=c3=b6rn_SVENSSON?= , gdb-patches@sourceware.org References: <20221013105305.657219-1-torbjorn.svensson@foss.st.com> From: Luis Machado In-Reply-To: <20221013105305.657219-1-torbjorn.svensson@foss.st.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: LO4P123CA0562.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:33b::12) To VI1PR08MB3919.eurprd08.prod.outlook.com (2603:10a6:803:c4::31) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: VI1PR08MB3919:EE_|DB8PR08MB5369:EE_|AM7EUR03FT022:EE_|AS8PR08MB6374:EE_ X-MS-Office365-Filtering-Correlation-Id: 96482794-e3ef-4f63-03f3-08daad0d36cb 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: pcAB1+oCng+Q183ZCo+HN29r1c08dGpCvRHMlUAZ8bQ3c6sc2sNDZbCTTL3uWkJrky+YBY3MKA9v53wg8enOHHUqsw0mIygJTs/MuJlcS11D8JC7y9jUBmQ45xSQORREQtPhmbD2g0R47XTN8SIpG9r0+AZrZSJrTOTbvjQNrkx1nfTO60/ajv5PyBZ3TYdtIRywSWMFtlI+F118xUnIkVfSuJ9gTTFEAwzngpTMKhY5Qy1dfiogVdjHBMbIUcKGE1/RdlEoaY3ly5jiMzLboiJUgCbIVIxlQ5Gg+Y2ABEV3Q1PXQzO1toO1qv3yOvvUANFML35BklfiIMyjg+hdQ30wNwmahQ/iM1andqwV+Fwy16kg0RE+cIXOTcuBpdUyRcRLDq8wo/A60EyYioUOZPiZ+FLsM+gF1o8lLTQOBE/N1mFQnh0PVTKVoKFfMmDwxjDfhwNTo5+0ARa6IVrEyVJqmC/ELRULtINde7Hqn6JpKPEWWKfitjB4k9SoQqS0ylIIt3r0S7iJOINdE2NXVDbLnBJcvU2x9tq9nOomzC3/flv8sfsE4yZQxqpVFyI+Em0q++07W3D9PWt7wr8aGk9GWd8+WRnbih98YxjsEV5Uqj5glvJRi38bjS68nOvgg15vH4OKjDrj0/4RjhtPnFH4sRq9oWqJi4wwgGcxylB/nDtPTnEU0e1OTNgR/Pjy+H4JwXsWlD+ZDCnO4U56o2C8f416pVKjQqkSUK7lpegANfpji9jIbaLYYx35xdeNYnTda9Y5WP9eOZUmRtnn/38g10lYHsLfSxIDJKp1JzFaNS80HYqQUXrISDl2nzty 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:(13230022)(4636009)(366004)(376002)(39860400002)(396003)(346002)(136003)(451199015)(36756003)(31686004)(86362001)(31696002)(44832011)(38100700002)(2906002)(5660300002)(66574015)(186003)(2616005)(83380400001)(6486002)(6506007)(26005)(53546011)(478600001)(6512007)(66556008)(66476007)(316002)(66946007)(41300700001)(4326008)(8936002)(8676002)(43740500002)(45980500001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR08MB5369 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: AM7EUR03FT022.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 7e747194-e8f6-4319-baf0-08daad0d3105 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gjzAYj1/TGJNa/aLCdiLyAuLZNT6w/kjTvq3cEcpSYhUVicFlCy+KkXk5XypAOXcFcPt6qkQb/KIOYU0UF+IpGyNu49gIhSG+Po4EY4JAafISx9BkEDTRHJ/ipH4+d0n9z00JLFshcJlmIMHzbVz7/wrcg4u2qB6ncCa9IB8vubsP8cVOLYA/1k565s14S6dTgMoye4ouR0g2lwjWVVKnKyHlR1twNPrWMBjIo6imdUsULDB+7SSC7AkAyVTQaUgqpS7EhwU49isA3irhuK7S4lyGUw2Yx4WUIrQ4J3dFXxib3PWkdrbDHdrxGXalXKOe4MOIX8uuYk5eaTCqLfU9kKSqjWn8e3pe7fyVfxM029h47Z586TULdEQT6au89+3TkRdIg47ne5Q4ke5btyqqtJPjRyqXfw8VInJWe+l+2AaDJg+r/nf2A4+AogydszWhrNvRAuhlQFB1VqoWN4FrsbY4qV2MQkGEyG64t1y7yeX1Pm/fIu7OHHyKlYUtT9oUU5BbmLVvrCih14p625Ezx/Fe7BPyiB9F1SHHnYpBfYOTLwn4svBPohlmeuH58u/+NNOIf3nPO0FbUOJuAOm5Dyyb4ih24dE+Ci7RCCvSAsc6yNdxY2VdYJSjXNUVZwOnFOy6pTs/caANzGgCucVuTR9yWATpORcRxFiamTS7D1VT5Mcakhb8njSwYs1K4zWWbJ9lyNAUKyQ1NeJyk3A5aDfzGO1zNYLS/KP0YLFjJQ36tIQojPxpcJrwcWdcJXZHWGcprPzLrg5Latimcb9NbD0Cc5Bkf4WDc6Psk8b/TPtM/ffqiiyFIe50fPZzo5izjgPhKIGIBftb76AddUhPw== 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:(13230022)(4636009)(39860400002)(346002)(376002)(136003)(396003)(451199015)(46966006)(40470700004)(36840700001)(36860700001)(316002)(2616005)(83380400001)(81166007)(356005)(86362001)(66574015)(47076005)(82740400003)(82310400005)(31696002)(44832011)(70206006)(8676002)(6512007)(41300700001)(70586007)(8936002)(4326008)(5660300002)(53546011)(40460700003)(6506007)(40480700001)(186003)(26005)(2906002)(6486002)(478600001)(36756003)(336012)(31686004)(43740500002); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Oct 2022 11:22:29.1332 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 96482794-e3ef-4f63-03f3-08daad0d36cb 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: AM7EUR03FT022.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6374 X-Spam-Status: No, score=-13.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, FORGED_SPF_HELO, GIT_PATCH_0, KAM_DMARC_NONE, KAM_SHORT, NICE_REPLY_A, 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.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2022 11:22:44 -0000 Just one nit... On 10/13/22 11:53, Torbjörn SVENSSON wrote: > When it's impossible to read the FPCCR and XPSR, the unwinding is > unpredictable as the it's not possible to determine the correct > frame size or padding. > The only sane thing to do in this condition is to stop the unwinding. > > Example session wihtout this patch: > > (gdb) bt > #0 SVC_Handler () at .../GPIO/GPIO_EXTI/Src/stm32f4xx_it.c:112 > .../gdb/arm-tdep.c:3594: internal-error: arm_m_exception_cache: Assertion `safe_read_memory_unsigned_integer (FPCCR, ARM_INT_REGISTER_SIZE, byte_order, &fpccr)' failed. > A problem internal to GDB has been detected, > further debugging may prove unreliable. > ----- Backtrace ----- > 0x5583bfb2a157 gdb_internal_backtrace_1 > ... > --------------------- > > This is a bug, please report it. For instructions, see: > . > > Aborted (core dumped) > > Example session with this patch: > > (gdb) bt > #0 SVC_Handler () at .../GPIO/GPIO_EXTI/Src/stm32f4xx_it.c:112 > warning: Could not fetch required FPCCR content. Further unwind is impossible. > #1 > (gdb) > > Signed-off-by: Torbjörn SVENSSON > --- > gdb/arm-tdep.c | 35 +++++++++++++++++++++++++++++------ > 1 file changed, 29 insertions(+), 6 deletions(-) > > diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c > index 041e6afefed..bdbff247188 100644 > --- a/gdb/arm-tdep.c > +++ b/gdb/arm-tdep.c > @@ -3591,9 +3591,13 @@ arm_m_exception_cache (frame_info_ptr this_frame) > ULONGEST fpcar; > > /* Read FPCCR register. */ > - gdb_assert (safe_read_memory_unsigned_integer (FPCCR, > - ARM_INT_REGISTER_SIZE, > - byte_order, &fpccr)); > + if (!safe_read_memory_unsigned_integer (FPCCR, ARM_INT_REGISTER_SIZE, > + byte_order, &fpccr)) > + { > + warning (_("Could not fetch required FPCCR content. Further " > + "unwind is impossible.")); unwind -> unwinding would read better. > + return nullptr; > + } > > /* Read FPCAR register. */ > if (!safe_read_memory_unsigned_integer (FPCAR, ARM_INT_REGISTER_SIZE, > @@ -3669,9 +3673,15 @@ arm_m_exception_cache (frame_info_ptr this_frame) > aligner between the top of the 32-byte stack frame and the > previous context's stack pointer. */ > ULONGEST xpsr; > - gdb_assert (safe_read_memory_unsigned_integer (cache->saved_regs[ > - ARM_PS_REGNUM].addr (), 4, > - byte_order, &xpsr)); > + if (!safe_read_memory_unsigned_integer (cache->saved_regs[ARM_PS_REGNUM] > + .addr (), ARM_INT_REGISTER_SIZE, > + byte_order, &xpsr)) > + { > + warning (_("Could not fetch required XPSR content. Further unwind " > + "is impossible.")); Same here. unwind -> unwinding. > + return nullptr; > + } > + > if (bit (xpsr, 9) != 0) > { > CORE_ADDR new_sp = arm_cache_get_prev_sp_value (cache, tdep) + 4; > @@ -3703,6 +3713,14 @@ arm_m_exception_this_id (frame_info_ptr this_frame, > *this_cache = arm_m_exception_cache (this_frame); > cache = (struct arm_prologue_cache *) *this_cache; > > + /* Unwind of this frame is not possible. Return outer_frame_id to stop the Unwind -> Unwinding. > + unwinding. */ > + if (cache == nullptr) > + { > + *this_id = outer_frame_id; > + return; > + } > + > /* Our frame ID for a stub frame is the current SP and LR. */ > arm_gdbarch_tdep *tdep > = gdbarch_tdep (get_frame_arch (this_frame)); > @@ -3725,6 +3743,11 @@ arm_m_exception_prev_register (frame_info_ptr this_frame, > *this_cache = arm_m_exception_cache (this_frame); > cache = (struct arm_prologue_cache *) *this_cache; > > + /* It's not allowed to call prev_register when this_id has returned the > + outer_frame_id. The arm_m_exception_cache function will return NULL when > + the frame cannot be properly unwinded. */ > + gdb_assert (cache != nullptr); > + > /* The value was already reconstructed into PREV_SP. */ > arm_gdbarch_tdep *tdep > = gdbarch_tdep (get_frame_arch (this_frame)); Otherwise LGTM. No need to send a v4 with these changes. Make sure you fix the commit message to mention the correct warnings. Thanks! Luis