From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-eopbgr70042.outbound.protection.outlook.com [40.107.7.42]) by sourceware.org (Postfix) with ESMTPS id 6A75438515C3 for ; Wed, 1 Jun 2022 07:59:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6A75438515C3 ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=JqKoRTclV5iRlewtpexK43QxcHo+M+n/kqXUW39S5TC07efck0lyazwxAtR3q+QtlV+b14yCCZX+M2IH6Fwl5yj8F895/uFYRZKc8Gs57Ga0U/kYeUZsmEU4d+dMrDoEOOeBgnO6+O8clh5g6PoVUpYaj0AOWG28wyDM6AhrfSvOY/fEsT9j63znuas5W4+SDZ28Yvpsvs6gMT6lPnmpgMT8f4XwuV/frtqonUichl+Cfh2wqWaNClGQJ+GkmrscEU8+2Sd384oHqCp17fEZ5YQnlJ7/jZjlKA3GfIxBmR1cQdRAcvxKzujg+xq9xJi4Sd6dFJRhZoFowy9CHLjA4g== 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=pM/kmk8v6ETvZfOsQW0Jr2V+Vz/XJBB2r6vJwKUfrDI=; b=aW1Qnuf6zOahxr+g6r6+50iAsPBEkRiLs5ewmJEcFPZxcw0a8NS0IDqBNbXix76uREXk4x1fToQXpqZVJdtRh61dmf1sPKioE2aGtIWI2HVaYUGcYXjr/g2BWgQ4+SOB10VayI1UyBdFDqXXyAE4X9WjPjSKzX9sSRXOtETljQLcKn6Pg/gYwn+sLe4jKv9fdTr+sNu3w7zIWA+vlmJygbLt8nuCp3LgSzZ8PIGNUOpLTSQuobWWmPaFuPMlvmdBLGzPRvD4QdBf4w/yl/xEdMoCoxM/J7D3r1HxN5WnLWdoLszvnPUPPYHHMI8BR994VYy0AcaBnt3sOD8qn9WpqA== 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 DB8PR09CA0007.eurprd09.prod.outlook.com (2603:10a6:10:a0::20) by AM6PR08MB4455.eurprd08.prod.outlook.com (2603:10a6:20b:70::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5293.13; Wed, 1 Jun 2022 07:59:09 +0000 Received: from DBAEUR03FT032.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:a0:cafe::e3) by DB8PR09CA0007.outlook.office365.com (2603:10a6:10:a0::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5314.12 via Frontend Transport; Wed, 1 Jun 2022 07:59:09 +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 DBAEUR03FT032.mail.protection.outlook.com (100.127.142.185) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5314.12 via Frontend Transport; Wed, 1 Jun 2022 07:59:09 +0000 Received: ("Tessian outbound 6f53897bcd4e:v120"); Wed, 01 Jun 2022 07:59:09 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 963c6936f66abe96 X-CR-MTA-TID: 64aa7808 Received: from f6973049c0fc.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 79855D1B-D831-4CBD-AF9F-6B9066724692.1; Wed, 01 Jun 2022 07:59:02 +0000 Received: from EUR01-DB5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id f6973049c0fc.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 01 Jun 2022 07:59:02 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=i7+ord2G2Tk3bE3ZitLnWGrC/n8SfxeYyqn53R601vZ9zAVPROPpaFC3/B3K2+cRfck783iBBCn27stVqNIuiFpAVI5ix2dfb44WzDUrrEBaNRKBDcIOvnZjBvq+dF6+Mjg8JB1Fy55OkzNLRGSTxf72mRRQC0Rmchg0tE8JYA6WTU5NQYquEVfilQUS5uDjP7n+2CHSFLrXosA3Z3P1/lgOZuLUWPp1TPcsTLK0CQZCDz21Z8bJqtl280H5xieMHo/7RYZWq3T6GSBhFdqO5lgRDb/aPP+bRnPSO4A96AkfhlDwTtXQ49UOin1+G1wciAhYqS0Mt2a0c5UWcGuA0g== 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=pM/kmk8v6ETvZfOsQW0Jr2V+Vz/XJBB2r6vJwKUfrDI=; b=bGHr3pRKfvUIDNqlygpiMuquxvbb9b5Sn70J/lGPN5s+KVU1JmWwUswdRqGEJi1uQ54UHiYjh2OVLHh39+26eZvrx/XYn9GVXfeWEYpCUUGSQvgbkYFydq7amUoy4zpIX+EoQwsOyLJ2xa/f7gcPFIFWZ6qJ5RgDZawbK4VyQdZpKqKc+BUOZ/uYBoGunstl9WDS6CKqIQYGaPIIB+r75StVEXdqEU1iSSIBHtPmOQbvjZbzD97HOHb+uJMFmigpqiEZZmBly7BAwTDZQCph7IERq09Rduh/wBed2u5iSro06zTEr8p3xzlB+pzuIyo2fXTlEv+sP9iHl8f6MvVKxg== 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 AM7PR08MB5493.eurprd08.prod.outlook.com (2603:10a6:20b:102::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5314.12; Wed, 1 Jun 2022 07:59:00 +0000 Received: from VI1PR08MB3919.eurprd08.prod.outlook.com ([fe80::9545:ff73:df89:3e50]) by VI1PR08MB3919.eurprd08.prod.outlook.com ([fe80::9545:ff73:df89:3e50%7]) with mapi id 15.20.5314.013; Wed, 1 Jun 2022 07:58:59 +0000 Message-ID: Date: Wed, 1 Jun 2022 08:58:57 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [PATCH 1/5] gdb/arm: move fetch of arm_gdbarch_tdep to a more inner scope 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; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: LO4P265CA0078.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:2bd::7) To VI1PR08MB3919.eurprd08.prod.outlook.com (2603:10a6:803:c4::31) MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: e61561a0-3233-4958-4608-08da43a49c0d X-MS-TrafficTypeDiagnostic: AM7PR08MB5493:EE_|DBAEUR03FT032:EE_|AM6PR08MB4455: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: G4QnDxcz4nr72pIrE4J/SKXobJx2GE2eWSmvfiCsEYTFH6NKMY8EFoJ4zyifTwMFyf6wvVtowJTNWLV/wVmd7oTaUSTYZ8/isIr7GctW2iPc4bWTRumqQXIIpxxnPmp3sXl8IAjqWTlcg2fRAa91zZmcH6UtTvcjiLZlBU3nxX3LtsUslCXSzdEAvett2P2cjJus78S0rVs5PmE/nKRA+gG7aJuGvUasb/zOYtxpxJ1wOvMuqjUiQTdIvAkJ8FdmI5Drl9UzO1Uwd9OTnJYHnCU+xf1hOkDHNFFZ4bl5TtFNEusGW3VsCu5G1H2tXRwcigb7vYkvpxSx2fM7D71ZJvU+98RjZzBSCC6LJo5dTsZMFNjuJ+FG/TFagIX2Z4ejs51FsK/okaAQxp49Ip/XwueLqfgJat0OuK6OS+1ACtuw14upr+R4bHdVdiZZnXETPK7OvPEW+7iG7lXiPyjNgxa9hvtrMZv/MRs67MKUU5VgOT4SFVGu+mwoY22yyWxOfN9X0tE9jFOqYz6U6qRtzBqno1G/Gi+pkA0U+mY/6DrA8TmAlvwiFC97/DdkHFAE6j415m/tIQsqu3dlKFZsmfeiDJlLGjqQNFxf/JyDPsR0gxy5BfmJZESRP1hxjrNMjp9bzBrksugM6L1CyGABpTnVwmOV7WLHQjR/kVSTK2iAFrZUGyBa4D9h5IdidAgHZVYgio4iSL9eR6k1gUatdBP0NI0Gt/W5/c1EHiUhWa8= 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)(66946007)(66556008)(66476007)(8676002)(38100700002)(316002)(36756003)(6486002)(508600001)(8936002)(31696002)(5660300002)(83380400001)(2906002)(86362001)(6506007)(31686004)(26005)(2616005)(186003)(44832011)(6512007)(53546011)(45980500001)(43740500002); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR08MB5493 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: DBAEUR03FT032.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: cce52215-a3e2-493a-a6a4-08da43a495ab X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZmdpsnHqfibQDEPjzh7owZVWi3caw6PrL6E+g8hmuWvYAiVAn3qlhlziDrHDaufJXWZ0OeaJNcPTwlR9Jd7ljZIoPgWc/Pue93Me6r9u+60RseRsI4ekAgNXURZFk9ToqYDoSOvGATdwTNG8ny01oq9kEdIVTEYPbmmQP+UmC2FDBaxm2InEzBdT81oJr6AC2nks/uRi7YDu+pOPWEgBhNCJySPN+3Q3HkBn4Reju9Xbw22fNVUpQbTqCU8kj/YT8MoXBiD57O7qlwdm0f/ujht2yJvbZ2ujAthBMnyWWEqncAOv4lj0xuYTXPqQqCp6lUhLydCZ2eURQAQPfRaa4f0aTmMp61G5OC8ZKhhnYljQgL+9LVjn9/mO60AuDKePTMImHAUAy9XZOINhohO5E3CwGG4S7MoGebBY+dZv+szTOIVYxZHwqJYutacYGDHQddkEO/WLv/pJovmOlw5k5+qprcJf9ryBP5U+UgmdA6806w8fhnnjLOZhtQDaVulIPO9eNsAL+NWjU9Y7Feb/4gY4wzbknFjB/afNL1KfVnkgTQxTOLYhFyad5jDUFeUDEJVg1PN0780vDePmX5DsEypihAAQQh0sYkzvwDkXKe04Xvf5EassNGJRZiICX8kRjBvnUJ/d6Tqbe9TmbfH5iS2uKS6yMxGe99qLIn3EMtJsoHGTQdoxaFfuM2c/Db5WaHeSAtmGO8IhywIFFchJVw== 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)(40470700004)(46966006)(36840700001)(186003)(31696002)(6486002)(8676002)(5660300002)(70206006)(70586007)(86362001)(83380400001)(40460700003)(508600001)(8936002)(26005)(6512007)(36860700001)(356005)(82310400005)(81166007)(2616005)(44832011)(6506007)(53546011)(2906002)(36756003)(47076005)(31686004)(316002)(336012)(43740500002); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jun 2022 07:59:09.8159 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e61561a0-3233-4958-4608-08da43a49c0d 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: DBAEUR03FT032.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4455 X-Spam-Status: No, score=-13.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, 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: Wed, 01 Jun 2022 07:59:16 -0000 On 5/31/22 15:30, Andrew Burgess via Gdb-patches wrote: > This is a small refactor to resolve an issue before it becomes a > problem in a later commit. > > Move the fetching of an arm_gdbarch_tdep into a more inner scope > within two functions in arm-tdep.c. > > The problem with the current code is that the functions in question > are used as the callbacks for two set/show parameters. These set/show > parameters are available no matter the current architecture, but are > really about controlling an ARM architecture specific setting. And > so, if I build GDB for all targets on an x86-64/GNU-Linux system, I > can still do this: > > (gdb) show arm fpu > (gdb) show arm abi > > After these calls we end up in show_fp_model and arm_show_abi > respectively, where we unconditionally do this: > > arm_gdbarch_tdep *tdep > = (arm_gdbarch_tdep *) gdbarch_tdep (target_gdbarch ()); > > However, the gdbarch_tdep() result will only be a arm_gdbarch_tdep if > the current architecture is ARM, otherwise the result will actually be > of some other type. > > This isn't actually a problem, as in both cases the use of tdep is > guarded by a later check that the gdbarch architecture is > bfd_arch_arm. > > This commit just moves the call to gdbarch_tdep() after the > architecture check. > > In a later commit gdbarch_tdep() will be able to spot when we are > casting the result to the wrong type, and this function will trigger > assertion failures if things are not fixed. > > There should be not user visible changes after this commit. > --- > gdb/arm-tdep.c | 24 ++++++++++++++---------- > 1 file changed, 14 insertions(+), 10 deletions(-) > > diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c > index 49664093f00..d39342e19c6 100644 > --- a/gdb/arm-tdep.c > +++ b/gdb/arm-tdep.c > @@ -9015,14 +9015,16 @@ static void > show_fp_model (struct ui_file *file, int from_tty, > struct cmd_list_element *c, const char *value) > { > - arm_gdbarch_tdep *tdep > - = (arm_gdbarch_tdep *) gdbarch_tdep (target_gdbarch ()); > - > if (arm_fp_model == ARM_FLOAT_AUTO > && gdbarch_bfd_arch_info (target_gdbarch ())->arch == bfd_arch_arm) > - gdb_printf (file, _("\ > + { > + arm_gdbarch_tdep *tdep > + = (arm_gdbarch_tdep *) gdbarch_tdep (target_gdbarch ()); > + > + gdb_printf (file, _("\ > The current ARM floating point model is \"auto\" (currently \"%s\").\n"), > - fp_model_strings[tdep->fp_model]); > + fp_model_strings[tdep->fp_model]); > + } > else > gdb_printf (file, _("\ > The current ARM floating point model is \"%s\".\n"), > @@ -9053,14 +9055,16 @@ static void > arm_show_abi (struct ui_file *file, int from_tty, > struct cmd_list_element *c, const char *value) > { > - arm_gdbarch_tdep *tdep > - = (arm_gdbarch_tdep *) gdbarch_tdep (target_gdbarch ()); > - > if (arm_abi_global == ARM_ABI_AUTO > && gdbarch_bfd_arch_info (target_gdbarch ())->arch == bfd_arch_arm) > - gdb_printf (file, _("\ > + { > + arm_gdbarch_tdep *tdep > + = (arm_gdbarch_tdep *) gdbarch_tdep (target_gdbarch ()); > + > + gdb_printf (file, _("\ > The current ARM ABI is \"auto\" (currently \"%s\").\n"), > - arm_abi_strings[tdep->arm_abi]); > + arm_abi_strings[tdep->arm_abi]); > + } > else > gdb_printf (file, _("The current ARM ABI is \"%s\".\n"), > arm_abi_string); LGTM