From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-eopbgr130084.outbound.protection.outlook.com [40.107.13.84]) by sourceware.org (Postfix) with ESMTPS id 7CC9C3857BB5 for ; Thu, 13 Oct 2022 09:46:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7CC9C3857BB5 ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=odWckOYuff7Y1ZNxIskZt9PTbtGUbQRr7CNguHM7HRJUcficvxjZaq2Ma8xYXOG3VmMeTRYKlDWzY8979RgH4Fm/FrSps+xvIRAMBIEsMmaVk3beYDpKmMPkw1Qn9kPpgGMyP4HXF5gMkH2dks16mXSocAr8QUND7P2Ft4YGGBJHbdaLE1DzzSyhrrAVUUvdUCbH3O+DglbFQoaKC8mLnglz1slOJ6XredbKdxDGrkO24DQfUnyG6c20EBI8xfA46L/6nrtn0IAlvaGgk5OW8ppdZn2OM7sTVBfNURTgzNfDD9jsD9xH01ts+W8ldmPsFwd7ZhI8ql7R/9w7YS0b1w== 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=LemhEmAifZCYYtrQze49Of3t8pqOZY9r96nsjoGI9eg=; b=Lh+IEIHnw9WmLdRQES5xFVisbtvgNtP759VNySc5mgQKKb62Ya5bUlGVce35VkThBuDkkNBnL+PMCLt9KIavwAhVch++FTTRr02G5wJhFk5ReOaYXiO7c2C8qxh72eA0wTo3ST8MbO9L/tzbuo6Juy1zBayln7UEMoYCcg/NE0VDhc5yfEI+uU1sdNE7b2cfUAzrARQchsTrvXfeNiA4kjrsokU0vDYFiU3qc2uKuecXea7en+N7iKg9xBIUXA6ugf36qIlUheNV2XnsNQhMCscp0aKJS/n2KJle3UMrZOzvJb1iThfPtkvwozZZ1ciwsJ+uOcpj0GIShIeY+DxgbA== 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 DB6PR0802CA0037.eurprd08.prod.outlook.com (2603:10a6:4:a3::23) by AM9PR08MB6098.eurprd08.prod.outlook.com (2603:10a6:20b:2d9::12) 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 09:46:30 +0000 Received: from DBAEUR03FT050.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:a3:cafe::63) by DB6PR0802CA0037.outlook.office365.com (2603:10a6:4:a3::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5709.22 via Frontend Transport; Thu, 13 Oct 2022 09:46:30 +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 DBAEUR03FT050.mail.protection.outlook.com (100.127.142.250) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.20 via Frontend Transport; Thu, 13 Oct 2022 09:46:30 +0000 Received: ("Tessian outbound 937eed45f6ed:v128"); Thu, 13 Oct 2022 09:46:30 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 4138e27c025adb06 X-CR-MTA-TID: 64aa7808 Received: from eb883134dbac.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 31BDBC34-563E-4ECC-8D6C-C45CDABAA2BC.1; Thu, 13 Oct 2022 09:46:23 +0000 Received: from EUR04-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id eb883134dbac.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 13 Oct 2022 09:46:23 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RgMnJyvFj2uyKBAjhuWjvwhN836tEfBtzHxCLjelYfEPP6dXLW5UGzJOOvZTko7wc1qFrdjWTrKhCWT+rXoCFoeY+7CchlE34zbBZW3TFXPcet+fYZTQX7hwx2F0tSVj2cpwmbGW6c+aRBapImOCh1qHhM9m61Tu4vIs7vEUep+pIAeHdhlbDDiQgXbyajxAHHQSZgwoumwT5sbsoU2jqc6obQSFX9UPt5574w+44At30LzcseDQWxFtj6uxUlXw0ykVMZj8kAgEU8Xt/d3rBOCXEl9LZRKwK+qIUI7AFAfwJRWS5MDLVfVRklJb8DM60N4O6sAJd4CHB+AL12v7ZA== 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=LemhEmAifZCYYtrQze49Of3t8pqOZY9r96nsjoGI9eg=; b=hCsCkK8mXfBM1F/BRkIgSQmvZX7RGT1mu7HJ5u6rLGxxr4Ua1fJkWqSoq8T3F9mBbPQP/BqXbB2/N+KffC3CAzdCoLBCrMveD4QIbjvqKzH9dYeKhz6m7DKIgVkF+uptibo7+zBmj9Wa33uXKk8RtrBACgt7EFvry5n9tgcSU1lRprpptQPfpGucC0LA+MBbQAPvsvuK9KlwkYgjWx5nGIOtSfD7q1hjKZQL+FI1bgvnL6h7VBVhrhiFpHlQ+/tQ3j1u2e+gIVE8TBYLQSPmHbJoXel6HTX3Issh16DER4qkVqTnP147qzFOB67n3BHYgiwgaJRNHRUOgsheFCrjUw== 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 AS8PR08MB6470.eurprd08.prod.outlook.com (2603:10a6:20b:33a::8) 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 09:46:18 +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 09:46:17 +0000 Message-ID: Date: Thu, 13 Oct 2022 10:46:10 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH v2] 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: <20221013091740.645783-1-torbjorn.svensson@foss.st.com> From: Luis Machado In-Reply-To: <20221013091740.645783-1-torbjorn.svensson@foss.st.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: SA9PR13CA0136.namprd13.prod.outlook.com (2603:10b6:806:27::21) To VI1PR08MB3919.eurprd08.prod.outlook.com (2603:10a6:803:c4::31) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: VI1PR08MB3919:EE_|AS8PR08MB6470:EE_|DBAEUR03FT050:EE_|AM9PR08MB6098:EE_ X-MS-Office365-Filtering-Correlation-Id: fc8b7430-f7cd-458f-cd57-08daacffce43 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: jBG+6B7c733VrjQe/YKcZgAuEeNkcDCDxEG7fotp4Qmn5y69Vr+A3WSUI/VCXHSm5x900ELQaekK+bZa0Zf9zvMWz45bIQMU0s1YxyNIJrev6zfA+q0Lv9moh4m3iA6+RWKEqR87HahtJfjKZ3+vMouzId9uHp/xh8aSaOH+FAx1ZBicGAtrkl02ozWjNLozM8lDzIqE1cONS8WZET+qSLm6ZA1BlGbITy1wXNdP1bsq/R7814SgkLcJjYFMKtJuM9hqcvr00J5bQ5RrGgq6J/R2Xm56qY2uAlH1nITA98xIGQ+Wm2LDHoDWbp7m6Ia5214LthTlceSjwALgsiXep4jbPNgvJnyaMv20j27SrGKmCYFTZ1llMx4LmouqIbMgOqSfh5fmn9dY7PQWbR+2TbHIyihSemlukcFE0PCdYp4WEcwI4IfNArI0STNSMFIH6lHwREHs4cf/dWdwEq6SqF4zLYaXP/+iJmj2cb7ubvVZ2ob5f4sofbb7+ZtXn9Hq4SgqwIFNSwtmoydZW88WpyfOOmiRTN9Rk1c15LwyfpHcrStzkLzVe7nrITFl6ZjAwHkJGWBat2KAJN0+2eErJkBz0THwjR42dErpM5Gs7QOwQo7XR+vtOQAsuDwNT2lZHshlOhYrJbez91APPQ93I1ZVrq8bMFxib+QDzZWzk5dSXJnbtZkpraQJSjdb4Oo0cqCvCc96Cs0lAOXcKdyxoYs4hb8dkWO3m8FNkINHh9MY3oc/iFXvnHYvLjDlUDownZQXIhcId6kjpFkMrc662QMIMjZA5v4LOeiMKOQjnSE= 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)(346002)(136003)(39860400002)(376002)(366004)(396003)(451199015)(31686004)(36756003)(6506007)(53546011)(2616005)(41300700001)(26005)(6512007)(478600001)(66476007)(66556008)(8676002)(4326008)(38100700002)(86362001)(31696002)(66946007)(8936002)(6486002)(5660300002)(186003)(83380400001)(44832011)(66574015)(316002)(6666004)(2906002)(45980500001)(43740500002); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6470 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: DBAEUR03FT050.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: deb37c21-d852-4cce-ed0c-08daacffc641 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: HxlA1SLlLSuICJKcwZcbIq1ggmNHbJsS7ELFUoc45MN5L9O0UxAUucZeII60WWdo6TjOA8MiqPLYiMV+vMWIh/c4HUT8S7r5WhnMkIyxFf2Vvj8Rmv7fJkuSM4rKX8wuNTSYEfNKwwb1JkqUvWTrSEtMtNe+IBy4lpXrpWrLkZl6o1+8fQat9mAB10/zRdzJMzG3lFWcMekSwhWd0EBZAuOsbCfBs8XcEOhsguJCBc3MoBNJAIGkq1HsJr1GENZeFAhmxYNw/YrCsg9svVjZT6VsRtkr3PlK0sN8pSQDSPOB1CaZZbn9oFDPPDBWJcPtnp55RaiyEGA+AxwJi+phAKsUxa9VLSHIRfxxOW2ri3ZeCtCah2AstMG+vkzS7w7EYTPVz+IRGno5dA5PI2ZV9EKAyHOQzW3cK3qFilm6lrOtN9KFI0La+9s5wL5ymee0SmyfYLtnWekbSlRg0fsTnNZkFFdgS1U6vSJz/95bQ33jS2klHWYP86siISsv4J2xzu0Dr+HH2EEZe74nze0qqMYYOVxzwDQC6+zFlVJL5HPCIGzYYj4H5++gDvKPLA/WiMKmY8WQ2+HcbhOrFrdsys+kMHX1vXaxircywdW2G9XqPrSM79FgOkkQKlUSJMH2ZD+vbXNC0sDCbS9hBn6+YYIpWm4WEEhSWYr4h5qmCS8zg46eXoL5Jbs3l9PWE83kNosA0JGHcOkjhu9Z4EEj1m8dP9vJDy25PmI7S5yA4UVqzqUJgaccRNfd0RtpgWmq0H7gXZ2+RFtikHwdm0bq2Qg+4SeUqFEbl6/qZyZV9ZOjE/y3FZtNs6/h1IkgG7/2 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)(396003)(346002)(136003)(376002)(451199015)(46966006)(36840700001)(40470700004)(5660300002)(336012)(186003)(44832011)(2906002)(2616005)(6506007)(41300700001)(53546011)(6512007)(26005)(8936002)(81166007)(356005)(82310400005)(82740400003)(40480700001)(86362001)(31696002)(40460700003)(36756003)(83380400001)(66574015)(47076005)(36860700001)(316002)(478600001)(31686004)(8676002)(4326008)(70586007)(70206006)(6666004)(6486002)(43740500002); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Oct 2022 09:46:30.3534 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fc8b7430-f7cd-458f-cd57-08daacffce43 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: DBAEUR03FT050.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR08MB6098 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, 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 09:46:40 -0000 Hi, On 10/13/22 10:17, 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. > > Without this patch, gdb would assert if this errornous state was > detected. > Could you please attach an example of the change in the commit message? What it does before and after the change? > 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..afcbce478c2 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.")); > + return NULL; NULL -> nullptr everywhere. > + } > > /* 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.")); > + return NULL; > + } > + > 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 > + unwinding. */ > + if (cache == NULL) > + { > + *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 != NULL); > + It does seem safe to assume this function won't be called if there is no frame_id. So I agree this would be a GDB bug and needs an assertion here. > /* The value was already reconstructed into PREV_SP. */ > arm_gdbarch_tdep *tdep > = gdbarch_tdep (get_frame_arch (this_frame));