From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-eopbgr70053.outbound.protection.outlook.com [40.107.7.53]) by sourceware.org (Postfix) with ESMTPS id 89BAE392AC05 for ; Fri, 10 Jun 2022 15:21:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 89BAE392AC05 ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=m/6bSYVcR2KiIMMPUQa4TKGRtM5/tGU1CvEeQyZ+NTckfM/K2PNSFarBfQ/U5KbYiISzDRXSd6esm5Sn/metJYRN08oqacINKsc/ab86pYW5oZeVrFQ7ZrBUboYNHUJPoWsJZ8dFImvh6VnKIDOayGQ2gPhen68IzdSsmpinQ3X8SvM8kGEys/WIOe3hKac9y1eGSk5yofNRWkwZwGzkc37TKumuQ5PBNn5TDY+AYJ13p0Zwc8n4wHLdomTkbCqICkCA8V7otDE9whNAAuKqDy+tBbNJOglcKlhX0spN2vR8kFMlOVQ7+B6XDspA1jXLeLTeNTmdIJ+uzQlv5tVtNw== 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=sTTL6ieafGoOkB/Z5vpWkQNbldHyN1IbAyrZusrdm8U=; b=kVIH9LAuafXkdxrXEr9zEtcB8K1FQ173K8kliIDxixdG/zWlTpx+RnVg2cf7JKHY23Y82Sr2d+ztzUuSOYLrCST/mBrdoY1o2ksfG7tKSddt2dywyq3vUHqgZEs8hEJ9HbPDvA0ohQGVRNfq8STjni+7/SDvT2vUY93NuE0PA0EB7WsIgO+9xOAqHPgD5eZGceKOYiU4Ah1KQlcvbvbEMbc/zdCzplkRaxycDFDzSxEhDD+OWbXYwhVjCF+TStVT75/tIxeOns5vfpellWrXAa3Oetew/rfaJp1VI2MMUpq+15bvj+CIeBNhCiYcJ55jIKC4OnC/wJJZPBc3N/fbCw== 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 AM6P191CA0040.EURP191.PROD.OUTLOOK.COM (2603:10a6:209:7f::17) by VI1PR08MB3695.eurprd08.prod.outlook.com (2603:10a6:803:c4::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5314.13; Fri, 10 Jun 2022 15:21:35 +0000 Received: from AM5EUR03FT059.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:7f:cafe::a5) by AM6P191CA0040.outlook.office365.com (2603:10a6:209:7f::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5332.13 via Frontend Transport; Fri, 10 Jun 2022 15:21:35 +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 AM5EUR03FT059.mail.protection.outlook.com (10.152.17.193) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5332.12 via Frontend Transport; Fri, 10 Jun 2022 15:21:35 +0000 Received: ("Tessian outbound 01afcf8ccfad:v120"); Fri, 10 Jun 2022 15:21:35 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: b91173434b936ba3 X-CR-MTA-TID: 64aa7808 Received: from b0786fc03acd.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 8C3C0BDB-B9E3-41D4-9848-EF4B1E85B738.1; Fri, 10 Jun 2022 15:21:28 +0000 Received: from EUR03-AM5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id b0786fc03acd.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 10 Jun 2022 15:21:28 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SWlB/h7fi+tKtbgmnGZjJXaqEDaQqEzA3VoqgjzEAQdeAzbsaFGq77evFdgWXO7s1vUwlwWKiXBbi3MS8UXoMOYFYC9yyBzRTXCC7tUSBt5HLba/6bGeKyoxPdiu6t8SzXDUpt8Ptw9st/beDsgtvSwY5TvR9MNmdC3d6IXgd/QNHdgLSCHgONtUAdtJ9oJRmMd0hhEBR4J7w/FtQqmN0DW7bxnG073fgPGYh7PG3fP2jdR+dchbLl7RmUJ4G2QtqzzVIPcBuxAgxsdUGjv60I3ju6DeECnBMrq4jYPxgc1PSZkXoZuaB6J++dxU0Yc/9EwEiM2+0h4lJJKpevXB8g== 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=sTTL6ieafGoOkB/Z5vpWkQNbldHyN1IbAyrZusrdm8U=; b=KGTEpq+DcXstw/qVEJRe7i74lNw10n6xSBTd2hRM7BrU3Ec+d3N+K351afL+toXZWl+zUIa7ctPxP7j3Xkp7/VTmmXskGNO2EeuEX8wcJlejl7xBqEk+uONLkvQpD68KzzG71w9mHHbdTn/F42jSQNUCrJb8wvdWJnt3CU+T+Db7+B2qjbJWd3sA4mu/+lmTwJfN9EYfPNnIMxFtPxMl1JWaHRoCBo6ljpw7uWyMAQ+7TaTU3hMZrLVwddrxbrSfOuMIUaZY20s8jktUulzmyQL+MU0HnqUIJ8nYdmP6i2kk10UdgLYX71G5HykmfgAAg36a795X090132YYDbb9Cg== 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 VE1PR08MB5119.eurprd08.prod.outlook.com (2603:10a6:803:114::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5332.13; Fri, 10 Jun 2022 15:21:27 +0000 Received: from VI1PR08MB3919.eurprd08.prod.outlook.com ([fe80::d9c0:539c:a641:5735]) by VI1PR08MB3919.eurprd08.prod.outlook.com ([fe80::d9c0:539c:a641:5735%2]) with mapi id 15.20.5332.014; Fri, 10 Jun 2022 15:21:26 +0000 Message-ID: Date: Fri, 10 Jun 2022 16:21:24 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [PATCHv2 3/6] gdb/arm: avoid undefined behaviour in arm_frame_is_thumb Content-Language: en-US To: Andrew Burgess , gdb-patches@sourceware.org References: <0d968da223ab233af5ce95520f5472a4d849d269.1654866187.git.aburgess@redhat.com> From: Luis Machado In-Reply-To: <0d968da223ab233af5ce95520f5472a4d849d269.1654866187.git.aburgess@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: LO4P123CA0248.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:1a7::19) To VI1PR08MB3919.eurprd08.prod.outlook.com (2603:10a6:803:c4::31) MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 889b23c7-a759-458a-767b-08da4af4e83b X-MS-TrafficTypeDiagnostic: VE1PR08MB5119:EE_|AM5EUR03FT059:EE_|VI1PR08MB3695:EE_ X-Microsoft-Antispam-PRVS: 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: FyGAHlErR6Zzbw5By5N/zavQJoduInQfh2235szT0cr7ZjXIjPP4qfrtUwBCf2rp34PqYhJC99g/IM7fvmARq/5laBDhh4KW5MVc0uj+J8ghxwH/VCOijDJQJ95iFUz3fFwSWydRO8tDkSS1dmiJWqZDDe6W0aHThZUDK9+qpPSn9Rz3pwf1nODcoqdkqzFycZwK9QzItgs/T7OdtRXoTC4CbP7s2X1PXxT7PDI7YRKNWHrEE1rhvoMsO7rlsgdLAACKKtMW+QrWrxUGD6uLQOk79PZ9W967GJyutNRQxOGhHLZNn+Vd09EZ06RBOOmVXsLXTJzNE8VzjHV45q/Z54+ve5UuEpthHpnM9pBmHQkPo/tPlTrGzBRPx+3aI32yT4AiZxAZoPX9AeCeLyPFjcf3o70iCMkzD9CeL3fOuxsIYSPGk/U5+VBX7IPc/ipRGDwm+65tKBnTM4hlK6h4gDZ27YpO7ywytFyTIQ9N04Cp0N2sgDsRPtuFvkjHXmWBL5zDBoEcE9Z2/1UqHTu5dfzqBTcqQOlCrpyAeDl4nys6ZDjYyuVdBoV1DTNg7/ktVMHViWSWYZlhBsA2mXcJSYTH/eZoxO7C5F01ov2/Xc6KGoWvdWUFK8A8q9+62cixFJr16/uIRF5AFBteVYKx7S54P6cgTRwTlNw3LKyvDOPPHwubI+NwamNQCvlFjL+8r7KevtLEOvhABNP1zVH32XfKIPgIKBVfgtjiX7+zeM3FeoeflQUG2f7Rz2eMmlNGTR96MQbT0HaiRBRQGh8kcUe/l+fDMwcRKLcUzjEk0/5BJerrKvlXuKVDQoJc+nNc 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:(13230001)(4636009)(366004)(2616005)(31696002)(508600001)(86362001)(6506007)(6486002)(26005)(53546011)(6512007)(186003)(84970400001)(2906002)(83380400001)(66476007)(66946007)(8936002)(31686004)(44832011)(5660300002)(36756003)(316002)(38100700002)(8676002)(66556008)(43740500002)(45980500001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB5119 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: AM5EUR03FT059.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 849b13be-3aaf-461d-ae1a-08da4af4e2ea X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: du3R8KCLru81f2mL0zHuV1D5rcDj4NX3nQ1KZaW2NKvqsK05kmlqKS7BJvGkAVK0uwU1GZnEX9EgqlaS2RAwKLG0iTfXn3RFW6SgZ15uMqz0bmtCjeZbG3U8K0+WW3GukzCxPFz/xKdEZj12hqPI1+IYXQae3ZqwqLXd2nQyixhGNzhtJAIELJuMTvCM17SHAgbSQ5emHEaXeUDx6pXAW0Tnw6MtWHwt7hCLa83VZVKkKFTHz9hWprYKm5CxMLzkbTfg4huix1OMn3B8U0X22NgmTYGORYenLfywaB070+10Jkj/E7fLlzPc0g27Y5kIV1suwgDYtquMp/GF1HMF9KaWv4R+R6P5Fb1loY7YvzQEOSaIM86FLR5wwZbTdPi8wRIgUmMVNib+GDjouaU6BijZw1Y7WsQ6wqraKYPpOma4hm+44PMdk2Z4vNRizuvjXxuBaQhAyIzvUxQzu5VOg3Jwdwz1JhfCV/bq/56SXoaLp1sWosRd0K7zoQDXbS+X+spw1Y1fWuJvPNVCrRENpWnNFP/sYZfTcw6hyGY0XjdSlBqF2YqPGcRL2Rq0u4QDnLd7wVmFAJScwOGMojyJc/wxArUiDzEUfFbEmzJzYU96kAnHc8qarmaH9+JrokFwJJqOPsVVY12zhhaTHMsaTp83hrtI+SJUMwlkKlzrAvQSgGCUmSI9t1b4nwt7ocL2Mln1ZgS746+mFpe3QSCHecl4eewGDha6JuMi1zeRowwmWC5QZaF5VmO+1n4i5eJc2f9idJHMAewXSEZXxnklbiQ9qTavQy3jBWHv0oxuFa0= 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:(13230001)(4636009)(46966006)(40470700004)(36840700001)(356005)(82310400005)(84970400001)(83380400001)(6486002)(81166007)(8936002)(186003)(36860700001)(336012)(36756003)(47076005)(40460700003)(53546011)(508600001)(2906002)(31696002)(6506007)(316002)(26005)(86362001)(70206006)(5660300002)(31686004)(6512007)(70586007)(8676002)(44832011)(2616005)(43740500002); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jun 2022 15:21:35.4251 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 889b23c7-a759-458a-767b-08da4af4e83b 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: AM5EUR03FT059.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB3695 X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, FORGED_SPF_HELO, 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 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: Fri, 10 Jun 2022 15:21:42 -0000 On 6/10/22 14:08, Andrew Burgess via Gdb-patches wrote: > This commit fixes real undefined behaviour in GDB which I spotted when > working on a later patch in this series. The later patch in this > series detects when the result of gdbarch_tdep() is cast to the wrong > type. > > The issue is revealed by the gdb.multi/multi-arch.exp test. > > In this test we setup two inferiors, an AArch64 process, and an ARM > process, then at one point we have inferior 1 selected (the AArch64 > inferior), and we place a breakpoint on a symbol present in the other > inferior (the ARM inferior). > > During the process of creating the breakpoint we call arm_pc_is_thumb, > the GDBARCH passed into this function is correct, that is, represents > the ARM process. > > For whatever reason we are unable to figure out if the address in > question is thumb or not throughout most of arm_pc_is_thumb, and so we > get to this code at the end of the function: > > /* If we couldn't find any symbol, but we're talking to a running > target, then trust the current value of $cpsr. This lets > "display/i $pc" always show the correct mode (though if there is > a symbol table we will not reach here, so it still may not be > displayed in the mode it will be executed). */ > if (target_has_registers ()) > return arm_frame_is_thumb (get_current_frame ()); > > Which I guess is a last attempt to figure out the thumb status of an > address. However, remember, we the AArch64 inferior is current at > this time, so the current frame is an AArch64 frame. If we're trying to insert a breakpoint into a 32-bit inferior, we should really have the 32-bit arm gdbarch at hand, not the AArch64 gdbarch. I think the bug is somewhere else, in whoever passed the current inferior's gdbarch as opposed to the gdbarch of the inferior that contains the symbol we've found. I think this should be an assertion instead, as it is clearly wrong.