From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 4UA4C6WfYGphziQAWB0awg (envelope-from ) for ; Wed, 22 Jul 2026 06:47:01 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=5X6lFA33; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 22D011E166; Wed, 22 Jul 2026 06:47:01 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-6.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 6652F1E099 for ; Wed, 22 Jul 2026 06:46:58 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id EA3294BA2E1C for ; Wed, 22 Jul 2026 10:46:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EA3294BA2E1C Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=5X6lFA33 Received: from PH7PR06CU001.outbound.protection.outlook.com (mail-westus3azlp170100009.outbound.protection.outlook.com [IPv6:2a01:111:f403:c107::9]) by sourceware.org (Postfix) with ESMTPS id 1100E4BA2E3B for ; Wed, 22 Jul 2026 10:42:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1100E4BA2E3B Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=amd.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 1100E4BA2E3B Authentication-Results: sourceware.org; arc=pass smtp.remote-ip=2a01:111:f403:c107::9 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1784716976; cv=pass; b=xIpPQUVMpsQdrARWdDVnbEahlVGViRPnuytYlU/rFjCSDkymqeK2S1zGwIMZ6DEn12o1vILfVyNJ2qC1xRae/N0pGAZabaBM4rNcbVdSpjT2+F0OyupdLqmDeF36SMCJK62/wxyERH73FAxkaiW0qe/jVxd/UZBIR1jndVALEsw= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1784716976; c=relaxed/simple; bh=9zj2w5Nk2389E+FKlxW/O1JCeq/HFy+Cd6ziFYMS2AQ=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=oshrYcvFpVz+rwcNpKS4taKikN+Skn9Ymc4w2wQcT2lAX+CE9yArsF4HSMNcSEHrQIgJeGwpxBnFHKm6fyuL+Ve8YVeSYumI7VV2LOMEUyU+oo6p275TVfE1eCqhPu90JmvNjYbp7ysSUEg8V1Th2ng2DD1P5X9wTVE/yhPbzAA= ARC-Authentication-Results: i=2; sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=5X6lFA33 DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1100E4BA2E3B ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Mrp7s6pL1LZfLWUePetM3Bfbn6kIrRdMuriqQYS0nPkGQ/HHf8Av2117xNxNs/t4Tmtx9jkYHywCpexRXXhTB2sgpiJvKEVQA+08JhjpDQ6d0xi/N71Y+ZzGr2xcYVgZdsK+2eAE3SZIcJwlijpA4hNHU/iYhbi5JfuJiWAXovakw0UhLk0ps1VsBGCZ9Hwr66ZxVOuAqLUDIkMtdC3/NHr3044xoXqF/DGmvAUCO5gdO+5BqjR4sptXTWjSV50QJynRABr+EMBeagZqPvO/rfUQ1XQP3m1XzPth4xs08uMxholM1I3mOH26TiG3I7AS5fHOo6LCrwI33L3OzTyR9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=yzY9WkkSO8WDIjmJ5lJ+/dtKx4EQuLNU39CMGnT2vmE=; b=I15czn9ZuS8EsjaW3Mfch+vlMKzOT4khuXCoYUprfdlFTOG9rBqCjNCdLYVODYwwYEPW4RXrW7zuGuee3z7G2VsAyaj4VCGkrK4FqxBPsr7EuNoUgXA8m/SCVDzBWVz3VOmwONZK6xhFTU59qgdN9QIBcBip1VcOg4ZizQoO/nIe53pC3Mc9S2IvPQLm5c+p7ykJUaBK4Sb/p2frO2r8LCkH5hIirGRSzpEbtwNhARFp4kIOfrE/kTfTgZA2w36RanmEHsahvRrfSctOd9Iw+bId38gWPds3EQN5SOApjgYcCVohXkRhb7JA0Ob2tSIy6kNrSQxliHRgnnjbr6B0EQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=sourceware.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=yzY9WkkSO8WDIjmJ5lJ+/dtKx4EQuLNU39CMGnT2vmE=; b=5X6lFA33qJGb6EFjKV3v/Ld9pH4v2Um0D1SNbA5iPoX4SxGmZrj7NusuqNFGIcub/mgYuwP5a9k6XcP8gE6kaw8eRGaLQhH4FQfuCeTvDUAE8ezv9PzZcnynGAkPU6tFvA1HJwBs+8iHE59MTXV9QNLQWCXSSXBwD9EU7MT+M1w= Received: from CH0PR03CA0100.namprd03.prod.outlook.com (2603:10b6:610:cd::15) by MW4PR12MB7142.namprd12.prod.outlook.com (2603:10b6:303:220::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.245.10; Wed, 22 Jul 2026 10:42:43 +0000 Received: from CH3PEPF00000013.namprd21.prod.outlook.com (2603:10b6:610:cd:cafe::22) by CH0PR03CA0100.outlook.office365.com (2603:10b6:610:cd::15) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.245.10 via Frontend Transport; Wed, 22 Jul 2026 10:42:43 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=satlexmb07.amd.com; pr=C Received: from satlexmb07.amd.com (165.204.84.17) by CH3PEPF00000013.mail.protection.outlook.com (10.167.244.118) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.270.0 via Frontend Transport; Wed, 22 Jul 2026 10:42:43 +0000 Received: from ctr-rack32-mi300x-1.amd.com (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.41; Wed, 22 Jul 2026 05:42:41 -0500 From: Tankut Baris Aktemur To: CC: Subject: [PATCH v2 02/17] gdb: convert address_class_type_flags_to_name to address_class_id_to_name Date: Wed, 22 Jul 2026 05:41:51 -0500 Message-ID: <20260722-users-aktemur-type-instance-flags-v2-2-d60dcbc2a76f@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260722-users-aktemur-type-instance-flags-v2-0-d60dcbc2a76f@amd.com> References: <20260722-users-aktemur-type-instance-flags-v2-0-d60dcbc2a76f@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" X-Mailer: b4 0.15.0 Content-Transfer-Encoding: 8bit X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: satlexmb08.amd.com (10.181.42.217) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH3PEPF00000013:EE_|MW4PR12MB7142:EE_ X-MS-Office365-Filtering-Correlation-Id: e073d569-d191-4764-ac0b-08dee7ddf5d1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|36860700016|376014|82310400026|23010399003|22082099003|18002099003|10067099003|11063799006|56012099006|3023799007|6133799003; X-Microsoft-Antispam-Message-Info: tjeIc7UhRR49XibszOOHCyrYu8SdO+REdBbfKQenjn7gacLpTGVPWbHrhC2FMsQRXkNkIvBn4paSGvfH/k1EWJ3gcBfvA66/hV3Xg7sdhYOmZv3jyu9UZMJd5mHcawk5/H/0Gm6+lfjx2nJv85eW7iheIdTwM89ZzykGc8gcfxjX627kwORTcKvB0RqkkDn4+dihBKwafOTXexO6Bj5kNBvivWrA6NGfQR2g5eW0p1NqXHDWmMmu2qf3p+pl1yLXFsbDj8EbVW47JiHI1/MANuP0IbmWee620z1FQtvlZIbSKnB8sTR/8SZAEGp2q3JHhMgIPvPSrNOmk7an3MgRlHBQPPeDYTx76lp2xti7MKlcQf87iBEIgiPMOS8hvWaAEAgIK4Yj1T2Ey6CybfLOJZZQi+yRZ+ArRN4i+Z+T+awAobtS66BlBjLqRumGOUkCbMJKrvrSCr7sMbPgk7kuUKIOe7y5GZPNlOg2Bmvcw7k/PZxF285GIohRLsUqseVmvLPV3KA5yaJWW8uOSBcB30Qj2gerpE+B6PEg+QBv8ZAKRG20vsfAokv5e9gjOz9QuOlK5xsddTDzBsTa3fbVihSvxcOm2qeAGQCMREMMIo0r3EkGQDeSu3+SEJ4LHoWasrZ6gIAn/RhNxafusZMLPVTUno+B2/kJviiIaTV3/KgMM41LN+Z8EWq3/tctSOvxw4URfrCDPPB6gD1XbUC9Gw== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:satlexmb07.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(1800799024)(36860700016)(376014)(82310400026)(23010399003)(22082099003)(18002099003)(10067099003)(11063799006)(56012099006)(3023799007)(6133799003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 4FOuW18D48Sk0Z0Ke0FXlQBkU4vgB+wxtU97/UHS8alUOcgv+q3gkJ6D/zkd5c/+XJfd48gLvaAWmG1rO3k0/BYbjsTP5gGy0xu0I0P5yOYMS7bgQc+hIOt/z++FodfywZDQu5u7dsVeCivofgwIePJjidUOGbtGlWUt50m54NKs4jqgk5nvCNHvWWtJ3h6qSrEJAV+OnxI8+ErNrPhK1AXPsibYIsxADrzRSB27CvlPfBaLBlAsHwxlZXVjygLFGf1OpD3eDgGe6L+VuKlnHxeIjCaLci7TI2D0jGEGgEepm2th2E+9qQMdPlTjXCcnIGPlhJa/TD5Diquz1NvhS5NsJw4pxy1XqgDw0rD/KpczOwIlWIJv50Nr/PmiXkGn3fvTZhk3uzfoFQohnLTppPCaXOiAOCzCAxEnXwaOQO8mVZHreoUtpvPGh27p9Y1e X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jul 2026 10:42:43.0595 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e073d569-d191-4764-ac0b-08dee7ddf5d1 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CH3PEPF00000013.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB7142 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org In type instance flags, two bits are allocated for encoding the address class. Although defined like a bitmask, those two bits in fact represent an architecture-specific enum value. As a step towards making this conceptual separation clear, refactor the gdbarch method 'address_class_type_flags_to_name'. This method is used for returning the name for the address class id encoded in type instance flags. Make this clear by passing it the address class id, instead of the whole flags. --- gdb/avr-tdep.c | 27 ++++++++++++--------------- gdb/ft32-tdep.c | 14 +++++++------- gdb/gdbarch-gen.c | 30 +++++++++++++++--------------- gdb/gdbarch-gen.h | 11 +++++++---- gdb/gdbarch_components.py | 8 ++++++-- gdb/gdbtypes.c | 8 +++++--- gdb/gdbtypes.h | 4 ++++ gdb/s390-tdep.c | 12 ++++++------ 8 files changed, 62 insertions(+), 52 deletions(-) diff --git a/gdb/avr-tdep.c b/gdb/avr-tdep.c index ddb917fda5f..d29e47b3a71 100644 --- a/gdb/avr-tdep.c +++ b/gdb/avr-tdep.c @@ -72,13 +72,10 @@ /* Constants: prefixed with AVR_ to avoid name space clashes */ -/* Address space flags */ +/* We are assigning the id 1 to the flash address space. */ -/* We are assigning the TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1 to the flash address - space. */ - -#define AVR_TYPE_ADDRESS_CLASS_FLASH TYPE_ADDRESS_CLASS_1 -#define AVR_TYPE_INSTANCE_FLAG_ADDRESS_CLASS_FLASH \ +#define AVR_ADDRESS_CLASS_FLASH 1 +#define AVR_TYPE_INSTANCE_FLAG_ADDRESS_CLASS_FLASH \ TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1 @@ -310,7 +307,7 @@ avr_address_to_pointer (struct gdbarch *gdbarch, enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); /* Is it a data address in flash? */ - if (AVR_TYPE_ADDRESS_CLASS_FLASH (type)) + if (TYPE_ADDRESS_CLASS (type) == AVR_ADDRESS_CLASS_FLASH) { /* A data pointer in flash is byte addressed. */ store_unsigned_integer (buf, type->length (), byte_order, @@ -342,7 +339,7 @@ avr_pointer_to_address (struct gdbarch *gdbarch, = extract_unsigned_integer (buf, type->length (), byte_order); /* Is it a data address in flash? */ - if (AVR_TYPE_ADDRESS_CLASS_FLASH (type)) + if (TYPE_ADDRESS_CLASS (type) == AVR_ADDRESS_CLASS_FLASH) { /* A data pointer in flash is already byte addressed. */ return avr_make_iaddr (addr); @@ -1390,15 +1387,15 @@ avr_address_class_type_flags (int byte_size, int dwarf2_addr_class) return 0; } -/* Implementation of `address_class_type_flags_to_name' gdbarch method. +/* Implementation of `address_class_id_to_name' gdbarch method. - Convert a type_instance_flag_value to an address space qualifier. */ + Convert an address class id to an address class qualifier. */ static const char* -avr_address_class_type_flags_to_name (struct gdbarch *gdbarch, - type_instance_flags type_flags) +avr_address_class_id_to_name (struct gdbarch *gdbarch, + unsigned int address_class) { - if (type_flags & AVR_TYPE_INSTANCE_FLAG_ADDRESS_CLASS_FLASH) + if (address_class == AVR_ADDRESS_CLASS_FLASH) return "flash"; else return NULL; @@ -1540,8 +1537,8 @@ avr_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) set_gdbarch_address_class_type_flags (gdbarch, avr_address_class_type_flags); set_gdbarch_address_class_name_to_type_flags (gdbarch, avr_address_class_name_to_type_flags); - set_gdbarch_address_class_type_flags_to_name - (gdbarch, avr_address_class_type_flags_to_name); + set_gdbarch_address_class_id_to_name + (gdbarch, avr_address_class_id_to_name); return gdbarch; } diff --git a/gdb/ft32-tdep.c b/gdb/ft32-tdep.c index 45afebb18e9..b0da5bf815b 100644 --- a/gdb/ft32-tdep.c +++ b/gdb/ft32-tdep.c @@ -354,15 +354,15 @@ ft32_address_class_type_flags (int byte_size, int dwarf2_addr_class) return 0; } -/* Implementation of `address_class_type_flags_to_name' gdbarch method. +/* Implementation of `address_class_id_to_name' gdbarch method. - Convert a type_instance_flag_value to an address space qualifier. */ + Convert an address class id to an address space qualifier. */ static const char* -ft32_address_class_type_flags_to_name (struct gdbarch *gdbarch, - type_instance_flags type_flags) +ft32_address_class_id_to_name (struct gdbarch *gdbarch, + unsigned int address_class) { - if (type_flags & TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1) + if (address_class == 1) return "flash"; else return NULL; @@ -612,8 +612,8 @@ ft32_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) set_gdbarch_address_class_type_flags (gdbarch, ft32_address_class_type_flags); set_gdbarch_address_class_name_to_type_flags (gdbarch, ft32_address_class_name_to_type_flags); - set_gdbarch_address_class_type_flags_to_name - (gdbarch, ft32_address_class_type_flags_to_name); + set_gdbarch_address_class_id_to_name + (gdbarch, ft32_address_class_id_to_name); return gdbarch; } diff --git a/gdb/gdbarch-gen.c b/gdb/gdbarch-gen.c index f424fa2a86e..e1c5a902b00 100644 --- a/gdb/gdbarch-gen.c +++ b/gdb/gdbarch-gen.c @@ -164,7 +164,7 @@ struct gdbarch bool cannot_step_breakpoint = false; bool have_nonsteppable_watchpoint = false; gdbarch_address_class_type_flags_ftype *address_class_type_flags = nullptr; - gdbarch_address_class_type_flags_to_name_ftype *address_class_type_flags_to_name = nullptr; + gdbarch_address_class_id_to_name_ftype *address_class_id_to_name = nullptr; gdbarch_execute_dwarf_cfa_vendor_op_ftype *execute_dwarf_cfa_vendor_op = default_execute_dwarf_cfa_vendor_op; gdbarch_address_class_name_to_type_flags_ftype *address_class_name_to_type_flags = nullptr; gdbarch_register_reggroup_p_ftype *register_reggroup_p = default_register_reggroup_p; @@ -419,7 +419,7 @@ verify_gdbarch (struct gdbarch *gdbarch) /* Skip verify of cannot_step_breakpoint, invalid_p == 0. */ /* Skip verify of have_nonsteppable_watchpoint, invalid_p == 0. */ /* Skip verify of address_class_type_flags, has predicate. */ - /* Skip verify of address_class_type_flags_to_name, has predicate. */ + /* Skip verify of address_class_id_to_name, has predicate. */ /* Skip verify of execute_dwarf_cfa_vendor_op, invalid_p == 0. */ /* Skip verify of address_class_name_to_type_flags, has predicate. */ /* Skip verify of register_reggroup_p, invalid_p == 0. */ @@ -965,11 +965,11 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file) "gdbarch_dump: address_class_type_flags = <%s>\n", host_address_to_string (gdbarch->address_class_type_flags)); gdb_printf (file, - "gdbarch_dump: gdbarch_address_class_type_flags_to_name_p() = %d\n", - gdbarch_address_class_type_flags_to_name_p (gdbarch)); + "gdbarch_dump: gdbarch_address_class_id_to_name_p() = %d\n", + gdbarch_address_class_id_to_name_p (gdbarch)); gdb_printf (file, - "gdbarch_dump: address_class_type_flags_to_name = <%s>\n", - host_address_to_string (gdbarch->address_class_type_flags_to_name)); + "gdbarch_dump: address_class_id_to_name = <%s>\n", + host_address_to_string (gdbarch->address_class_id_to_name)); gdb_printf (file, "gdbarch_dump: execute_dwarf_cfa_vendor_op = <%s>\n", host_address_to_string (gdbarch->execute_dwarf_cfa_vendor_op)); @@ -3520,27 +3520,27 @@ set_gdbarch_address_class_type_flags (struct gdbarch *gdbarch, } bool -gdbarch_address_class_type_flags_to_name_p (struct gdbarch *gdbarch) +gdbarch_address_class_id_to_name_p (struct gdbarch *gdbarch) { gdb_assert (gdbarch != nullptr); - return gdbarch->address_class_type_flags_to_name != nullptr; + return gdbarch->address_class_id_to_name != nullptr; } const char * -gdbarch_address_class_type_flags_to_name (struct gdbarch *gdbarch, type_instance_flags type_flags) +gdbarch_address_class_id_to_name (struct gdbarch *gdbarch, unsigned int address_class) { gdb_assert (gdbarch != nullptr); - gdb_assert (gdbarch->address_class_type_flags_to_name != nullptr); + gdb_assert (gdbarch->address_class_id_to_name != nullptr); if (gdbarch_debug >= 2) - gdb_printf (gdb_stdlog, "gdbarch_address_class_type_flags_to_name called\n"); - return gdbarch->address_class_type_flags_to_name (gdbarch, type_flags); + gdb_printf (gdb_stdlog, "gdbarch_address_class_id_to_name called\n"); + return gdbarch->address_class_id_to_name (gdbarch, address_class); } void -set_gdbarch_address_class_type_flags_to_name (struct gdbarch *gdbarch, - gdbarch_address_class_type_flags_to_name_ftype address_class_type_flags_to_name) +set_gdbarch_address_class_id_to_name (struct gdbarch *gdbarch, + gdbarch_address_class_id_to_name_ftype address_class_id_to_name) { - gdbarch->address_class_type_flags_to_name = address_class_type_flags_to_name; + gdbarch->address_class_id_to_name = address_class_id_to_name; } bool diff --git a/gdb/gdbarch-gen.h b/gdb/gdbarch-gen.h index 678b308fba5..9fea082a690 100644 --- a/gdb/gdbarch-gen.h +++ b/gdb/gdbarch-gen.h @@ -902,11 +902,14 @@ using gdbarch_address_class_type_flags_ftype = type_instance_flags (int byte_siz type_instance_flags gdbarch_address_class_type_flags (struct gdbarch *gdbarch, int byte_size, int dwarf2_addr_class); void set_gdbarch_address_class_type_flags (struct gdbarch *gdbarch, gdbarch_address_class_type_flags_ftype *address_class_type_flags); -bool gdbarch_address_class_type_flags_to_name_p (struct gdbarch *gdbarch); +/* Given an architecture-specific address class identifier, return the + name of that address class. */ -using gdbarch_address_class_type_flags_to_name_ftype = const char *(struct gdbarch *gdbarch, type_instance_flags type_flags); -const char *gdbarch_address_class_type_flags_to_name (struct gdbarch *gdbarch, type_instance_flags type_flags); -void set_gdbarch_address_class_type_flags_to_name (struct gdbarch *gdbarch, gdbarch_address_class_type_flags_to_name_ftype *address_class_type_flags_to_name); +bool gdbarch_address_class_id_to_name_p (struct gdbarch *gdbarch); + +using gdbarch_address_class_id_to_name_ftype = const char *(struct gdbarch *gdbarch, unsigned int address_class); +const char *gdbarch_address_class_id_to_name (struct gdbarch *gdbarch, unsigned int address_class); +void set_gdbarch_address_class_id_to_name (struct gdbarch *gdbarch, gdbarch_address_class_id_to_name_ftype *address_class_id_to_name); /* Execute vendor-specific DWARF Call Frame Instruction. OP is the instruction. FS are passed from the generic execute_cfa_program function. */ diff --git a/gdb/gdbarch_components.py b/gdb/gdbarch_components.py index b9304d3036d..5ec4bdee819 100644 --- a/gdb/gdbarch_components.py +++ b/gdb/gdbarch_components.py @@ -1546,9 +1546,13 @@ Function( ) Method( + comment=""" +Given an architecture-specific address class identifier, return the +name of that address class. +""", type="const char *", - name="address_class_type_flags_to_name", - params=[("type_instance_flags", "type_flags")], + name="address_class_id_to_name", + params=[("unsigned int", "address_class")], predicate=True, ) diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index d1a2914e1e6..f3c77073f70 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -570,9 +570,11 @@ address_space_type_instance_flags_to_name (struct gdbarch *gdbarch, return "code"; else if (space_flag & TYPE_INSTANCE_FLAG_DATA_SPACE) return "data"; - else if ((space_flag & TYPE_INSTANCE_FLAG_ADDRESS_CLASS_ALL) - && gdbarch_address_class_type_flags_to_name_p (gdbarch)) - return gdbarch_address_class_type_flags_to_name (gdbarch, space_flag); + + unsigned int aclass = TYPE_ADDRESS_CLASS_FROM_INSTANCE_FLAGS (space_flag); + + if (gdbarch_address_class_id_to_name_p (gdbarch)) + return gdbarch_address_class_id_to_name (gdbarch, aclass); else return NULL; } diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index 572bf6d3d6f..3c21d4ad214 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -175,6 +175,10 @@ DEF_ENUM_FLAGS_TYPE (enum type_instance_flag_value, type_instance_flags); (TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1 | TYPE_INSTANCE_FLAG_ADDRESS_CLASS_2) #define TYPE_ADDRESS_CLASS_ALL(t) (((t)->instance_flags ()) \ & TYPE_INSTANCE_FLAG_ADDRESS_CLASS_ALL) +#define TYPE_ADDRESS_CLASS_FROM_INSTANCE_FLAGS(t) \ + ((unsigned int) ((t) & TYPE_INSTANCE_FLAG_ADDRESS_CLASS_ALL) >> 4) +#define TYPE_ADDRESS_CLASS(t) \ + (TYPE_ADDRESS_CLASS_FROM_INSTANCE_FLAGS ((t)->instance_flags ())) /* Information about a single discriminant. */ diff --git a/gdb/s390-tdep.c b/gdb/s390-tdep.c index f74e55284c0..57ddce44644 100644 --- a/gdb/s390-tdep.c +++ b/gdb/s390-tdep.c @@ -1619,14 +1619,14 @@ s390_address_class_type_flags (int byte_size, int dwarf2_addr_class) return 0; } -/* Implement addr_class_type_flags_to_name gdbarch method. +/* Implement addr_class_id_to_name gdbarch method. Only used for ABI_LINUX_ZSERIES. */ static const char * -s390_address_class_type_flags_to_name (struct gdbarch *gdbarch, - type_instance_flags type_flags) +s390_address_class_id_to_name (struct gdbarch *gdbarch, + unsigned int address_class) { - if (type_flags & TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1) + if (address_class == 1) return "mode32"; else return NULL; @@ -7357,8 +7357,8 @@ s390_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) set_gdbarch_ptr_bit (gdbarch, 64); set_gdbarch_address_class_type_flags (gdbarch, s390_address_class_type_flags); - set_gdbarch_address_class_type_flags_to_name (gdbarch, - s390_address_class_type_flags_to_name); + set_gdbarch_address_class_id_to_name (gdbarch, + s390_address_class_id_to_name); set_gdbarch_address_class_name_to_type_flags (gdbarch, s390_address_class_name_to_type_flags); break; -- 2.34.1