From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by sourceware.org (Postfix) with ESMTPS id E83F83858434 for ; Fri, 1 Apr 2022 19:43:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E83F83858434 Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 231Fwnmj017615; Fri, 1 Apr 2022 19:43:02 GMT Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com with ESMTP id 3f1ucu04y9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 01 Apr 2022 19:43:02 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.16.1.2/8.16.1.2) with SMTP id 231JgCKn025532; Fri, 1 Apr 2022 19:43:01 GMT Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2103.outbound.protection.outlook.com [104.47.55.103]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com with ESMTP id 3f1tg9j7nv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 01 Apr 2022 19:43:01 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Cp8L7KbSQlYdCO7TJHBL0GPgsRNYQIWYRIwznnfaGBJBCtDn6S8u5rn7pvRcgC1qRjr5OOSypeN1jkrdmKIxYviXtlT0NKYIlYlHOoAmEwMtBv3zaseRansrZmM7vFddss0fQKAXpaPVl7/h/l7xYVa1ZRtisIaqoLcBgKg+8VOvOWifVqiW6j76JBD/lvGDZKhpeOCOTRdlmPoOOT3KZOeQNtsMLaYC4wk78R9GT1xEnWUachTY45++84fPrCZvDyD1GoXioIXOcgdRAM2CT9gasKig/jj3XnivWEdhcAgRABELy50uVlmhCBcG7eq3rqgEpiUacmF7oMFoDgl8GA== 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=b3GVu8QC4Oj19crSUy0IFak6A3+ipgCEX38vQ7vRIGE=; b=EMrG7MrJZ5Lu385YsENT/9Wj4dpKIqqGizmaghAXYEPbYdMvtqvIQ+Z46g3pk74d6Dp3qbXkqasmQYXS4cOIfBly87IBfYp9/kD60oZfQPdeOM6kG9SFs3XBoRVhsqDY+dqge9P0bz7z9vl1JVxX11fDOPmGrHs5go8IY7Ez8MQ8dvBG0vlXDAMe0em2u07K0aSzcaBh6SBj6N/mh1DKRJWv2K/+bSor0IB9UED3yplVzeCyf12XAi1vM0RIUpe91GvcSbi4viQxpRFKyveyAGW9bqqGU1rgOPQqpIdMiDi9+3A+IQncJGj/jbvVMRgQHodxYx+XqawLHAxfs/kkFQ== 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 MWHPR1001MB2286.namprd10.prod.outlook.com (2603:10b6:301:2d::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5102.19; Fri, 1 Apr 2022 19:42:59 +0000 Received: from MN2PR10MB3213.namprd10.prod.outlook.com ([fe80::705e:a465:c30b:fec6]) by MN2PR10MB3213.namprd10.prod.outlook.com ([fe80::705e:a465:c30b:fec6%6]) with mapi id 15.20.5123.021; Fri, 1 Apr 2022 19:42:59 +0000 From: David Faust To: gcc-patches@gcc.gnu.org Cc: yhs@fb.com, jose.marchesi@oracle.com Subject: [PATCH 5/8] ctfc: Add support to pass through BTF annotations Date: Fri, 1 Apr 2022 12:42:13 -0700 Message-Id: <20220401194216.16469-6-david.faust@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220401194216.16469-1-david.faust@oracle.com> References: <20220401194216.16469-1-david.faust@oracle.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: DM6PR03CA0052.namprd03.prod.outlook.com (2603:10b6:5:100::29) To MN2PR10MB3213.namprd10.prod.outlook.com (2603:10b6:208:131::33) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2cd0054c-6d1f-4cae-5074-08da1417d3c0 X-MS-TrafficTypeDiagnostic: MWHPR1001MB2286:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +SifQWDRo1SFuc+vQOw78ln72V4kdSE7i/BSSKUzgQsAQfrezcZzmYpsKSlVjfF76BGCNwbW9jtH2DAEBiR2iNm8PtzkWenOQvCb9Qr1nIW7kQIjyf2OkVqyYDlrWkVe+hXvqBqNYt+iFUgKK3tvEtGirBczeQdPIu+KYUCVlpIBXgp3cpnqFDPHTlfUvum4xe08H1m//W7pBSc6O+yvVYKe8EdJi5bjtbk6kI+8/EHYDEDePc/izPvdu4VMxkOgJUMbhhBFEKLeiv4+RIZC/IDjaWYX32QCVTEs+dv9SrylBnYZEC0/iTLUP9sA6fsa/SPbqbhXIyr3jzHEkOHvBwvolM3vFz4RdNz4A/r1R+jchyakEG9VmM+nKNwWzkNDoSobRxJvIo6j88SVUpeqbTrREaTkaZhI5PO7v/mZm38MvZ/wv1DpOmD5qbBd3pU3sTRfhRNId/TBNpdLgQwtpaizBTtYqpXB3Hlop9eGQwGZ7HFQWKcM7OwTOahcmEgBWsnIFki+P9GeXxrLsx/RZ4OXIFjo5Fvo8Uz/pwLXo80yM/gJn6RJhh2DJ1z3bIM8hzBQR6FQuFm0jFafuEXP685up14xfz8GUN+lfzadSYd2q/Ah21fB/gqmxkbnXbz9YYM7f1itOH1ERlxAszkZiznvMla+4JmR/hZjhAZz9FOvvpiKYm+n1wn7gvvW/bOYIe79FO8ciI/ktd4bsaEUCbiKZopH/FJHa5xLKdR9uFd+LNPOBC96kvZdjUTNkkiqRwX/dbt3Q6tMPr45Csgfxg== 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:(13230001)(366004)(66946007)(6916009)(316002)(36756003)(66556008)(5660300002)(66476007)(508600001)(38100700002)(86362001)(6666004)(8676002)(44832011)(4326008)(8936002)(6486002)(6512007)(107886003)(52116002)(2906002)(6506007)(2616005)(83380400001)(186003)(1076003)(2004002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?eKgippIZ7WihEooVnqI86xpiy8bCA3zquFx8Osf4JcX2yi2mHyeVVYZTm21X?= =?us-ascii?Q?0AzNI0rIZkUCsEWlKT8P8B7AyN5C6Y943s34zECvW7Hku3Qx7tRRRMDpk8DR?= =?us-ascii?Q?fhxVZ9PlHGhe/cHqTyr1NuLWBbjXUHeD17spdUS7bY16lkD8lD19r4Fieq9G?= =?us-ascii?Q?8JQxxVwt2IuTALAit6rHR9x0OEZA3luSSO3L5Y0kQUfMd5tsPt45YA2AtI5m?= =?us-ascii?Q?StZJkUqcUkoonJLkgG3+aklzF8Tr2O1cAxUo9vwPsxALXYMF7hGwoyBfit5i?= =?us-ascii?Q?CARfwixG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zk2naiti?= =?us-ascii?Q?7spYS83yT1w1l61hy/PnyIGSbfA6o3Dfs6OuCLTiWX01aOsgZC5DjriUAyf/?= =?us-ascii?Q?Q4wMCp/sO3qq55um21kK7+uk5vwH4Jdu+99UEm5YSeZIgm6jyqJuln9S9CN9?= =?us-ascii?Q?ubWwU7GoD3R63+dJTsAZtcsWQlOCvlAHnhgCP+PqxhR2/golcInPKEPVC4Le?= =?us-ascii?Q?cxnVamIHHpmAsRPZ1ABAJlzlk7lxt3HC5NxfivzopfMVUQBERgFXWTgEbwWo?= =?us-ascii?Q?OEsAnDBcADLMD+H0Bc6krw2yc2ogZaWSCnL4tGeCfBfUN01jpPP+fSQESQRI?= =?us-ascii?Q?vnITjWal+7AmzYX6ot/hRsDJGswcRu2X1ajh55kMNR4f9J4FDLaA7i0JzRvf?= =?us-ascii?Q?DE24fIyHV2NV8tUTc2pYfd8lJiAymF5jN3CoUq1h5o+XTgt29RS9fQYvxYVt?= =?us-ascii?Q?MIcY2oRrbHR71gOimS8Nbe1wP95vvFe8EG7toKMlQ3tQylS2wRC/vwtGRrJV?= =?us-ascii?Q?vnNllhaG3dkev59Td/sjYlXlnNkythGEh/cE3nOccAvhmSi5TP0CaEMxqoSk?= =?us-ascii?Q?3oG9sGQipxh6vpHtDW4PUEu7RpVCW9LVaGckjmmaHQMr/nCTXvcl?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2cd0054c-6d1f-4cae-5074-08da1417d3c0 X-MS-Exchange-CrossTenant-AuthSource: MN2PR10MB3213.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Apr 2022 19:42:59.7152 (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: JAji/7wiHYNBJDhuIGaDGpuX7ubMdFIQNX59V8aU3PtqwRN0TsZa2y6HjunDEp2iXGOg7urDD06DgJhXl6qYHg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR1001MB2286 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.425, 18.0.850 definitions=2022-04-01_05:2022-03-30, 2022-04-01 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 adultscore=0 mlxscore=0 phishscore=0 spamscore=0 suspectscore=0 bulkscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2204010093 X-Proofpoint-ORIG-GUID: ngclLeR-qNsteDRs_tdagJZUCauVL0ij X-Proofpoint-GUID: ngclLeR-qNsteDRs_tdagJZUCauVL0ij X-Spam-Status: No, score=-13.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, 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.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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-List-Received-Date: Fri, 01 Apr 2022 19:43:06 -0000 BTF generation currently relies on the internal CTF representation to convert debug info from DWARF dies. This patch adds a new internal header, "ctf-int.h", which defines CTF kinds to be used internally to represent BTF tags which must pass through the CTF container. It also adds a new type for representing information specific to those tags, and a member for that type in ctf_dtdef. This patch also updates ctf_add_reftype to accept a const char * name, and add it for the newly added type. gcc/ * ctf-int.h: New file. * ctfc.cc (ctf_add_reftype): Add NAME parameter. Pass it to ctf_add_generic call. (ctf_add_pointer): Update ctf_add_reftype call accordingly. * ctfc.h (ctf_add_reftype): Analogous change. (ctf_btf_annotation): New. (ctf_dtdef): Add member for it. (enum ctf_dtu_d_union_enum): Likewise. * dwarf2ctf.cc (gen_ctf_modifier_type): Update call to ctf_add_reftype accordingly. --- gcc/ctf-int.h | 29 +++++++++++++++++++++++++++++ gcc/ctfc.cc | 11 +++++++---- gcc/ctfc.h | 17 ++++++++++++++--- gcc/dwarf2ctf.cc | 2 +- 4 files changed, 51 insertions(+), 8 deletions(-) create mode 100644 gcc/ctf-int.h diff --git a/gcc/ctf-int.h b/gcc/ctf-int.h new file mode 100644 index 00000000000..fb5f4aacad6 --- /dev/null +++ b/gcc/ctf-int.h @@ -0,0 +1,29 @@ +/* ctf-int.h - GCC internal definitions used for CTF debug info. + Copyright (C) 2022 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 3, or (at your option) any later +version. + +GCC is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +. */ + +#ifndef GCC_CTF_INT_H +#define GCC_CTF_INT_H 1 + +/* These CTF kinds only exist as a bridge to generating BTF types for + BTF_KIND_DECL_TAG and BTF_KIND_TYPE_TAG. They do not correspond to any + representable type kind in CTF. */ +#define CTF_K_DECL_TAG 62 +#define CTF_K_TYPE_TAG 63 + +#endif /* GCC_CTF_INT_H */ diff --git a/gcc/ctfc.cc b/gcc/ctfc.cc index 6fe44d2e8d4..031a6fff65d 100644 --- a/gcc/ctfc.cc +++ b/gcc/ctfc.cc @@ -107,6 +107,9 @@ ctf_dtu_d_union_selector (ctf_dtdef_ref ctftype) return CTF_DTU_D_ARGUMENTS; case CTF_K_SLICE: return CTF_DTU_D_SLICE; + case CTF_K_DECL_TAG: + case CTF_K_TYPE_TAG: + return CTF_DTU_D_BTFNOTE; default: /* The largest member as default. */ return CTF_DTU_D_ARRAY; @@ -394,15 +397,15 @@ ctf_add_encoded (ctf_container_ref ctfc, uint32_t flag, const char * name, } ctf_id_t -ctf_add_reftype (ctf_container_ref ctfc, uint32_t flag, ctf_id_t ref, - uint32_t kind, dw_die_ref die) +ctf_add_reftype (ctf_container_ref ctfc, uint32_t flag, const char * name, + ctf_id_t ref, uint32_t kind, dw_die_ref die) { ctf_dtdef_ref dtd; ctf_id_t type; gcc_assert (ref <= CTF_MAX_TYPE); - type = ctf_add_generic (ctfc, flag, NULL, &dtd, die); + type = ctf_add_generic (ctfc, flag, name, &dtd, die); dtd->dtd_data.ctti_info = CTF_TYPE_INFO (kind, flag, 0); /* Caller of this API must guarantee that a CTF type with id = ref already exists. This will also be validated for us at link-time. */ @@ -514,7 +517,7 @@ ctf_id_t ctf_add_pointer (ctf_container_ref ctfc, uint32_t flag, ctf_id_t ref, dw_die_ref die) { - return (ctf_add_reftype (ctfc, flag, ref, CTF_K_POINTER, die)); + return (ctf_add_reftype (ctfc, flag, NULL, ref, CTF_K_POINTER, die)); } ctf_id_t diff --git a/gcc/ctfc.h b/gcc/ctfc.h index 18c93c802a0..51f43cd01cb 100644 --- a/gcc/ctfc.h +++ b/gcc/ctfc.h @@ -35,6 +35,7 @@ along with GCC; see the file COPYING3. If not see #include "dwarf2ctf.h" #include "ctf.h" #include "btf.h" +#include "ctf-int.h" /* Invalid CTF type ID definition. */ @@ -151,6 +152,13 @@ typedef struct GTY (()) ctf_func_arg #define ctf_farg_list_next(elem) ((ctf_func_arg_t *)((elem)->farg_next)) +/* BTF support: a BTF type tag or decl tag. */ + +typedef struct GTY (()) ctf_btf_annotation +{ + uint32_t component_idx; +} ctf_btf_annotation_t; + /* Type definition for CTF generation. */ struct GTY ((for_user)) ctf_dtdef @@ -173,6 +181,8 @@ struct GTY ((for_user)) ctf_dtdef ctf_func_arg_t * GTY ((tag ("CTF_DTU_D_ARGUMENTS"))) dtu_argv; /* slice. */ ctf_sliceinfo_t GTY ((tag ("CTF_DTU_D_SLICE"))) dtu_slice; + /* btf annotation. */ + ctf_btf_annotation_t GTY ((tag ("CTF_DTU_D_BTFNOTE"))) dtu_btfnote; } dtd_u; }; @@ -212,7 +222,8 @@ enum ctf_dtu_d_union_enum { CTF_DTU_D_ARRAY, CTF_DTU_D_ENCODING, CTF_DTU_D_ARGUMENTS, - CTF_DTU_D_SLICE + CTF_DTU_D_SLICE, + CTF_DTU_D_BTFNOTE }; enum ctf_dtu_d_union_enum @@ -396,8 +407,8 @@ extern ctf_dvdef_ref ctf_dvd_lookup (const ctf_container_ref ctfc, extern const char * ctf_add_string (ctf_container_ref, const char *, uint32_t *, int); -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_reftype (ctf_container_ref, uint32_t, const char *, + 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); extern ctf_id_t ctf_add_slice (ctf_container_ref, uint32_t, ctf_id_t, diff --git a/gcc/dwarf2ctf.cc b/gcc/dwarf2ctf.cc index 747b2f66107..32495cf4307 100644 --- a/gcc/dwarf2ctf.cc +++ b/gcc/dwarf2ctf.cc @@ -511,7 +511,7 @@ gen_ctf_modifier_type (ctf_container_ref ctfc, dw_die_ref modifier) gcc_assert (kind != CTF_K_MAX); /* Now register the modifier itself. */ if (!ctf_type_exists (ctfc, modifier, &modifier_type_id)) - modifier_type_id = ctf_add_reftype (ctfc, CTF_ADD_ROOT, + modifier_type_id = ctf_add_reftype (ctfc, CTF_ADD_ROOT, NULL, qual_type_id, kind, modifier); -- 2.35.1