From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by sourceware.org (Postfix) with ESMTPS id EC455385C317 for ; Fri, 21 Oct 2022 09:28:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org EC455385C317 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=oracle.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=oracle.com Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 29L7n5fg006658 for ; Fri, 21 Oct 2022 09:28:38 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=message-id : date : subject : to : cc : references : from : in-reply-to : content-type : content-transfer-encoding : mime-version; s=corp-2022-7-12; bh=NtjX6z4YFTMLR6KogSSuQ6DVx6Gc5dM+JAssqDUalKs=; b=o2nrJ2UjRhQWTlyQ9ycb7suhbBf5Jt8XtzIlhW2dIjxgtFmYcfme8FvqZOPyLdIEB4D4 mSv/BDFi3voj8RQ2yE7iDVaMmXuhe3c1HRUyQK0PN1FwJOynpotZ82bAW/sXcGqFSfM2 sgdLADL1SzNpT/fO59WmajpESJgTec0rkZTmEnLLkqSC5aFXFfStoEcVKRrWR+oKS4u2 Wh0CkY8trfRsJIiGLC7rYK1K0TtirtFR76ESnB6CIjEZb75nkL4HxqSYYrh+TvchhZvU uopa6a9Zj1bUw4yQQWFyYm1HEQ9bzpMibd+EJtHPEvLFCzEMuEQERqh8sxUxQqHYsunT HQ== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3k7mu0812s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 21 Oct 2022 09:28:37 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 29L8catC027653 for ; Fri, 21 Oct 2022 09:28:37 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2104.outbound.protection.outlook.com [104.47.70.104]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3k8htkedf4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 21 Oct 2022 09:28:37 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NL2yJD0m/jXvQW46X6sgQuCicDgnmIou5SAm297LdkeZOPNKGNvgYY3k7TfDjDY7x6RIyVQSI9wKan1yJeKy4+njMoBo6csY9obM2Asp+NVDr6oFzxejgZVZI3uSQX3lPDlnmly1peYpy5e+9MCREZJTfqne1o+xYvsGyhCqII6ubg2xsR5+RChXZOLDXg08Gjyt7WftSqU8FzXP6HgzNe2iWOgam10sxfja1dfIhGRNRHJ7RuV3GqlKwYyH9EWMxweJX9lnvI6YcJMHyBK0DrxHRrH623CguXXJF2BXEns9jo/r/74cfTvGeDwn5WBYpuDU+qLC32LMbJHLJsH10Q== 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=NtjX6z4YFTMLR6KogSSuQ6DVx6Gc5dM+JAssqDUalKs=; b=Z7CPU/s79Nk3wDmhH44YbejU/cjJaZDy4a3hZ4SKbWbCZCsu0fus1YcdHcNzhw2Y0Q7upVDHlI+Os+q+eFwsINI2k3S5Sg4xvhBKJM2lS71pLqkDLzqZ/k/dF5L3wOrpiEy1Eky0P4nL8UzdhHWMXGdSNeLfBBoVZPnalhxcGF9S3FPSsgsDRxKBF8BpcT2gsrz6OuOsCQDhxssXzZurw8CVc02u4w5E25+xeUA13bJ/lNq5IZSFgUgn1tTolPrvwP8I0jGmopG5H9b9Vvr4SOShuFoqV4bLbe4+MpxGo2yV/Oy9SadmO0V0+zS/JqJir99QR0xWJ742YE/6E7cI6g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=NtjX6z4YFTMLR6KogSSuQ6DVx6Gc5dM+JAssqDUalKs=; b=R92q591HYAYpMHbAYvFc66T/g4bonTd9wid05m0KR0MXdkOP3IAPzchghYgFUuMK4Bd5kuXkgdqOhYxYN5BNLndM8sjk5fUro+zCZJ5BTLcvNyrBH6Rrp3fBS9mlkZPyVXvo4pgRsr1DheuoAN1U2H1YINxyOkHtt+DHVgd+XQI= Received: from MWHPR1001MB2158.namprd10.prod.outlook.com (2603:10b6:301:2d::17) by PH0PR10MB4568.namprd10.prod.outlook.com (2603:10b6:510:41::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.30; Fri, 21 Oct 2022 09:28:35 +0000 Received: from MWHPR1001MB2158.namprd10.prod.outlook.com ([fe80::a505:15c2:a248:efa2]) by MWHPR1001MB2158.namprd10.prod.outlook.com ([fe80::a505:15c2:a248:efa2%7]) with mapi id 15.20.5723.033; Fri, 21 Oct 2022 09:28:35 +0000 Message-ID: <9a5675fa-64c3-2abb-5125-2db20f60a7fd@oracle.com> Date: Fri, 21 Oct 2022 02:28:31 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.1 Subject: Re: [PATCH v4] btf: Add support to BTF_KIND_ENUM64 type To: "Guillermo E. Martinez" , gcc-patches@gcc.gnu.org Cc: david.faust@oracle.com References: <20221015035548.274704-1-guillermo.e.martinez@oracle.com> <20221020020507.616781-1-guillermo.e.martinez@oracle.com> Content-Language: en-US From: Indu Bhagat In-Reply-To: <20221020020507.616781-1-guillermo.e.martinez@oracle.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: MW4PR03CA0043.namprd03.prod.outlook.com (2603:10b6:303:8e::18) To MWHPR1001MB2158.namprd10.prod.outlook.com (2603:10b6:301:2d::17) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWHPR1001MB2158:EE_|PH0PR10MB4568:EE_ X-MS-Office365-Filtering-Correlation-Id: 9437207b-2c91-4873-4a1d-08dab3469fc7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: HlIh+rnOs631pojOomLacuMTFToW/k9ApoDl4qGzdMMt9+gQExyNNRbXtPpuXs1fZ8HWa8F534CnAHZduUTWE8IBPtLyH0JrjbLfOrF4Xi9eOTXiyb9HdK5N0R4wi6fNMpPr8O8OwXKpQ2Q1vMCRUQvLjRWrA3W1e1QtnFn5GdnEcgFiKZjMVzZBSKgC/1XECfJk/mqvUpm8X+K+I85WF/4IlcrqRVit0EirqUqyFUhnqri5gY0mEHEUm1qlaT9+Twpt++8HCdJ6ZZJPCf3nddVZGnyEDEiDfj0nsGrb0IIqI9D7yo9M6TNqxauXGyDeJ29C/RO3bEnp7EdCU15ILFyx2nvN2Fv/TxkXMHs15UbguiP1yAL/KWeXNMfbQhONO++otie6HKrMJI5eajfd7gauSw7fAQbd9Kkpdltv1YXVvKgRNF7ZLxrNGgyLY3u3f86XhPyqaKvIxXe2lSO1ve/CQ56eknNDRsWEcf0HZlOaA3CU5DwYgL7HGigNePhixkbj+uJDKbXq1csrF2ovLdZYAig4Yi+QX84MOl4apYV0jrphtfVcr8SghUaA211NnP60nWN1yq06kZHSnMhgbjZVFCguCPI20VzgHNka4d6jiSDv+Uf6qlq9Ho7WAN+kbW54nMjh9MuD+T4zuHs0fznbVOeWSjsXjAeCG3d1YvqxwJDPq622IdjcZswvPM0MCdgmGgYut9F57Wn0KUei3p4yUZ52oBOxkt/XT8YFxqraNGR51cuToBvjX/MC2UIpzozTj4tRNybM1gQiCPFxljkPh5KXR0MPuHRlAyezLfy8OTnbyIrXVZHIv81U95SzF843xYEgsAQnXMHNaCkAMqHZ51+jc1uEIjJ9xrHZnF4= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MWHPR1001MB2158.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(376002)(366004)(346002)(396003)(39860400002)(136003)(451199015)(41300700001)(53546011)(8676002)(478600001)(83380400001)(31696002)(30864003)(86362001)(2616005)(44832011)(186003)(2906002)(8936002)(107886003)(6506007)(316002)(6486002)(6666004)(6512007)(4326008)(5660300002)(66476007)(66946007)(66556008)(66899015)(36756003)(31686004)(84970400001)(38100700002)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?QnJiZ0p3eFFiTnJxc0pWOHYrNVlWTGFaUFhYajRKS3ViMFdUWWFkaFh6UmpP?= =?utf-8?B?dFNwN0EvQjBrYWNsOUV1aGkyYmZ4OUdreFQ1cWFzcHRJRWhEd1ZJZTRWS2V4?= =?utf-8?B?MkljS25taFNONEp6eUIrMUllcUFGbDdZWHZUM05PcjY2ZTEwS2gxOFhsWVhm?= =?utf-8?B?c05T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adkZZK2tw?= =?utf-8?B?Ni81bEtPWEtjbHZkQUZRQmUzWlJvSk5EcEFwVElUSHlITVFzRFRJYS9qNSsw?= =?utf-8?B?MzhVM1V4MGtsVzFVMGx1VlMwM05kQTdEeG5XWVJSR0Z1bklEUVc2S3dsckF3?= =?utf-8?B?clptemZ5OVp4cVN1TTFleUwxaENnUmRFZjNySHRXNXNIWDc5azVBWWx5QXha?= =?utf-8?Q?7YUl13N1IpaEDTnwtXPUsXM=3D?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9437207b-2c91-4873-4a1d-08dab3469fc7 X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2158.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2022 09:28:35.2940 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Z1LbwkjVJWItQ3068L88hN/NZSsCVWrwVB9g6WT3MrOpiUHYTK328AjaRUFuLM8yAa0RR0u3IyHVo2E2jGk06w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4568 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-10-21_04,2022-10-20_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 phishscore=0 suspectscore=0 spamscore=0 adultscore=0 mlxscore=0 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210210055 X-Proofpoint-ORIG-GUID: S5_jNW0flyDW4LMeCY9upIHHuf8nrXZS X-Proofpoint-GUID: S5_jNW0flyDW4LMeCY9upIHHuf8nrXZS X-Spam-Status: No, score=-13.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,NICE_REPLY_A,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 10/19/22 19:05, Guillermo E. Martinez wrote: > Hello, > > The following is patch v4 to update BTF/CTF backend supporting > BTF_KIND_ENUM64 type. Changes from v3: > > + Remove `ctf_enum_binfo' structure. > + Remove -m{little,big}-endian from dg-options in testcase. > > Comments will be welcomed and appreciated!, > > Kind regards, > guillermo > -- > Thanks Guillermo. LGTM. > BTF supports 64-bits enumerators with following encoding: > > struct btf_type: > name_off: 0 or offset to a valid C identifier > info.kind_flag: 0 for unsigned, 1 for signed > info.kind: BTF_KIND_ENUM64 > info.vlen: number of enum values > size: 1/2/4/8 > > The btf_type is followed by info.vlen number of: > > struct btf_enum64 > { > uint32_t name_off; /* Offset in string section of enumerator name. */ > uint32_t val_lo32; /* lower 32-bit value for a 64-bit value Enumerator */ > uint32_t val_hi32; /* high 32-bit value for a 64-bit value Enumerator */ > }; > > So, a new btf_enum64 structure was added to represent BTF_KIND_ENUM64 > and a new field dtd_enum_unsigned in ctf_dtdef structure to distinguish > when CTF enum is a signed or unsigned type, later that information is > used to encode the BTF enum type. > > gcc/ChangeLog: > > * btfout.cc (btf_calc_num_vbytes): Compute enumeration size depending of > enumerator type btf_enum{,64}. > (btf_asm_type): Update btf_kflag according to enumeration type sign > using dtd_enum_unsigned field for both: BTF_KIND_ENUM{,64}. > (btf_asm_enum_const): New argument to represent the size of > the BTF enum type, writing the enumerator constant value for > 32 bits, if it's 64 bits then explicitly writes lower 32-bits > value and higher 32-bits value. > (output_asm_btf_enum_list): Add enumeration size argument. > * ctfc.cc (ctf_add_enum): New argument to represent CTF enum > basic information. > (ctf_add_generic): Use of ei_{name. size, unsigned} to build the > dtd structure containing enumeration information. > (ctf_add_enumerator): Update comment mention support for BTF > enumeration in 64-bits. > * dwarf2ctf.cc (gen_ctf_enumeration_type): Extract signedness > for enumeration type and use it in ctf_add_enum. > * ctfc.h (ctf_dmdef): Update dmd_value to HOST_WIDE_INT to allow > use 32/64 bits enumerators. > information. > (ctf_dtdef): New field to describe enum signedness. > > include/ > * btf.h (btf_enum64): Add new definition and new symbolic > constant to BTF_KIND_ENUM64 and BTF_KF_ENUM_{UN,}SIGNED. > > gcc/testsuite/ChangeLog: > > * gcc.dg/debug/btf/btf-enum-1.c: Update testcase, with correct > info.kflags encoding. > * gcc.dg/debug/btf/btf-enum64-1.c: New testcase. > --- > gcc/btfout.cc | 30 ++++++++++--- > gcc/ctfc.cc | 13 +++--- > gcc/ctfc.h | 5 ++- > gcc/dwarf2ctf.cc | 5 ++- > gcc/testsuite/gcc.dg/debug/btf/btf-enum-1.c | 2 +- > gcc/testsuite/gcc.dg/debug/btf/btf-enum64-1.c | 44 +++++++++++++++++++ > include/btf.h | 19 ++++++-- > 7 files changed, 100 insertions(+), 18 deletions(-) > create mode 100644 gcc/testsuite/gcc.dg/debug/btf/btf-enum64-1.c > > diff --git a/gcc/btfout.cc b/gcc/btfout.cc > index 997a33fa089..aef9fd70a28 100644 > --- a/gcc/btfout.cc > +++ b/gcc/btfout.cc > @@ -223,7 +223,9 @@ btf_calc_num_vbytes (ctf_dtdef_ref dtd) > break; > > case BTF_KIND_ENUM: > - vlen_bytes += vlen * sizeof (struct btf_enum); > + vlen_bytes += (dtd->dtd_data.ctti_size == 0x8) > + ? vlen * sizeof (struct btf_enum64) > + : vlen * sizeof (struct btf_enum); > break; > > case BTF_KIND_FUNC_PROTO: > @@ -622,6 +624,15 @@ btf_asm_type (ctf_container_ref ctfc, ctf_dtdef_ref dtd) > btf_size_type = 0; > } > > + if (btf_kind == BTF_KIND_ENUM) > + { > + btf_kflag = dtd->dtd_enum_unsigned > + ? BTF_KF_ENUM_UNSIGNED > + : BTF_KF_ENUM_SIGNED; > + if (dtd->dtd_data.ctti_size == 0x8) > + btf_kind = BTF_KIND_ENUM64; > + } > + > dw2_asm_output_data (4, dtd->dtd_data.ctti_name, "btt_name"); > dw2_asm_output_data (4, BTF_TYPE_INFO (btf_kind, btf_kflag, btf_vlen), > "btt_info: kind=%u, kflag=%u, vlen=%u", > @@ -634,6 +645,7 @@ btf_asm_type (ctf_container_ref ctfc, ctf_dtdef_ref dtd) > case BTF_KIND_UNION: > case BTF_KIND_ENUM: > case BTF_KIND_DATASEC: > + case BTF_KIND_ENUM64: > dw2_asm_output_data (4, dtd->dtd_data.ctti_size, "btt_size: %uB", > dtd->dtd_data.ctti_size); > return; > @@ -707,13 +719,19 @@ btf_asm_sou_member (ctf_container_ref ctfc, ctf_dmdef_t * dmd) > } > } > > -/* Asm'out an enum constant following a BTF_KIND_ENUM. */ > +/* Asm'out an enum constant following a BTF_KIND_ENUM{,64}. */ > > static void > -btf_asm_enum_const (ctf_dmdef_t * dmd) > +btf_asm_enum_const (unsigned int size, ctf_dmdef_t * dmd) > { > dw2_asm_output_data (4, dmd->dmd_name_offset, "bte_name"); > - dw2_asm_output_data (4, dmd->dmd_value, "bte_value"); > + if (size == 4) > + dw2_asm_output_data (size, dmd->dmd_value, "bte_value"); > + else > + { > + dw2_asm_output_data (4, dmd->dmd_value & 0xffffffff, "bte_value_lo32"); > + dw2_asm_output_data (4, (dmd->dmd_value >> 32) & 0xffffffff, "bte_value_hi32"); > + } > } > > /* Asm'out a function parameter description following a BTF_KIND_FUNC_PROTO. */ > @@ -871,7 +889,7 @@ output_asm_btf_sou_fields (ctf_container_ref ctfc, ctf_dtdef_ref dtd) > btf_asm_sou_member (ctfc, dmd); > } > > -/* Output all enumerator constants following a BTF_KIND_ENUM. */ > +/* Output all enumerator constants following a BTF_KIND_ENUM{,64}. */ > > static void > output_asm_btf_enum_list (ctf_container_ref ARG_UNUSED (ctfc), > @@ -881,7 +899,7 @@ output_asm_btf_enum_list (ctf_container_ref ARG_UNUSED (ctfc), > > for (dmd = dtd->dtd_u.dtu_members; > dmd != NULL; dmd = (ctf_dmdef_t *) ctf_dmd_list_next (dmd)) > - btf_asm_enum_const (dmd); > + btf_asm_enum_const (dtd->dtd_data.ctti_size, dmd); > } > > /* Output all function arguments following a BTF_KIND_FUNC_PROTO. */ > diff --git a/gcc/ctfc.cc b/gcc/ctfc.cc > index 9773358a475..34030cbaa49 100644 > --- a/gcc/ctfc.cc > +++ b/gcc/ctfc.cc > @@ -577,7 +577,7 @@ ctf_add_array (ctf_container_ref ctfc, uint32_t flag, const ctf_arinfo_t * arp, > > ctf_id_t > ctf_add_enum (ctf_container_ref ctfc, uint32_t flag, const char * name, > - HOST_WIDE_INT size, dw_die_ref die) > + HOST_WIDE_INT size, bool eunsigned, dw_die_ref die) > { > ctf_dtdef_ref dtd; > ctf_id_t type; > @@ -604,6 +604,7 @@ ctf_add_enum (ctf_container_ref ctfc, uint32_t flag, const char * name, > gcc_assert (size <= CTF_MAX_SIZE); > > dtd->dtd_data.ctti_size = size; > + dtd->dtd_enum_unsigned = eunsigned; > > ctfc->ctfc_num_stypes++; > > @@ -630,10 +631,12 @@ ctf_add_enumerator (ctf_container_ref ctfc, ctf_id_t enid, const char * name, > > gcc_assert (kind == CTF_K_ENUM && vlen < CTF_MAX_VLEN); > > - /* Enum value is of type HOST_WIDE_INT in the compiler, dmd_value is int32_t > - on the other hand. Check bounds and skip adding this enum value if out of > - bounds. */ > - if ((value > INT_MAX) || (value < INT_MIN)) > + /* Enum value is of type HOST_WIDE_INT in the compiler, CTF enumerators > + values in ctf_enum_t is limited to int32_t, BTF supports signed and > + unsigned enumerators values of 32 and 64 bits, for both debug formats > + we use ctf_dmdef_t.dmd_value entry of HOST_WIDE_INT type. So check > + CTF bounds and skip adding this enum value if out of bounds. */ > + if (!btf_debuginfo_p() && ((value > INT_MAX) || (value < INT_MIN))) > { > /* FIXME - Note this TBD_CTF_REPRESENTATION_LIMIT. */ > return (1); > diff --git a/gcc/ctfc.h b/gcc/ctfc.h > index bcf3a43ae1b..48c381a008d 100644 > --- a/gcc/ctfc.h > +++ b/gcc/ctfc.h > @@ -133,7 +133,7 @@ typedef struct GTY ((chain_next ("%h.dmd_next"))) ctf_dmdef > ctf_id_t dmd_type; /* Type of this member (for sou). */ > uint32_t dmd_name_offset; /* Offset of the name in str table. */ > uint64_t dmd_offset; /* Offset of this member in bits (for sou). */ > - int dmd_value; /* Value of this member (for enum). */ > + HOST_WIDE_INT dmd_value; /* Value of this member (for enum). */ > struct ctf_dmdef * dmd_next; /* A list node. */ > } ctf_dmdef_t; > > @@ -162,6 +162,7 @@ struct GTY ((for_user)) ctf_dtdef > bool from_global_func; /* Whether this type was added from a global > function. */ > uint32_t linkage; /* Used in function types. 0=local, 1=global. */ > + bool dtd_enum_unsigned; /* Enum signedness. */ > union GTY ((desc ("ctf_dtu_d_union_selector (&%1)"))) > { > /* struct, union, or enum. */ > @@ -406,7 +407,7 @@ extern const char * ctf_add_string (ctf_container_ref, const char *, > extern ctf_id_t ctf_add_reftype (ctf_container_ref, uint32_t, ctf_id_t, > uint32_t, dw_die_ref); > extern ctf_id_t ctf_add_enum (ctf_container_ref, uint32_t, const char *, > - HOST_WIDE_INT, dw_die_ref); > + HOST_WIDE_INT, bool, dw_die_ref); > extern ctf_id_t ctf_add_slice (ctf_container_ref, uint32_t, ctf_id_t, > uint32_t, uint32_t, dw_die_ref); > extern ctf_id_t ctf_add_float (ctf_container_ref, uint32_t, const char *, > diff --git a/gcc/dwarf2ctf.cc b/gcc/dwarf2ctf.cc > index 397100004c2..748dd0cd8af 100644 > --- a/gcc/dwarf2ctf.cc > +++ b/gcc/dwarf2ctf.cc > @@ -736,6 +736,7 @@ gen_ctf_enumeration_type (ctf_container_ref ctfc, dw_die_ref enumeration) > { > const char *enum_name = get_AT_string (enumeration, DW_AT_name); > unsigned int bit_size = ctf_die_bitsize (enumeration); > + unsigned int signedness = get_AT_unsigned (enumeration, DW_AT_encoding); > int declaration_p = get_AT_flag (enumeration, DW_AT_declaration); > > ctf_id_t enumeration_type_id; > @@ -759,7 +760,9 @@ gen_ctf_enumeration_type (ctf_container_ref ctfc, dw_die_ref enumeration) > > /* Generate a CTF type for the enumeration. */ > enumeration_type_id = ctf_add_enum (ctfc, CTF_ADD_ROOT, > - enum_name, bit_size / 8, enumeration); > + enum_name, bit_size / 8, > + (signedness == DW_ATE_unsigned), > + enumeration); > > /* Process the enumerators. */ > { > diff --git a/gcc/testsuite/gcc.dg/debug/btf/btf-enum-1.c b/gcc/testsuite/gcc.dg/debug/btf/btf-enum-1.c > index 728493b0804..7e940529f1b 100644 > --- a/gcc/testsuite/gcc.dg/debug/btf/btf-enum-1.c > +++ b/gcc/testsuite/gcc.dg/debug/btf/btf-enum-1.c > @@ -4,7 +4,7 @@ > /* { dg-options "-O0 -gbtf -dA" } */ > > /* { dg-final { scan-assembler-times "\[\t \]0x6000004\[\t \]+\[^\n\]*btt_info" 1 } } */ > -/* { dg-final { scan-assembler-times "\[\t \]0x6000003\[\t \]+\[^\n\]*btt_info" 1 } } */ > +/* { dg-final { scan-assembler-times "\[\t \]0x86000003\[\t \]+\[^\n\]*btt_info" 1 } } */ > /* { dg-final { scan-assembler-times "ascii \"QAD.0\"\[\t \]+\[^\n\]*btf_string" 1 } } */ > /* { dg-final { scan-assembler-times "ascii \"QED.0\"\[\t \]+\[^\n\]*btf_string" 1 } } */ > /* { dg-final { scan-assembler-times "ascii \"QOD.0\"\[\t \]+\[^\n\]*btf_string" 1 } } */ > diff --git a/gcc/testsuite/gcc.dg/debug/btf/btf-enum64-1.c b/gcc/testsuite/gcc.dg/debug/btf/btf-enum64-1.c > new file mode 100644 > index 00000000000..e443d4c8c00 > --- /dev/null > +++ b/gcc/testsuite/gcc.dg/debug/btf/btf-enum64-1.c > @@ -0,0 +1,44 @@ > +/* Test BTF generation for 64 bits enums. */ > + > +/* { dg-do compile } */ > +/* { dg-options "-O0 -gbtf -dA" } */ > + > +/* { dg-final { scan-assembler-times "\[\t \].size\[\t \]myenum1,\[\t \]8" 1 } } */ > +/* { dg-final { scan-assembler-times "\[\t \].size\[\t \]myenum2,\[\t \]8" 1 } } */ > +/* { dg-final { scan-assembler-times "\[\t \].size\[\t \]myenum3,\[\t \]8" 1 } } */ > +/* { dg-final { scan-assembler-times "\[\t \]0x13000003\[\t \]+\[^\n\]*btt_info" 2 } } */ > +/* { dg-final { scan-assembler-times "\[\t \]0x93000003\[\t \]+\[^\n\]*btt_info" 1 } } */ > +/* { dg-final { scan-assembler-times "\[\t \]0xffffffaa\[\t \]+\[^\n\]*bte_value_lo32" 2 } } */ > +/* { dg-final { scan-assembler-times "\[\t \]0xff\[\t \]+\[^\n\]*bte_value_hi32" 3 } } */ > +/* { dg-final { scan-assembler-times "ascii \"B1.0\"\[\t \]+\[^\n\]*btf_string" 1 } } */ > +/* { dg-final { scan-assembler-times "ascii \"B2.0\"\[\t \]+\[^\n\]*btf_string" 1 } } */ > +/* { dg-final { scan-assembler-times "ascii \"B3.0\"\[\t \]+\[^\n\]*btf_string" 1 } } */ > +/* { dg-final { scan-assembler-times "ascii \"C1.0\"\[\t \]+\[^\n\]*btf_string" 1 } } */ > +/* { dg-final { scan-assembler-times "ascii \"C2.0\"\[\t \]+\[^\n\]*btf_string" 1 } } */ > +/* { dg-final { scan-assembler-times "ascii \"C3.0\"\[\t \]+\[^\n\]*btf_string" 1 } } */ > +/* { dg-final { scan-assembler-times "ascii \"D1.0\"\[\t \]+\[^\n\]*btf_string" 1 } } */ > +/* { dg-final { scan-assembler-times "ascii \"D2.0\"\[\t \]+\[^\n\]*btf_string" 1 } } */ > +/* { dg-final { scan-assembler-times "ascii \"D3.0\"\[\t \]+\[^\n\]*btf_string" 1 } } */ > +/* { dg-final { scan-assembler-times "bte_value_lo32" 9 } } */ > +/* { dg-final { scan-assembler-times "bte_value_hi32" 9 } } */ > + > +enum default_enum > +{ > + B1 = 0xffffffffaa, > + B2 = 0xbbbbbbbb, > + B3 = 0xaabbccdd, > +} myenum1 = B1; > + > +enum explicit_unsigned > +{ > + C1 = 0xffffffffbbUL, > + C2 = 0xbbbbbbbb, > + C3 = 0xaabbccdd, > +} myenum2 = C1; > + > +enum signed64 > +{ > + D1 = 0xffffffffaa, > + D2 = 0xbbbbbbbb, > + D3 = -0x1, > +} myenum3 = D1; > diff --git a/include/btf.h b/include/btf.h > index 78b551ced23..eba67f9d599 100644 > --- a/include/btf.h > +++ b/include/btf.h > @@ -109,7 +109,8 @@ struct btf_type > #define BTF_KIND_VAR 14 /* Variable. */ > #define BTF_KIND_DATASEC 15 /* Section such as .bss or .data. */ > #define BTF_KIND_FLOAT 16 /* Floating point. */ > -#define BTF_KIND_MAX BTF_KIND_FLOAT > +#define BTF_KIND_ENUM64 19 /* Enumeration up to 64 bits. */ > +#define BTF_KIND_MAX BTF_KIND_ENUM64 > #define NR_BTF_KINDS (BTF_KIND_MAX + 1) > > /* For some BTF_KINDs, struct btf_type is immediately followed by > @@ -130,14 +131,17 @@ struct btf_type > #define BTF_INT_BOOL (1 << 2) > > /* BTF_KIND_ENUM is followed by VLEN struct btf_enum entries, > - which describe the enumerators. Note that BTF currently only > - supports signed 32-bit enumerator values. */ > + which describe the enumerators. */ > struct btf_enum > { > uint32_t name_off; /* Offset in string section of enumerator name. */ > int32_t val; /* Enumerator value. */ > }; > > +/* BTF_KF_ENUM_ holds the flags for kflags in BTF_KIND_ENUM{,64}. */ > +#define BTF_KF_ENUM_UNSIGNED (0) > +#define BTF_KF_ENUM_SIGNED (1 << 0) > + > /* BTF_KIND_ARRAY is followed by a single struct btf_array. */ > struct btf_array > { > @@ -190,6 +194,15 @@ struct btf_var_secinfo > uint32_t size; /* Size (in bytes) of variable. */ > }; > > +/* BTF_KIND_ENUM64 is followed by VLEN struct btf_enum64 entries, > + which describe the 64 bits enumerators. */ > +struct btf_enum64 > +{ > + uint32_t name_off; /* Offset in string section of enumerator name. */ > + uint32_t val_lo32; /* lower 32-bit value for a 64-bit value Enumerator */ > + uint32_t val_hi32; /* high 32-bit value for a 64-bit value Enumerator */ > +}; > + > #ifdef __cplusplus > } > #endif