From patchwork Tue May 30 18:27:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Faust X-Patchwork-Id: 1787839 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=UN1xGeKM; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QW19C5PKbz20Q4 for ; Wed, 31 May 2023 04:27:58 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3B8523856976 for ; Tue, 30 May 2023 18:27:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3B8523856976 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1685471271; bh=vNSH2kq+H2fiPVCXLtqEBuolRiGkXrjqpWANZC+CcLA=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=UN1xGeKMpvrPb2y0xF66zPOcJZAy0Iyo4JlYYav5ji+EiGu6PQm2jEUMrnOyaUpN2 /jYm6bKDWdvYLUJeZnDO51I73t1YBVyudzctVikcNFuXzFv3ggMtdeE4263oLf2WgD StUb7qr6x87iAnlvGyn19YbvXS/dfupURnTpFZ/4= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by sourceware.org (Postfix) with ESMTPS id 0FAC33858D20 for ; Tue, 30 May 2023 18:27:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0FAC33858D20 Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 34UE45PQ002519 for ; Tue, 30 May 2023 18:27:30 GMT Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3qvhd9ujw2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 30 May 2023 18:27:30 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 34UI6UEH019757 for ; Tue, 30 May 2023 18:27:29 GMT Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2104.outbound.protection.outlook.com [104.47.55.104]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3qu8a4hket-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 30 May 2023 18:27:29 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gwtJYdRxS0srhwzMdANFTIhfqwSjn0P4K6AlnQtmYzBF7Kll6gNurHZN2/giYcW4ncklwqHa2UQ9+GYcmAUd4/u6PIlQcbgTiU6pdxUTrGE2VEqVyTK2tnY2UIELxuB9jLcck99oN6ZUY4+WHTFI6Iuw+TqmpMypph0tDAN+LIRRow5ZlBg7zTOenJPVRj5WAvZRHSsa4cIoVcAvCAOVStxa+regpFaAvJVLcdV4goRt7tnY84noSTmBrCyhaIRW1l5X0D8doPoG8OVj8jO2q8A7lz7CIT9psDolt7L/rCn57jlm9zZYAWsAj8R8pG7xfa6d7ZTw25dzuh0AS/KdrA== 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=vNSH2kq+H2fiPVCXLtqEBuolRiGkXrjqpWANZC+CcLA=; b=dQ6iinaYXuwACmEY/hjKp7qL2n58X//ax+0yZBAC4Em1giU58qZl+gZY1nETboJV/bD1wy/LWW3cN4tV3NeF8q/Iz6kMbLLwc3zr+p9ATf5ATzazr63iAKNztfQklj7ZTAY1D7mI2eshmK5KmGR/YXZQXyVOe2JHCuncc/1/SJ/YPVbA0no9FtSaJld0c9/PyoJjpBHgcnufumhDl/DtkH+CQB+QqyS7Yw8G6RQ/ha+adHeKlFU8S/WPFonDUFFVCvrHukEKu5QODZHp5gUUwbErJwUZZ/BRQIEbFK+duLUxFdG9GQaBv29m5Yx8jxgJ6WCkDN0sTHjLmLCd+GA7XA== 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 Received: from MN2PR10MB3213.namprd10.prod.outlook.com (2603:10b6:208:131::33) by SN7PR10MB6620.namprd10.prod.outlook.com (2603:10b6:806:2af::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.22; Tue, 30 May 2023 18:27:27 +0000 Received: from MN2PR10MB3213.namprd10.prod.outlook.com ([fe80::6ff6:bf43:d990:858a]) by MN2PR10MB3213.namprd10.prod.outlook.com ([fe80::6ff6:bf43:d990:858a%3]) with mapi id 15.20.6433.022; Tue, 30 May 2023 18:27:27 +0000 To: gcc-patches@gcc.gnu.org Cc: indu.bhagat@oracle.com Subject: [PATCH 1/2] btf: be clear when record size/type is not used Date: Tue, 30 May 2023 11:27:01 -0700 Message-Id: <20230530182702.8020-1-david.faust@oracle.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230525163740.6062-1-david.faust@oracle.com> References: <20230525163740.6062-1-david.faust@oracle.com> X-ClientProxiedBy: BY5PR04CA0016.namprd04.prod.outlook.com (2603:10b6:a03:1d0::26) To MN2PR10MB3213.namprd10.prod.outlook.com (2603:10b6:208:131::33) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN2PR10MB3213:EE_|SN7PR10MB6620:EE_ X-MS-Office365-Filtering-Correlation-Id: 9e55c707-05e9-4240-1a34-08db613b8539 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QZWIaU5lFZhQjevmh+H9SgvYqu4iAyJtQV3Ny9YEt7uiXA2zVeJfftg0L33Eu54/F0hSuVMMCWXN2kEsTnk22paKsbJMQGWezPzYVtK/YO5qdvcqIgkep1j9RPkuOJ/FVy1HbXt5ARVGAxYLTde3uRwO42XuoDlTc7EjoO9f8VE1PpSsvXcWRHwXwo4OPJM6dYx05To2mjEdzi3fSZ0dIGRdqAsVsWE3MnMYnzQosWdI/TECPQ/71ZNm38tUzXpYSDXLr2LKN/mRYqiC9mhpuCpDeWYs6dzncSOCUwVwxsyYEfvcwHkPLtdeB4NdABbATaYd4/psI6Usp21ouxh1DuKWe9XgpondD1bJeu9kxgRU9gkp4RnDFeB4h3PsRRBBJBIy2077p9WLV8Lcwm1NaRFE9RnYcJ7BzojX5lYSHQMyFbAPJ53poohGzSUeKIwmmO1jOosC1k1UeSGy7aEHbzJjPRnjw+UewGIaOo/9myybdC7WqQF33bRWuUf4W5Tf4ReXN3+H0nED4uWGDmh+Fr4fRpSe7yOu5up8WpmfAsSYPEYGOGBCfAxStQ8knEAJ X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MN2PR10MB3213.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(136003)(39860400002)(396003)(366004)(346002)(376002)(451199021)(6512007)(6506007)(186003)(2616005)(2906002)(26005)(478600001)(1076003)(44832011)(83380400001)(86362001)(8936002)(8676002)(6486002)(41300700001)(38100700002)(66556008)(316002)(6666004)(66476007)(36756003)(66946007)(5660300002)(107886003)(6916009)(4326008); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 2DYQUomg3t0oj5gNOhyEj/TwZnoAcG/eJxLQ2T2Ef02eGsFX99WwQ5Yd4qjDaMrJ058JACmtXGEcOaXv9sNOB99AZ7teSQVgXBrkW4hN+dkjObruWzNAt+6kOw5lGyQ3gWis03BcLtlqF6TmpKu6V1ZGSNArrKelV0LGy9r/7vx88AymxXNT3QN3hzCKm250tKT3S7AqcUElsKrnsQtBtrOfpcUtPlpbkoY33fQM8CjaSk/PgGffQ6ROZp/q8/tw/ir7AmcJkZtkpZ0XX6P4C2XtmXez23DNiHSrwQKaryWRMgy21rmV9mvAs3FBV+fl+XtO4mTUxkgMnUbNaGYX1CGTJb6y1y48dKVlJa+V7v5M6SoBtxVY1t+TphHdvSkDDMFkJg6deF4Cl0eAU5sxKX9CLHjVC0mJ0aHrZz1JV1VAYL4Z9dFFsI5pI2u6+2AjErVu78KoQnivZCP8ihA+77F4F7D7jG8t/xif25Lh4PM/RijCzYY3rGCsrLdtw4Eg1cQLPmWGfkMfjV8i4aiY7yXTO1D2jvWtWsH56Wjb7uSllVu/dz04DM/Nh6tfCN0zLTKsEfuBFCJuDttkmvTD1kfjnaoXPPWlJ5nuEUTYa/w0+6P5bn2ijuLbOp6K4NDoTgC16r1z2C1olGKL8gNCT7O0PoPdzsXwtW2uaA+RdRFQMFBY/GvZlQe2EHI9ldvD+oeImlBu8IC4FFB0v0N1WGH/R0WBaLZU9WY+so9kSKI288eRl6B7fiZ20DSy+HCKu8+vIpmpfkw9rE90aB0iVHC9q6J9JExn6qqZGGxOb6F92wyIB9aGQCotx27yyeQayTf6PfF9AxmE9ujLdldSgl7qXqSvUd/q2PRWb0Nyi3qHIJDB1w3AY7IgBPzvvajIPDaIXPHjm3JtnS6mLYuWvflq4gKGKXFiHysO6nYrYq7Sks+X3OY3zq1H7YH1J0CE4XhSb8DmbYn6WjAJpDOIE9QVtVK+5m+c8Oic9LXZ7rjIQHTt4KUy02T6RUNgmiXH6hEq8qP2EkdNLfSvLLt0zrZ2YY4Cp984k5EEXr/HXO5YqXFQPk3Ld3xY1du0uanmQz1s5nsrD5t+6ez0weZh1c9AbeP9/DKbj2zPvQfS4bqFvxNRVOxM9N0CRXEgjZd2gCCdUK7jyuS0mBFlBv0oMptkTQRFohmYSCTA1/brCF+QkrCHEen/Rn3VnvdyuEL348O+Ij7z7wiC6bou93UkzJOmbreRp0mwFCqkjgADa6ZZl0GolL/hsMWNqbyw0GcyTsDmYKqcgvZEcDmsGMlJrTsuyYNO8luf+eiWn+LUkWT9tI3AGfTxjC8jt1PvAZrlaRF++4X9oJs2CWU14D7iAI/xbFoHmgc7zZ8Unf5KBUQgy+Lm/bIbA2TEAc8UD6Su5J6Hg/oZT5su0xBtm54T/cfLzeRrViT2TuzxiJ+ImmddCR1a3DmQYcfsTOpOSCNxDHWMq/5W5pYdVBg3ptRzoFrhg+SjtfhO1e9YLwYQKXSNIPtP+46NsOUBUqbPBsHRN272wywHDAuNseCn/GS86/+nXCvPdbevfIxRob0WdcrORbmSJyqNhtRNbe7gaaU0 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: BS96X5ohociugLrW0OSlU2aPrg5lHRnUFGzujbIEnD46TmameFpBLPY8URbGKwwwMBNJhtqoq5weT0gROFU5T7QuzGYkdozB5UVQ1OLkRliPZ6OujbHQgJ9MU4N6DAdSilz4y65QIK2JwPHDuU+3Ucyu5C6JSYjLKXRCbAW+8qDDJUJ0LajW+c8Vfe5582azeoscixQLdkgeflANZY1mC6ieriw3STc/l+aRJLeghapjCrYsY2yYZGul2kf8AjpQ5q2zGXAek0RYazaBHkkBpGeyEWV3DSCsKVgdzmB9XNinVIq2kjkBgGnqrMxVAfDFHUlKTkx1kdAcIxXtQWSFJDlEuZWDSxYSfBXKja8lQrShGtCSwIrHLXJfUu6FU+trZp9jZHQP6UC/cshPSFjtOpqZQZK/sxlymHNGHLp2buZQWxVja++gwooL1Q1A5HWfjanWypcEP6GtwocG0nMYAuGOP4hgHGipoO/H4FKxbKDPUtz/QJz1nSjUNAIeQ/RLR012GpvYccMHpiFRUQY/4UhRF2BjrAyoZxbUwAfM10RVpCseZh2XNE3r/8fc9mrRE/Rqgs5AZRQ2o9GbHRg9LyS5tUVS0LbRx/dLMxJVorCmKEnhPeCtkcvYTBTsX8dIJ9bx2toy2E1Y8bGRFcoW7jrUcXpAATKceVURIggqNPIYwToQ1rFR7pWRzHiuxQqibtQAEqovtJs6cbYFGSnYJi9HnRYSiiJ844bJj7o+Lr60K241HnPXNGBy/VBN/nJC X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9e55c707-05e9-4240-1a34-08db613b8539 X-MS-Exchange-CrossTenant-AuthSource: MN2PR10MB3213.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 May 2023 18:27:27.1716 (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: TJZ5NRIbMHX+/kHZhfKIwbynruTfGMR9kf7p6lcFsS8MZ8ITvKRY9zFQCZ5I9I2Kb4ovdi9hiQtSIwNlwe+W5Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR10MB6620 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.176.26 definitions=2023-05-30_14,2023-05-30_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 malwarescore=0 phishscore=0 bulkscore=0 adultscore=0 mlxscore=0 suspectscore=0 mlxlogscore=998 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2304280000 definitions=main-2305300147 X-Proofpoint-GUID: Nb81qlfIVg-EKadlFjWSWdefRX_-T2Zw X-Proofpoint-ORIG-GUID: Nb81qlfIVg-EKadlFjWSWdefRX_-T2Zw 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, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE 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: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: David Faust via Gcc-patches From: David Faust Reply-To: David Faust Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" [Changes from v1: split this change into own commit.] All BTF type records have a 4-byte field used to encode a size or link to another type, depending on the type kind. But BTF_KIND_ARRAY and BTF_KIND_FWD do not use this field at all, and should write zero. GCC already correctly writes zero in this field for these type kinds, but the process is not straightforward and results in the -dA comment claiming the field is a reference to another type. This patch makes the behavior explicit and updates the assembler comment to state clearly that the field is unused. gcc/ * btfout.cc (btf_asm_type): Add dedicated cases for BTF_KIND_ARRAY and BTF_KIND_FWD which do not use the size/type field at all. --- gcc/btfout.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/gcc/btfout.cc b/gcc/btfout.cc index 497c1ca06e6..ae9855716eb 100644 --- a/gcc/btfout.cc +++ b/gcc/btfout.cc @@ -705,6 +705,12 @@ btf_asm_type (ctf_container_ref ctfc, ctf_dtdef_ref dtd) dw2_asm_output_data (4, dtd->dtd_data.ctti_size, "btt_size: %uB", dtd->dtd_data.ctti_size); return; + case BTF_KIND_ARRAY: + case BTF_KIND_FWD: + /* These types do not encode any information in the size/type field + and should write 0. */ + dw2_asm_output_data (4, 0, "(unused)"); + return; default: break; } From patchwork Tue May 30 18:27:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Faust X-Patchwork-Id: 1787841 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=y4bcnmSZ; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QW19K3gvNz20Q4 for ; Wed, 31 May 2023 04:28:05 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7EC653856967 for ; Tue, 30 May 2023 18:28:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7EC653856967 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1685471283; bh=M0TYryEtP6Yuw8Z4nkax3/qt8PA29WD6hHv0H9zCMxg=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=y4bcnmSZ76ZNecX21rLKB6INiXr9+Q9o0xvaekc8H/0B+VZBuavN4XwtmoVlq/QmF NAxiEG/ypfvXeNkECttPRO46iTBsUHZz4R20+tmK9m7ks9kNxODXwZtfuS7HAA1pql DcHmjLnARGkcmG1430NVSc6TZNf+mkCfaJfK5/xc= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by sourceware.org (Postfix) with ESMTPS id 9FA53385770B for ; Tue, 30 May 2023 18:27:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9FA53385770B Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 34UE54dx020891 for ; Tue, 30 May 2023 18:27:37 GMT Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3qvhb93jdh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 30 May 2023 18:27:37 +0000 Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 34UI6ksV003685 for ; Tue, 30 May 2023 18:27:35 GMT Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2100.outbound.protection.outlook.com [104.47.55.100]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3qv4ybvx3h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 30 May 2023 18:27:35 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=J1092z9YWSndRU3OUtman/Q7ilcXpaaryT3+Uc7DmMGhRUqCHMGh7AuHZHCR3BbYtwNFA7eFryagm3QvQIuxQPHKhxBVRgb2Nr1UyJqcuRQyFVjxsy6wQLsPAHMWwXdK0mdXDhvwDitIar7xcpiPJDUpud6NQKohXWAAdjy15jg2RhpH8/bKpTgpsSw5zjSgaV3oFeEagEq96wxRkkk7Enrg2eVVCntoDrnKpDlrv4UIf2rryevuRPcZUA/hq56Wsf9AtG1PHpKK+1bAiS7v1IKBEeFiPOMaRvZqMt86zgv3xGQ+EeC1P33Sez1x/a/vdTprwLaPZnPczS2Esul1+A== 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=M0TYryEtP6Yuw8Z4nkax3/qt8PA29WD6hHv0H9zCMxg=; b=k+FspRMw71p5VnLxSjFYuqJj+qFBBTLt/g10u/d/me7v6VGm2ishEcQBrgkXoyqKHFxEtTv4hNgBRWGQzRDpQ4YmjtrF5PkkUelDDQ9/JXqXKk3lQae6UKu/ekfyv3NpeYLFcaJYXvYmqAfYmwfjUvTduj3pPcURoQufpARPrCLVoFTNqc2B/calAsNhAuBkE7auSMZLYBqkIvJI7luMDaml7Tcqb2lL3SjT28lapC5HNIf83yff2qS1ioVsZoF+iBzKnVReIuZSyPV7DDNN4+BAocUdfV73yGBwLT3FY6/TbrfEZzl2nfr1KHuzeZUYP2qIUagS0o2PTljVdZZ43A== 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 Received: from MN2PR10MB3213.namprd10.prod.outlook.com (2603:10b6:208:131::33) by SN7PR10MB6620.namprd10.prod.outlook.com (2603:10b6:806:2af::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.22; Tue, 30 May 2023 18:27:32 +0000 Received: from MN2PR10MB3213.namprd10.prod.outlook.com ([fe80::6ff6:bf43:d990:858a]) by MN2PR10MB3213.namprd10.prod.outlook.com ([fe80::6ff6:bf43:d990:858a%3]) with mapi id 15.20.6433.022; Tue, 30 May 2023 18:27:32 +0000 To: gcc-patches@gcc.gnu.org Cc: indu.bhagat@oracle.com Subject: [PATCH 2/2] btf: improve -dA comments for testsuite Date: Tue, 30 May 2023 11:27:02 -0700 Message-Id: <20230530182702.8020-2-david.faust@oracle.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230530182702.8020-1-david.faust@oracle.com> References: <20230525163740.6062-1-david.faust@oracle.com> <20230530182702.8020-1-david.faust@oracle.com> X-ClientProxiedBy: BY5PR13CA0015.namprd13.prod.outlook.com (2603:10b6:a03:180::28) To MN2PR10MB3213.namprd10.prod.outlook.com (2603:10b6:208:131::33) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN2PR10MB3213:EE_|SN7PR10MB6620:EE_ X-MS-Office365-Filtering-Correlation-Id: e091aabd-da7a-4fc6-4c4b-08db613b8823 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: UUtQW/xZkMo0aUCRnaXBX8Vr1A3d/om48wu2aR/unM8KjS8dgrh9AEl9/uSpEmswPzZ46x06smA10+Xv3Dl00ww0W/ovq110q5OEZPsdOqsrfFSqX32sfSoBkYM3Yt4igM8F5irylQHlmwQlKuIZ2J1zgJXQOVsLKNa3JRXrpvaUFeJApKnGO8jnerAMQyitAmFOoNvgOLHJ4aDsRn7vCTHXk2jqvmNQGzUwWA3qwOBT0Sl+1iuN/EbUok3TzSBRWTYacBuhCQJyRrhoijAMNNtEdRcJHfA9XdY3Hfq817Mlmid3YhDnLUuRfP0nQkO9fZKqdVJhUMaQZ6GZsbyM9zdnZqmWKWfBgTQGouwEWT3OeKEveUW0BK60YqOQZXbRaeiuuJIMsy4xLGdfw+hKsQ+X+edlKKyoyhqEI8HvO1TxEh23Ij1miwNrcj9QTKDnh7bIi4P/J0ymMVEJS+4pPwPkfLr0SmfTe92kMG6ckGLfCT46oDyQibBxQbt3LSucZ7qxDj8UiOM67CJjBJG87OQp2QwjKhA1ftASVTXNZjo= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MN2PR10MB3213.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(136003)(39860400002)(396003)(366004)(346002)(376002)(451199021)(6512007)(6506007)(186003)(2616005)(2906002)(30864003)(26005)(478600001)(1076003)(84970400001)(44832011)(83380400001)(86362001)(8936002)(8676002)(6486002)(41300700001)(38100700002)(66556008)(316002)(6666004)(66476007)(36756003)(66946007)(5660300002)(107886003)(6916009)(4326008); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: moyIB2NZ//ELyX9g8fRZ1rHrXQmm7OydohSI7Plrzol8AczMlgqsxDa3z+yx6+2MHMquoC7P+QL4ccHKZ97mIQ0hcXzxKYOB8sixYEtBZkwfsnccsYdT2/Crh82B7pAdDlC9iPmZR+kIiWhN+BOMmfuSHcKL3cLejClVqZ9+1Ba3XhRYQiVCItFWCczH+/d5uWUz7I90XjbN/7CpjJxHXzZz4d4nCG1nkmMRkHlVbQn1eYGR96qmosoeU4rtMZKnDh/AymfaPsB7WV7NnYaLh8ebVfWtrGwiDig9vpRvVDTG2OUWX3kHcOxpLSM+3avt/RHmROz0DOJyfOkgSYpjKaIbib503+YhgPTihpx34NG34Dzmzqb+GWfs7yOjA4wRAySFBZhms8YkPimGSNBEx8ySDsUCyaDsBo44XzKx0pQotorS+lVi1DHuN4/AF65J3DzTLHLkNfx+qAYKGMhFT6u71xo04akxknPTJq4Q2AxWW6/6hz0dcKRA8pbfJFelCntJJhuPySqpeCQag3BdnJ7XJEb1Qk0d5eS5C6bmWEnWbHd5eyHoVl44+3GsvjXoXMTv5rzERslX6YryIuFAlJf9ZLer2l+SnPFwvZ4kwoyT5YnjCyzO2z4m4NZpDYEqRSDsZjtykklOXkCJy8Z+GY+pJl8ery539wA9h4F9Yu0u5JslZKfXSPV2jhoElomKBkDFC8Q/iKyjBzRKczGXOqercgAqprJqVixfBBl6IizjEM4/HRpaOmQpAXkZ/aPzj1H50Xguuu+rc2ABLMiZ9XPB/HKcfTVAC2h14T9vFnlh0TPp1aVybQ/BFqgAAbEx87RZr752zX8uAXtlXrA7zGZtNHgzC2PU10SnNweYHVaDizs8S2hPIRmDPClwIzmVdOaOt6meF1MYJ11lKa/viWE6JLf2UeUKJKfiFgxRspxqaatZ097Irm0B+SQ3tp6UZHI7bkbQX/TWoySXd2tPxVmy4Ms8Sc/DQQ4HoDCoc679Lul4Q/OvB3gqzlcPQsq7qDEeusT+7rlOO4polC0WASrRh77eQMDkAqfLvskTWPdc7lRrUnmggYqiImLaeIIO/dxgZB7kHYGvDcMgYu++MX0cPMT/Gf+51Nz774lFTQ/TEcQ15lbTb8dzOkqGopVQt3K4ngDFoLeNn6AJgZsUypzHb+I1Nxbk2qz5M5uUD5mCzSxk6U4jjs9THqA95bbz4d3DMFgsQciZ5sOic0KTsa2DLChm1dalZiIO/NsccGgIYg4PkfMsBQEJApqvX1bCzw4+mkI5uMmmEa+iEBcGeUCE/EYMD8bEMpnvBdTXJFeWJMQA86vlzSYHpyy+wk7F+4rcqK04PvZr7XS/JrUWQwV/T9MRvn1sLg2HCKr/1/gslMUHcMwMFRuktwgDRtJmZ5QEj/adzmFVmUpTr57wneDWYytHM1rvmXzMh6ru8adrzTyv2G3kBGQBmsBCdqaVGwi1+w1kfkNcmah5k3/CJU/34f3dmzeoEP9HctM25a8h1C1sGPMhXV2lOqVaUwwK8lP3sm4HiRwLvYiwR3xxGVvPMJPo6j2ARjwPZVDBX5JRw45jkr6cK4zz5LkyptEo X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: Bl4soouqGXjCYJKZ/nFq5ea788tXxrSZVbbhqd/OXxe7l7S7WKycDqVH7TxGgXV02EyGAYOziA0hHOzAGK0xnqqDrqZTxILCmuKa+ODmWJqAJ50gStBmkbKj8gs5mAlC/R1bxSgbJ/OdAjPwgCWHcojATanJUdiJqCiG0Ki6O4vsa2KbbB/aMGvtUEUef5LBNK5o4N4+9ww0hIz9FgBnU7AbAZWg7zvr6w/eSn6WE2rUA8qPNCoyAJ1KrovPd2ei+eFKRm7zoH4+4pIpBq3Sl50rs1LC2/AN7fL9h/pHmnQDvIex/ugsxdrHgiF3I1eJdpFQWtUch1ZzvrZfVtY1eLDIrM/V58yAK3fD5MvHRj/r6LCmfha2+e5KagwiIEEmtwh8z6+r8BFNWrb313IBZ/T9GwuNge2EJS6gz++Uu5UgF+eDuaDKWXIgqHcF6s0ZUapHNASXsrfa7T4cAEsX+fYXGFtda59lXNjKFI8MBdTIM6SEHkiRUYqKAou67n7oUwr3mtZthL51gHdLnBL2wyjJOX7wtKdhVNOzXkKDdvxOkpAYagqOQthVoZuQlfmXX72/HE6nEqo33bQL5J8DH0f9J2pZx52KVdbZPP6L2f+SF6XvxNbm1od0gS27UCPEBKjgd+suhcULX5dmoSwGVlvyOK9SfcIcScnsbwEQvNFqipx5vC7YUpMwduwrBdofFhZua7PFRzQc5KMxA91wIpPcsjq9Ekp/+wGmA8bP7WQx4GwsC/pbcDP4uIxSNn9U X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: e091aabd-da7a-4fc6-4c4b-08db613b8823 X-MS-Exchange-CrossTenant-AuthSource: MN2PR10MB3213.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 May 2023 18:27:32.1198 (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: LoNOFcl8HgXm8grmCLFY/jfc1K0UFVcr6qu6xEzR6HkkpInCY6+sVJur4Rc0fKwfXlCcbG+hkYYn6MeZA1guwg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR10MB6620 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.176.26 definitions=2023-05-30_14,2023-05-30_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxlogscore=999 adultscore=0 malwarescore=0 bulkscore=0 suspectscore=0 mlxscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2304280000 definitions=main-2305300147 X-Proofpoint-GUID: aEiJ3sYDS4Y6ZvJD1EfErjMezvvlbTuZ X-Proofpoint-ORIG-GUID: aEiJ3sYDS4Y6ZvJD1EfErjMezvvlbTuZ 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, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE 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: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: David Faust via Gcc-patches From: David Faust Reply-To: David Faust Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" [Changes from v1: - Fix typos. - Split unrelated change into separate commit. - Improve asm comment for enum constants, update btf-enum-1 test. - Improve asm comment for DATASEC records, update btf-datasec-2 test.] Many BTF type kinds refer to other types via index to the final types list. However, the order of the final types list is not guaranteed to remain the same for the same source program between different runs of the compiler, making it difficult to test inter-type references. This patch updates the assembler comments output when writing a given BTF record to include minimal information about the referenced type, if any. This allows for the regular expressions used in the gcc testsuite to do some basic integrity checks on inter-type references. For example, for the type unsigned int * Assembly comments like the following are written with -dA: .4byte 0 ; TYPE 2 BTF_KIND_PTR '' .4byte 0x2000000 ; btt_info: kind=2, kflag=0, vlen=0 .4byte 0x1 ; btt_type: (BTF_KIND_INT 'unsigned int') Several BTF tests which can immediately be made more robust with this change are updated. It will also be useful in new tests for the upcoming btf_type_tag support. Re-tested on BPF and x86_64, no known regressions. Thanks. gcc/ * btfout.cc (btf_kind_names): New. (btf_kind_name): New. (btf_absolute_var_id): New utility function. (btf_relative_var_id): Likewise. (btf_relative_func_id): Likewise. (btf_absolute_datasec_id): Likewise. (btf_asm_type_ref): New. (btf_asm_type): Update asm comments and use btf_asm_type_ref (). (btf_asm_array): Likewise. Accept ctf_container_ref parameter. (btf_asm_varent): Likewise. (btf_asm_func_arg): Likewise. (btf_asm_datasec_entry): Likewise. (btf_asm_datasec_type): Likewise. (btf_asm_func_type): Likewise. Add index parameter. (btf_asm_enum_const): Likewise. (btf_asm_sou_member): Likewise. (output_btf_vars): Update btf_asm_* call accordingly. (output_asm_btf_sou_fields): Likewise. (output_asm_btf_enum_list): Likewise. (output_asm_btf_func_args_list): Likewise. (output_asm_btf_vlen_bytes): Likewise. (output_btf_func_types): Add ctf_container_ref parameter. Pass it to btf_asm_func_type. (output_btf_datasec_types): Update btf_asm_datsec_type call similarly. (btf_output): Update output_btf_func_types call similarly. gcc/testsuite/ * gcc.dg/debug/btf/btf-array-1.c: Use new BTF asm comments in scan-assembler expressions where useful. * gcc.dg/debug/btf/btf-anonymous-struct-1.c: Likewise. * gcc.dg/debug/btf/btf-anonymous-union-1.c: Likewise. * gcc.dg/debug/btf/btf-bitfields-2.c: Likewise. * gcc.dg/debug/btf/btf-bitfields-3.c: Likewise. * gcc.dg/debug/btf/btf-datasec-2.c: Likewise. * gcc.dg/debug/btf/btf-enum-1.c: Likewise. * gcc.dg/debug/btf/btf-function-6.c: Likewise. * gcc.dg/debug/btf/btf-pointers-1.c: Likewise. * gcc.dg/debug/btf/btf-struct-1.c: Likewise. * gcc.dg/debug/btf/btf-struct-2.c: Likewise. * gcc.dg/debug/btf/btf-typedef-1.c: Likewise. * gcc.dg/debug/btf/btf-union-1.c: Likewise. * gcc.dg/debug/btf/btf-variables-1.c: Likewise. * gcc.dg/debug/btf/btf-variables-2.c: Likewise. Update outdated comment. * gcc.dg/debug/btf/btf-function-3.c: Update outdated comment. --- gcc/btfout.cc | 227 ++++++++++++++---- .../gcc.dg/debug/btf/btf-anonymous-struct-1.c | 3 +- .../gcc.dg/debug/btf/btf-anonymous-union-1.c | 4 +- gcc/testsuite/gcc.dg/debug/btf/btf-array-1.c | 3 + .../gcc.dg/debug/btf/btf-bitfields-2.c | 2 +- .../gcc.dg/debug/btf/btf-bitfields-3.c | 2 +- .../gcc.dg/debug/btf/btf-datasec-2.c | 4 +- gcc/testsuite/gcc.dg/debug/btf/btf-enum-1.c | 4 + .../gcc.dg/debug/btf/btf-function-3.c | 2 +- .../gcc.dg/debug/btf/btf-function-6.c | 4 +- .../gcc.dg/debug/btf/btf-pointers-1.c | 3 + gcc/testsuite/gcc.dg/debug/btf/btf-struct-1.c | 4 +- gcc/testsuite/gcc.dg/debug/btf/btf-struct-2.c | 2 +- .../gcc.dg/debug/btf/btf-typedef-1.c | 14 +- gcc/testsuite/gcc.dg/debug/btf/btf-union-1.c | 2 +- .../gcc.dg/debug/btf/btf-variables-1.c | 6 + .../gcc.dg/debug/btf/btf-variables-2.c | 7 +- 17 files changed, 224 insertions(+), 69 deletions(-) diff --git a/gcc/btfout.cc b/gcc/btfout.cc index ae9855716eb..f51ccf73242 100644 --- a/gcc/btfout.cc +++ b/gcc/btfout.cc @@ -114,6 +114,23 @@ static unsigned int num_types_added = 0; CTF types. */ static unsigned int num_types_created = 0; +/* Name strings for BTF kinds. + Note: the indices here must match the type defines in btf.h. */ +static const char *const btf_kind_names[] = + { + "UNKN", "INT", "PTR", "ARRAY", "STRUCT", "UNION", "ENUM", "FWD", + "TYPEDEF", "VOLATILE", "CONST", "RESTRICT", "FUNC", "FUNC_PROTO", + "VAR", "DATASEC", "FLOAT", "DECL_TAG", "TYPE_TAG", "ENUM64" + }; + +/* Return a name string for the given BTF_KIND. */ + +static const char * +btf_kind_name (uint32_t btf_kind) +{ + return btf_kind_names[btf_kind]; +} + /* Map a CTF type kind to the corresponding BTF type kind. */ static uint32_t @@ -141,6 +158,57 @@ get_btf_kind (uint32_t ctf_kind) return BTF_KIND_UNKN; } +/* Helper routines to map between 'relative' and 'absolute' IDs. + + In BTF all records (including variables) are output in one long list, and all + inter-type references are via index into that list. But internally since we + a) translate from CTF, which separates variable records from regular types + and b) create some additional types after the fact, things like VAR and FUNC + records are stored in separate vectors with their own indices. These + functions map between the 'relative' IDs (i.e. indices in their respective + containers) and 'absolute' IDs (i.e. indices in the final contiguous + output list), which goes in order: + all normal type records translated from CTF + all BTF_KIND_VAR records + all BTF_KIND_FUNC records (synthesized split function records) + all BTF_KIND_DATASEC records (synthesized) + + The extra '+ 1's below are to account for the implicit "void" record, which + has index 0 but isn't actually contained in the type list. */ + +/* Return the final BTF ID of the variable at relative index REL. */ + +static ctf_id_t +btf_absolute_var_id (ctf_id_t rel) +{ + return rel + (num_types_added + 1); +} + +/* Return the relative index of the variable with final BTF ID ABS. */ + +static ctf_id_t +btf_relative_var_id (ctf_id_t abs) +{ + return abs - (num_types_added + 1); +} + +/* Return the relative index of the func record with final BTF ID ABS. */ + +static ctf_id_t +btf_relative_func_id (ctf_id_t abs) +{ + return abs - ((num_types_added + 1) + num_vars_added); +} + +/* Return the final BTF ID of the datasec record at relative index REL. */ + +static ctf_id_t +btf_absolute_datasec_id (ctf_id_t rel) +{ + return rel + (num_types_added + 1) + num_vars_added + funcs->length (); +} + + /* Allocate the btf_id_map, and initialize elements to BTF_INVALID_TYPEID. */ static void @@ -407,8 +475,7 @@ btf_collect_datasec (ctf_container_ref ctfc) info.type = 0; unsigned int *var_id = btf_var_ids->get (dvd); if (var_id) - /* +1 for the sentinel type not in the types map. */ - info.type = *var_id + num_types_added + 1; + info.type = btf_absolute_var_id (*var_id); else continue; @@ -620,6 +687,48 @@ btf_dmd_representable_bitfield_p (ctf_container_ref ctfc, ctf_dmdef_t *dmd) /* BTF asm helper routines. */ +/* Asm'out a reference to another BTF type. */ + +static void +btf_asm_type_ref (const char *prefix, ctf_container_ref ctfc, ctf_id_t ref_id) +{ + if (ref_id == BTF_VOID_TYPEID || ref_id == BTF_INVALID_TYPEID) + { + /* There is no explicit void type. + Also handle any invalid refs that made it this far, just in case. */ + dw2_asm_output_data (4, ref_id, "%s: void", prefix); + } + else if (ref_id >= num_types_added + 1 + && ref_id < num_types_added + num_vars_added + 1) + { + /* Ref to a variable. Should only appear in DATASEC entries. */ + ctf_id_t var_id = btf_relative_var_id (ref_id); + ctf_dvdef_ref dvd = ctfc->ctfc_vars_list[var_id]; + dw2_asm_output_data (4, ref_id, "%s: (BTF_KIND_VAR '%s')", + prefix, dvd->dvd_name); + + } + else if (ref_id >= num_types_added + num_vars_added + 1) + { + /* Ref to a FUNC record. */ + size_t func_id = btf_relative_func_id (ref_id); + ctf_dtdef_ref ref_type = (*funcs)[func_id]; + dw2_asm_output_data (4, ref_id, "%s: (BTF_KIND_FUNC '%s')", + prefix, ref_type->dtd_name); + } + else + { + /* Ref to a standard type in the types list. */ + ctf_dtdef_ref ref_type = ctfc->ctfc_types_list[ref_id]; + uint32_t ref_kind + = get_btf_kind (CTF_V2_INFO_KIND (ref_type->dtd_data.ctti_info)); + + dw2_asm_output_data (4, ref_id, "%s: (BTF_KIND_%s '%s')", + prefix, btf_kind_name (ref_kind), + ref_type->dtd_name); + } +} + /* Asm'out a BTF type. This routine is responsible for the bulk of the task of converting CTF types to their BTF representation. */ @@ -689,7 +798,10 @@ btf_asm_type (ctf_container_ref ctfc, ctf_dtdef_ref dtd) btf_kind = BTF_KIND_ENUM64; } - dw2_asm_output_data (4, dtd->dtd_data.ctti_name, "btt_name"); + dw2_asm_output_data (4, dtd->dtd_data.ctti_name, + "TYPE %lu BTF_KIND_%s '%s'", + get_btf_id (dtd->dtd_type), btf_kind_name (btf_kind), + dtd->dtd_name); dw2_asm_output_data (4, BTF_TYPE_INFO (btf_kind, btf_kflag, btf_vlen), "btt_info: kind=%u, kflag=%u, vlen=%u", btf_kind, btf_kflag, btf_vlen); @@ -715,29 +827,31 @@ btf_asm_type (ctf_container_ref ctfc, ctf_dtdef_ref dtd) break; } - dw2_asm_output_data (4, get_btf_id (dtd->dtd_data.ctti_type), "btt_type"); + ctf_id_t ref_id = get_btf_id (dtd->dtd_data.ctti_type); + btf_asm_type_ref ("btt_type", ctfc, ref_id); } /* Asm'out the variable information following a BTF_KIND_ARRAY. */ static void -btf_asm_array (ctf_dtdef_ref dtd) +btf_asm_array (ctf_container_ref ctfc, ctf_arinfo_t arr) { - dw2_asm_output_data (4, get_btf_id (dtd->dtd_u.dtu_arr.ctr_contents), - "bta_contents"); - dw2_asm_output_data (4, get_btf_id (dtd->dtd_u.dtu_arr.ctr_index), - "bta_index"); - dw2_asm_output_data (4, dtd->dtd_u.dtu_arr.ctr_nelems, "bta_nelems"); + btf_asm_type_ref ("bta_elem_type", ctfc, get_btf_id (arr.ctr_contents)); + btf_asm_type_ref ("bta_index_type", ctfc, get_btf_id (arr.ctr_index)); + dw2_asm_output_data (4, arr.ctr_nelems, "bta_nelems"); } /* Asm'out a BTF_KIND_VAR. */ static void -btf_asm_varent (ctf_dvdef_ref var) +btf_asm_varent (ctf_container_ref ctfc, ctf_dvdef_ref var) { - dw2_asm_output_data (4, var->dvd_name_offset, "btv_name"); + ctf_id_t ref_id = get_btf_id (var->dvd_type); + dw2_asm_output_data (4, var->dvd_name_offset, "TYPE %u BTF_KIND_VAR '%s'", + (*(btf_var_ids->get (var)) + num_types_added + 1), + var->dvd_name); dw2_asm_output_data (4, BTF_TYPE_INFO (BTF_KIND_VAR, 0, 0), "btv_info"); - dw2_asm_output_data (4, get_btf_id (var->dvd_type), "btv_type"); + btf_asm_type_ref ("btv_type", ctfc, ref_id); dw2_asm_output_data (4, var->dvd_visibility, "btv_linkage"); } @@ -745,7 +859,7 @@ btf_asm_varent (ctf_dvdef_ref var) BTF_KIND_UNION. */ static void -btf_asm_sou_member (ctf_container_ref ctfc, ctf_dmdef_t * dmd) +btf_asm_sou_member (ctf_container_ref ctfc, ctf_dmdef_t * dmd, unsigned int idx) { ctf_dtdef_ref ref_type = ctfc->ctfc_types_list[dmd->dmd_type]; @@ -768,15 +882,19 @@ btf_asm_sou_member (ctf_container_ref ctfc, ctf_dmdef_t * dmd) sou_offset &= 0x00ffffff; sou_offset |= ((bits & 0xff) << 24); + dw2_asm_output_data (4, dmd->dmd_name_offset, + "MEMBER '%s' idx=%u", + dmd->dmd_name, idx); /* Refer to the base type of the slice. */ - dw2_asm_output_data (4, dmd->dmd_name_offset, "btm_name_off"); - dw2_asm_output_data (4, get_btf_id (base_type), "btm_type"); + btf_asm_type_ref ("btm_type", ctfc, get_btf_id (base_type)); dw2_asm_output_data (4, sou_offset, "btm_offset"); } else { - dw2_asm_output_data (4, dmd->dmd_name_offset, "btm_name_off"); - dw2_asm_output_data (4, get_btf_id (dmd->dmd_type), "btm_type"); + dw2_asm_output_data (4, dmd->dmd_name_offset, + "MEMBER '%s' idx=%u", + dmd->dmd_name, idx); + btf_asm_type_ref ("btm_type", ctfc, get_btf_id (dmd->dmd_type)); dw2_asm_output_data (4, dmd->dmd_offset, "btm_offset"); } } @@ -784,9 +902,10 @@ btf_asm_sou_member (ctf_container_ref ctfc, ctf_dmdef_t * dmd) /* Asm'out an enum constant following a BTF_KIND_ENUM{,64}. */ static void -btf_asm_enum_const (unsigned int size, ctf_dmdef_t * dmd) +btf_asm_enum_const (unsigned int size, ctf_dmdef_t * dmd, unsigned int idx) { - dw2_asm_output_data (4, dmd->dmd_name_offset, "bte_name"); + dw2_asm_output_data (4, dmd->dmd_name_offset, "ENUM_CONST '%s' idx=%u", + dmd->dmd_name, idx); if (size == 4) dw2_asm_output_data (size, dmd->dmd_value, "bte_value"); else @@ -799,7 +918,8 @@ btf_asm_enum_const (unsigned int size, ctf_dmdef_t * dmd) /* Asm'out a function parameter description following a BTF_KIND_FUNC_PROTO. */ static void -btf_asm_func_arg (ctf_func_arg_t * farg, size_t stroffset) +btf_asm_func_arg (ctf_container_ref ctfc, ctf_func_arg_t * farg, + size_t stroffset) { /* If the function arg does not have a name, refer to the null string at the start of the string table. This ensures correct encoding for varargs @@ -809,31 +929,33 @@ btf_asm_func_arg (ctf_func_arg_t * farg, size_t stroffset) else dw2_asm_output_data (4, 0, "farg_name"); - dw2_asm_output_data (4, (btf_removed_type_p (farg->farg_type) - ? BTF_VOID_TYPEID - : get_btf_id (farg->farg_type)), - "farg_type"); + btf_asm_type_ref ("farg_type", ctfc, (btf_removed_type_p (farg->farg_type) + ? BTF_VOID_TYPEID + : get_btf_id (farg->farg_type))); } /* Asm'out a BTF_KIND_FUNC type. */ static void -btf_asm_func_type (ctf_dtdef_ref dtd) +btf_asm_func_type (ctf_container_ref ctfc, ctf_dtdef_ref dtd, size_t i) { - dw2_asm_output_data (4, dtd->dtd_data.ctti_name, "btt_name"); - dw2_asm_output_data (4, BTF_TYPE_INFO (BTF_KIND_FUNC, 0, - dtd->linkage), - "btt_info: kind=%u, kflag=%u, linkage=%u", - BTF_KIND_FUNC, 0, dtd->linkage); - dw2_asm_output_data (4, get_btf_id (dtd->dtd_data.ctti_type), "btt_type"); + ctf_id_t ref_id = dtd->dtd_data.ctti_type; + dw2_asm_output_data (4, dtd->dtd_data.ctti_name, + "TYPE %lu BTF_KIND_FUNC '%s'", + num_types_added + num_vars_added + 1 + i, + dtd->dtd_name); + dw2_asm_output_data (4, BTF_TYPE_INFO (BTF_KIND_FUNC, 0, dtd->linkage), + "btt_info: kind=%u, kflag=%u, linkage=%u", + BTF_KIND_FUNC, 0, dtd->linkage); + btf_asm_type_ref ("btt_type", ctfc, get_btf_id (ref_id)); } /* Asm'out a variable entry following a BTF_KIND_DATASEC. */ static void -btf_asm_datasec_entry (struct btf_var_secinfo info) +btf_asm_datasec_entry (ctf_container_ref ctfc, struct btf_var_secinfo info) { - dw2_asm_output_data (4, info.type, "bts_type"); + btf_asm_type_ref ("bts_type", ctfc, info.type); dw2_asm_output_data (4, info.offset, "bts_offset"); dw2_asm_output_data (4, info.size, "bts_size"); } @@ -841,17 +963,20 @@ btf_asm_datasec_entry (struct btf_var_secinfo info) /* Asm'out a whole BTF_KIND_DATASEC, including its variable entries. */ static void -btf_asm_datasec_type (btf_datasec_t ds, size_t stroffset) +btf_asm_datasec_type (ctf_container_ref ctfc, btf_datasec_t ds, ctf_id_t id, + size_t stroffset) { - dw2_asm_output_data (4, ds.name_offset + stroffset, "btt_name"); + dw2_asm_output_data (4, ds.name_offset + stroffset, + "TYPE %lu BTF_KIND_DATASEC '%s'", + btf_absolute_datasec_id (id), ds.name); dw2_asm_output_data (4, BTF_TYPE_INFO (BTF_KIND_DATASEC, 0, ds.entries.length ()), - "btt_info"); + "btt_info: n_entries=%u", ds.entries.length ()); /* Note: the "total section size in bytes" is emitted as 0 and patched by loaders such as libbpf. */ dw2_asm_output_data (4, 0, "btt_size"); for (size_t i = 0; i < ds.entries.length (); i++) - btf_asm_datasec_entry (ds.entries[i]); + btf_asm_datasec_entry (ctfc, ds.entries[i]); } /* Compute and output the header information for a .BTF section. */ @@ -912,7 +1037,7 @@ output_btf_vars (ctf_container_ref ctfc) if (num_ctf_vars) { for (i = 0; i < num_ctf_vars; i++) - btf_asm_varent (ctfc->ctfc_vars_list[i]); + btf_asm_varent (ctfc, ctfc->ctfc_vars_list[i]); } } @@ -946,9 +1071,13 @@ output_asm_btf_sou_fields (ctf_container_ref ctfc, ctf_dtdef_ref dtd) { ctf_dmdef_t * dmd; + unsigned idx = 0; for (dmd = dtd->dtd_u.dtu_members; dmd != NULL; dmd = (ctf_dmdef_t *) ctf_dmd_list_next (dmd)) - btf_asm_sou_member (ctfc, dmd); + { + btf_asm_sou_member (ctfc, dmd, idx); + idx++; + } } /* Output all enumerator constants following a BTF_KIND_ENUM{,64}. */ @@ -959,9 +1088,13 @@ output_asm_btf_enum_list (ctf_container_ref ARG_UNUSED (ctfc), { ctf_dmdef_t * dmd; + unsigned idx = 0; for (dmd = dtd->dtd_u.dtu_members; dmd != NULL; dmd = (ctf_dmdef_t *) ctf_dmd_list_next (dmd)) - btf_asm_enum_const (dtd->dtd_data.ctti_size, dmd); + { + btf_asm_enum_const (dtd->dtd_data.ctti_size, dmd, idx); + idx++; + } } /* Output all function arguments following a BTF_KIND_FUNC_PROTO. */ @@ -974,7 +1107,7 @@ output_asm_btf_func_args_list (ctf_container_ref ctfc, ctf_func_arg_t * farg; for (farg = dtd->dtd_u.dtu_argv; farg != NULL; farg = (ctf_func_arg_t *) ctf_farg_list_next (farg)) - btf_asm_func_arg (farg, farg_name_offset); + btf_asm_func_arg (ctfc, farg, farg_name_offset); } /* Output the variable portion of a BTF type record. The information depends @@ -1010,7 +1143,7 @@ output_asm_btf_vlen_bytes (ctf_container_ref ctfc, ctf_dtdef_ref dtd) break; case BTF_KIND_ARRAY: - btf_asm_array (dtd); + btf_asm_array (ctfc, dtd->dtd_u.dtu_arr); break; case BTF_KIND_STRUCT: @@ -1074,10 +1207,10 @@ output_btf_types (ctf_container_ref ctfc) /* Output all BTF_KIND_FUNC type records. */ static void -output_btf_func_types (void) +output_btf_func_types (ctf_container_ref ctfc) { for (size_t i = 0; i < vec_safe_length (funcs); i++) - btf_asm_func_type ((*funcs)[i]); + btf_asm_func_type (ctfc, (*funcs)[i], i); } /* Output all BTF_KIND_DATASEC records. */ @@ -1088,7 +1221,7 @@ output_btf_datasec_types (ctf_container_ref ctfc) size_t name_offset = ctfc_get_strtab_len (ctfc, CTF_STRTAB); for (size_t i = 0; i < datasecs.length(); i++) - btf_asm_datasec_type (datasecs[i], name_offset); + btf_asm_datasec_type (ctfc, datasecs[i], i, name_offset); } /* Postprocess the CTF debug data post initialization. @@ -1215,7 +1348,7 @@ btf_output (const char * filename) output_btf_header (tu_ctfc); output_btf_types (tu_ctfc); output_btf_vars (tu_ctfc); - output_btf_func_types (); + output_btf_func_types (tu_ctfc); output_btf_datasec_types (tu_ctfc); output_btf_strs (tu_ctfc); } diff --git a/gcc/testsuite/gcc.dg/debug/btf/btf-anonymous-struct-1.c b/gcc/testsuite/gcc.dg/debug/btf/btf-anonymous-struct-1.c index 89a5701bba0..05996fe195a 100644 --- a/gcc/testsuite/gcc.dg/debug/btf/btf-anonymous-struct-1.c +++ b/gcc/testsuite/gcc.dg/debug/btf/btf-anonymous-struct-1.c @@ -11,10 +11,11 @@ /* { dg-options "-O0 -gbtf -dA" } */ /* Struct type with 2 members (struct foo). */ +/* { dg-final { scan-assembler-times " BTF_KIND_STRUCT 'foo'" 1 } } */ /* { dg-final { scan-assembler-times "\[\t \]0x4000002\[\t \]+\[^\n\]*btt_info" 1 } } */ /* Struct type with 1 member (anon struct). */ +/* { dg-final { scan-assembler-times " BTF_KIND_STRUCT ''" 1 } } */ /* { dg-final { scan-assembler-times "\[\t \]0x4000001\[\t \]+\[^\n\]*btt_info" 1 } } */ -/* { dg-final { scan-assembler-times "\[\t \]0\[\t \]+\[^\n\]*btt_name" 1 } } */ struct foo { diff --git a/gcc/testsuite/gcc.dg/debug/btf/btf-anonymous-union-1.c b/gcc/testsuite/gcc.dg/debug/btf/btf-anonymous-union-1.c index f3b120bb458..49cdc87cf59 100644 --- a/gcc/testsuite/gcc.dg/debug/btf/btf-anonymous-union-1.c +++ b/gcc/testsuite/gcc.dg/debug/btf/btf-anonymous-union-1.c @@ -9,9 +9,9 @@ /* Struct type with 1 member. */ /* { dg-final { scan-assembler-times "\[\t \]0x4000001\[\t \]+\[^\n\]*btt_info" 1 } } */ -/* Union type with 2 members. */ +/* Anonymous union type with 2 members. */ /* { dg-final { scan-assembler-times "\[\t \]0x5000002\[\t \]+\[^\n\]*btt_info" 1 } } */ -/* { dg-final { scan-assembler-times "\[\t \]0\[\t \]+\[^\n\]*btt_name" 1 } } */ +/* { dg-final { scan-assembler-times " BTF_KIND_UNION ''" 1 } } */ struct foo { diff --git a/gcc/testsuite/gcc.dg/debug/btf/btf-array-1.c b/gcc/testsuite/gcc.dg/debug/btf/btf-array-1.c index ab55445bd35..967b1e8746a 100644 --- a/gcc/testsuite/gcc.dg/debug/btf/btf-array-1.c +++ b/gcc/testsuite/gcc.dg/debug/btf/btf-array-1.c @@ -18,6 +18,9 @@ /* { dg-final { scan-assembler-times "\[\t \]0x5\[\t \]+\[^\n\]*bta_nelems" 1 } } */ /* { dg-final { scan-assembler-times "\[\t \]0\[\t \]+\[^\n\]*bta_nelems" 1 } } */ +/* { dg-final { scan-assembler-times " bta_elem_type: \\(BTF_KIND_INT 'int'\\)" 4 } } */ +/* { dg-final { scan-assembler-times " bta_elem_type: \\(BTF_KIND_ARRAY ''\\)" 1 } } */ + int b1[2] = {0,1}; int c1[5] = {0,1,2,3,4}; int a1[2][3] = { {3,4,5}, {2,3,4} }; diff --git a/gcc/testsuite/gcc.dg/debug/btf/btf-bitfields-2.c b/gcc/testsuite/gcc.dg/debug/btf/btf-bitfields-2.c index 9665ab67145..03c323a6d49 100644 --- a/gcc/testsuite/gcc.dg/debug/btf/btf-bitfields-2.c +++ b/gcc/testsuite/gcc.dg/debug/btf/btf-bitfields-2.c @@ -16,7 +16,7 @@ /* { dg-final { scan-assembler-times "\[\t \]0x20000020\[\t \]+\[^\n\]*btm_offset" 1 } } */ /* Only 2 members. */ -/* { dg-final { scan-assembler-times "btm_name" 2 } } */ +/* { dg-final { scan-assembler-times "MEMBER" 2 } } */ struct foo { diff --git a/gcc/testsuite/gcc.dg/debug/btf/btf-bitfields-3.c b/gcc/testsuite/gcc.dg/debug/btf/btf-bitfields-3.c index 2984a3357eb..78b8b7d49ad 100644 --- a/gcc/testsuite/gcc.dg/debug/btf/btf-bitfields-3.c +++ b/gcc/testsuite/gcc.dg/debug/btf/btf-bitfields-3.c @@ -22,7 +22,7 @@ /* { dg-final { scan-assembler-times "\[\t \]0x84000001\[\t \]+\[^\n\]*btt_info" 1 } } */ /* Bitfield "f" points to type ID 1. */ -/* { dg-final { scan-assembler-times "\[\t \]0x1\[\t \]+\[^\n\]*btm_type" 1 } } */ +/* { dg-final { scan-assembler-times " btm_type: \\(BTF_KIND_ENUM 'foo'" 1 } } */ enum foo { diff --git a/gcc/testsuite/gcc.dg/debug/btf/btf-datasec-2.c b/gcc/testsuite/gcc.dg/debug/btf/btf-datasec-2.c index f4b298cf019..d6f3358d6fb 100644 --- a/gcc/testsuite/gcc.dg/debug/btf/btf-datasec-2.c +++ b/gcc/testsuite/gcc.dg/debug/btf/btf-datasec-2.c @@ -6,8 +6,8 @@ /* { dg-options "-O0 -gbtf -dA" } */ /* Expect one DATASEC with vlen=1 (.foo_sec) and one with vlen=2 (.bar_sec) */ -/* { dg-final { scan-assembler-times "0xf000002\[\t \]+\[^\n\]*btt_info" 1 } } */ -/* { dg-final { scan-assembler-times "0xf000001\[\t \]+\[^\n\]*btt_info" 1 } } */ +/* { dg-final { scan-assembler-times " BTF_KIND_DATASEC '.foo_sec'\[\\r\\n\]+\[^\\r\\n\]*0xf000001\[\t \]+\[^\n\]*btt_info" 1 } } */ +/* { dg-final { scan-assembler-times " BTF_KIND_DATASEC '.bar_sec'\[\\r\\n\]+\[^\\r\\n\]*0xf000002\[\t \]+\[^\n\]*btt_info" 1 } } */ /* Function entries should have offset and size of 0 at compile time. */ /* { dg-final { scan-assembler-times "0\[\t \]+\[^\n\]*bts_offset" 3 } } */ 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 2887cb1c5f2..021ce0345e4 100644 --- a/gcc/testsuite/gcc.dg/debug/btf/btf-enum-1.c +++ b/gcc/testsuite/gcc.dg/debug/btf/btf-enum-1.c @@ -5,6 +5,10 @@ /* { dg-final { scan-assembler-times "\[\t \]0x6000004\[\t \]+\[^\n\]*btt_info" 1 } } */ /* { dg-final { scan-assembler-times "\[\t \]0x86000003\[\t \]+\[^\n\]*btt_info" 1 } } */ +/* { dg-final { scan-assembler-times " ENUM_CONST 'QAD' idx=0" 1 } } */ +/* { dg-final { scan-assembler-times " ENUM_CONST 'QED' idx=1" 1 } } */ +/* { dg-final { scan-assembler-times " ENUM_CONST 'QOD' idx=2" 1 } } */ +/* { dg-final { scan-assembler-times " ENUM_CONST 'QUD' idx=3" 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-function-3.c b/gcc/testsuite/gcc.dg/debug/btf/btf-function-3.c index 884d25cfbda..7ca0890884e 100644 --- a/gcc/testsuite/gcc.dg/debug/btf/btf-function-3.c +++ b/gcc/testsuite/gcc.dg/debug/btf/btf-function-3.c @@ -1,6 +1,6 @@ /* Test BTF generation for a function with an unrepresentable parameter. - BTF has no encoding for floating point types, among others. Function + BTF has no encoding for vector types, among others. Function parameters of unrepresentable types are emitted as 'void' types. We expect one BTF_KIND_FUNC_PROTO with 3 parameters, one of which diff --git a/gcc/testsuite/gcc.dg/debug/btf/btf-function-6.c b/gcc/testsuite/gcc.dg/debug/btf/btf-function-6.c index 48a946ab14b..e014d9990a9 100644 --- a/gcc/testsuite/gcc.dg/debug/btf/btf-function-6.c +++ b/gcc/testsuite/gcc.dg/debug/btf/btf-function-6.c @@ -6,8 +6,8 @@ /* { dg-do compile } */ /* { dg-options "-O0 -gbtf -dA" } */ -/* { dg-final { scan-assembler-times "btt_info: kind=12, kflag=0, linkage=2" 1 } } */ -/* { dg-final { scan-assembler-times "btt_info: kind=12, kflag=0, linkage=1" 1 } } */ +/* { dg-final { scan-assembler-times " BTF_KIND_FUNC\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*linkage=2\[\\r\\n\]+\[^\\r\\n\]*\\(BTF_KIND_FUNC_PROTO 'extfunc'" 1 } } */ +/* { dg-final { scan-assembler-times " BTF_KIND_FUNC\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*linkage=1\[\\r\\n\]+\[^\\r\\n\]*\\(BTF_KIND_FUNC_PROTO 'foo'" 1 } } */ extern int extfunc(int a, int b); diff --git a/gcc/testsuite/gcc.dg/debug/btf/btf-pointers-1.c b/gcc/testsuite/gcc.dg/debug/btf/btf-pointers-1.c index a14ac0f89b2..f80d8089877 100644 --- a/gcc/testsuite/gcc.dg/debug/btf/btf-pointers-1.c +++ b/gcc/testsuite/gcc.dg/debug/btf/btf-pointers-1.c @@ -9,6 +9,9 @@ /* { dg-options "-O0 -gbtf -dA" } */ /* { dg-final { scan-assembler-times "\[\t \]0x2000000\[\t \]+\[^\n\]*btt_info" 2 } } */ +/* { dg-final { scan-assembeler-times " BTF_KIND_PTR ''\[\\r\\n\]+\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*\\(BTF_KIND_INT 'int'"}} */ +/* { dg-final { scan-assembeler-times " BTF_KIND_PTR ''\[\\r\\n\]+\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*\\(BTF_KIND_STRUCT 'st'"}} */ + /* { dg-final { scan-assembler-times "ascii \"int.0\"\[\t \]+\[^\n\]*btf_string" 1 } } */ /* { dg-final { scan-assembler-times "ascii \"st.0\"\[\t \]+\[^\n\]*btf_string" 1 } } */ diff --git a/gcc/testsuite/gcc.dg/debug/btf/btf-struct-1.c b/gcc/testsuite/gcc.dg/debug/btf/btf-struct-1.c index bc3281437c9..79156cd7bcf 100644 --- a/gcc/testsuite/gcc.dg/debug/btf/btf-struct-1.c +++ b/gcc/testsuite/gcc.dg/debug/btf/btf-struct-1.c @@ -9,7 +9,9 @@ /* { dg-final { scan-assembler-times "\[\t \]0x4000003\[\t \]+\[^\n\]*btt_info" 1 } } */ /* { dg-final { scan-assembler-times "\[\t \]0x4000002\[\t \]+\[^\n\]*btt_info" 1 } } */ -/* { dg-final { scan-assembler-times "btm_name" 5 } } */ +/* { dg-final { scan-assembler-times " btm_type: \\(BTF_KIND_INT" 3 } } */ +/* { dg-final { scan-assembler-times " btm_type: \\(BTF_KIND_ARRAY" 1 } } */ +/* { dg-final { scan-assembler-times " btm_type: \\(BTF_KIND_STRUCT" 1 } } */ struct foo { diff --git a/gcc/testsuite/gcc.dg/debug/btf/btf-struct-2.c b/gcc/testsuite/gcc.dg/debug/btf/btf-struct-2.c index c3aff09ed9a..e9ff06883db 100644 --- a/gcc/testsuite/gcc.dg/debug/btf/btf-struct-2.c +++ b/gcc/testsuite/gcc.dg/debug/btf/btf-struct-2.c @@ -1,7 +1,7 @@ /* Test BTF generation for struct type with a member which refers to an unsupported type. - BTF does not support floating point types (among other things). When + BTF does not support vector types (among other things). When generating BTF for a struct (or union) type, members which refer to unsupported types should be skipped. */ diff --git a/gcc/testsuite/gcc.dg/debug/btf/btf-typedef-1.c b/gcc/testsuite/gcc.dg/debug/btf/btf-typedef-1.c index 472cc63f600..36bbb292f5c 100644 --- a/gcc/testsuite/gcc.dg/debug/btf/btf-typedef-1.c +++ b/gcc/testsuite/gcc.dg/debug/btf/btf-typedef-1.c @@ -41,13 +41,13 @@ /* { dg-final { scan-assembler-times "ascii \"node_t.0\"\[\t \]+\[^\n\]*btf_string" 1 } } */ /* { dg-final { scan-assembler-times "ascii \"arena_t.0\"\[\t \]+\[^\n\]*btf_string" 1 } } */ -/* { dg-final { scan-assembler-times "\[\t \]0x2\[\t \]+\[^\n\]*btv_type" 1 } } */ -/* { dg-final { scan-assembler-times "\[\t \]0x3\[\t \]+\[^\n\]*btv_type" 1 } } */ -/* { dg-final { scan-assembler-times "\[\t \]0x4\[\t \]+\[^\n\]*btv_type" 1 } } */ -/* { dg-final { scan-assembler-times "\[\t \]0x6\[\t \]+\[^\n\]*btv_type" 1 } } */ -/* { dg-final { scan-assembler-times "\[\t \]0x8\[\t \]+\[^\n\]*btv_type" 1 } } */ -/* { dg-final { scan-assembler-times "\[\t \]0xb\[\t \]+\[^\n\]*btv_type" 1 } } */ -/* { dg-final { scan-assembler-times "\[\t \]0xf\[\t \]+\[^\n\]*btv_type" 1 } } */ +/* { dg-final { scan-assembler "BTF_KIND_VAR 'a'\[\\r\\n\]+\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*\\(BTF_KIND_TYPEDEF 'my_int'" } } */ +/* { dg-final { scan-assembler "BTF_KIND_VAR 'b'\[\\r\\n\]+\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*\\(BTF_KIND_TYPEDEF 'foo_int'" } } */ +/* { dg-final { scan-assembler "BTF_KIND_VAR 'c'\[\\r\\n\]+\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*\\(BTF_KIND_TYPEDEF 'bar_int'" } } */ +/* { dg-final { scan-assembler "BTF_KIND_VAR 'd'\[\\r\\n\]+\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*\\(BTF_KIND_TYPEDEF 'node_t'" } } */ +/* { dg-final { scan-assembler "BTF_KIND_VAR 'destination'\[\\r\\n\]+\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*\\(BTF_KIND_TYPEDEF 'CBAR'" } } */ +/* { dg-final { scan-assembler "BTF_KIND_VAR 'ticket'\[\\r\\n\]+\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*\\(BTF_KIND_TYPEDEF 'CBARP'" } } */ +/* { dg-final { scan-assembler "BTF_KIND_VAR 'suitcase'\[\\r\\n\]+\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*\\(BTF_KIND_TYPEDEF 'arena_t'" } } */ typedef int my_int; typedef int foo_int; diff --git a/gcc/testsuite/gcc.dg/debug/btf/btf-union-1.c b/gcc/testsuite/gcc.dg/debug/btf/btf-union-1.c index d66843717b3..e3a19028843 100644 --- a/gcc/testsuite/gcc.dg/debug/btf/btf-union-1.c +++ b/gcc/testsuite/gcc.dg/debug/btf/btf-union-1.c @@ -5,7 +5,7 @@ /* One union type with 4 members */ /* { dg-final { scan-assembler-times "\[\t \]0x5000004\[\t \]+\[^\n\]*btt_info" 1 } } */ -/* { dg-final { scan-assembler-times "btm_name" 4 } } */ +/* { dg-final { scan-assembler-times "MEMBER" 4 } } */ union onion { diff --git a/gcc/testsuite/gcc.dg/debug/btf/btf-variables-1.c b/gcc/testsuite/gcc.dg/debug/btf/btf-variables-1.c index a79ed1d53b7..42503df396f 100644 --- a/gcc/testsuite/gcc.dg/debug/btf/btf-variables-1.c +++ b/gcc/testsuite/gcc.dg/debug/btf/btf-variables-1.c @@ -5,6 +5,12 @@ /* We expect 6 variables */ /* { dg-final { scan-assembler-times "\[\t \]0xe000000\[\t \]+\[^\n\]*btv_info" 6 } } */ +/* { dg-final { scan-assembler-times " BTF_KIND_VAR 'x1'\[\\r\\n\]+\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*\\(BTF_KIND_INT" 1 } } */ +/* { dg-final { scan-assembler-times " BTF_KIND_VAR 'bar'\[\\r\\n\]+\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*\\(BTF_KIND_UNION" 1 } } */ +/* { dg-final { scan-assembler-times " BTF_KIND_VAR 'lala'\[\\r\\n\]+\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*\\(BTF_KIND_ENUM" 1 } } */ +/* { dg-final { scan-assembler-times " BTF_KIND_VAR 'arr'\[\\r\\n\]+\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*\\(BTF_KIND_ARRAY" 1 } } */ +/* { dg-final { scan-assembler-times " BTF_KIND_VAR 'plong'\[\\r\\n\]+\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*\\(BTF_KIND_PTR" 1 } } */ +/* { dg-final { scan-assembler-times " BTF_KIND_VAR 'st_inst'\[\\r\\n\]+\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*\\(BTF_KIND_STRUCT 'st'" 1 } } */ unsigned int x1; diff --git a/gcc/testsuite/gcc.dg/debug/btf/btf-variables-2.c b/gcc/testsuite/gcc.dg/debug/btf/btf-variables-2.c index db0bdd7be16..5f0c0b6e02d 100644 --- a/gcc/testsuite/gcc.dg/debug/btf/btf-variables-2.c +++ b/gcc/testsuite/gcc.dg/debug/btf/btf-variables-2.c @@ -1,7 +1,7 @@ /* BTF generation for variables with removed type. - BTF does not support floating point types, so no representation for the type - 'float' will be emitted. In this test, we check to also ensure that the + BTF does not support vector types, so no representation for the type + of 'bar' will be emitted. In this test, we check to also ensure that the variable 'bar' is not emitted, as it references a type that is not supported in BTF. */ @@ -11,6 +11,9 @@ /* We expect only 3 variables. */ /* { dg-final { scan-assembler-times "\[\t \]0xe000000\[\t \]+\[^\n\]*btv_info" 3 } } */ +/* { dg-final { scan-assembler-times " BTF_KIND_VAR 'foo'" 1 } } */ +/* { dg-final { scan-assembler-times " BTF_KIND_VAR 'baz'" 1 } } */ +/* { dg-final { scan-assembler-times " BTF_KIND_VAR 'myst'" 1 } } */ /* { dg-final { scan-assembler-times "ascii \"foo.0\"\[\t \]+\[^\n\]*btf_string" 1 } } */ /* { dg-final { scan-assembler-times "ascii \"baz.0\"\[\t \]+\[^\n\]*btf_string" 1 } } */ /* { dg-final { scan-assembler-times "ascii \"myst.0\"\[\t \]+\[^\n\]*btf_string" 1 } } */