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 CCCEC3954450 for ; Tue, 7 Jun 2022 21:44:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org CCCEC3954450 Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 257IYMBk010570; Tue, 7 Jun 2022 21:44:08 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 3ghvs3ac1v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 07 Jun 2022 21:44:07 +0000 Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.16.1.2/8.16.1.2) with SMTP id 257Ldwat016135; Tue, 7 Jun 2022 21:44:06 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2171.outbound.protection.outlook.com [104.47.59.171]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com with ESMTP id 3gfwu31y54-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 07 Jun 2022 21:44:06 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HI7LlRFhFGZIifT51aooHV5MPxCQI4yPnMHlqn9V7N759sKzx5+G6BTVWvXbduv0sOIam4zb6G+8zVq7Z+Uj7Zn3tGgDk8eunL2uP4N013ERu1Nl0YSoCpDupn9n6np0H6zr5xIvOd3gR2LGl0Mi1iYfLg0OanM6KIyDNUFye84GtBkTw1ynpRa367QqdXfGWrKcmtHdThuBMN5+TrqF1JtNWzs7LQPjMcGNQ1btNg+X/QWuteM/Rs3k4wjGbGUHaqRDmXCaBRflLRiZTUoo6jQXd/FYTZSl10Xes826+JrJFwvB+e+9qeBTiyRVNopIK4hj1m8V+fhbdsE1f2ugMQ== 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=p0rT+e/BsYBNuLmMzaxIBx0hjMcu/QYFugJzbyFARik=; b=lrQWmEswRLSVejIF0WUdQFAe5fqekQtwae71k+GonbEblr5D56Wn3i4oEt6C8eQP5R+c7HBOtTROdpVH/Fu3rvc3pwFl8Rt84zQN8zpD0+6Rcvdfhx2CBIS4e6H+j/wCgyykz5JJn8kbOQ+aJ9szFFu0I4onPEOFCg5uKP+l6tmlAgX6Po2q0dORyxmzOfwEvBOZFniEIeOJmPF4aMTaDG9LXThD5hzkArxnnNVpiaVH9RgQCrrU49MO5wUsI7jjG15nWl9Isfjdp00v6QvIPmHKlvWqVWW3YLNOnee91VeP86sZZ9qo/+Rm9/kVo/3JTLL4rKy5xQOBHh/2NBox+w== 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 BN0PR10MB5351.namprd10.prod.outlook.com (2603:10b6:408:127::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5314.12; Tue, 7 Jun 2022 21:44:04 +0000 Received: from MN2PR10MB3213.namprd10.prod.outlook.com ([fe80::4939:15e0:57cb:87fb]) by MN2PR10MB3213.namprd10.prod.outlook.com ([fe80::4939:15e0:57cb:87fb%5]) with mapi id 15.20.5314.019; Tue, 7 Jun 2022 21:44:04 +0000 From: David Faust To: gcc-patches@gcc.gnu.org Cc: jose.marchesi@oracle.com, yhs@fb.com Subject: [PATCH 4/9] dwarf: generate annotation DIEs Date: Tue, 7 Jun 2022 14:43:37 -0700 Message-Id: <20220607214342.19463-5-david.faust@oracle.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220607214342.19463-1-david.faust@oracle.com> References: <20220607214342.19463-1-david.faust@oracle.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: DM5PR11CA0003.namprd11.prod.outlook.com (2603:10b6:3:115::13) 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: 03fc503e-2f33-4e1d-805c-08da48ced751 X-MS-TrafficTypeDiagnostic: BN0PR10MB5351: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: 2LEhax8tZT90sj7Fea8zc6cWSGRoH3PLT/s4zRC7R5dgB3WrfCNOjOHJf9nVRzZnJWLhjZ+Vvjcm3WSjKI6IK/eQFgQno8Q8DbYQZNk/6m4ig2QvaKlAYqK4cSoeQSNG4BQqCdGWYsaRW3+S/3CSON50Cbq2jKdC7crnPe9flzYO8rx6Fk0U/GLF8tK2tFCj7uSYMNAT0n21aVMzpkrRjk+dGzCpZzANdqBfap/PgmUIZWyBA9zjRYYLPJobAAgKPDSpuE8JlYn4F3c+yYGgJ0f+epJSJnd/vMeU5HwQUVGL6tueGjfRi2Byv5bpFF848Uxnf9+NxIq3y/cjxHDbPNV6fUvI3sKNBQU2jkx491JOIMSeaXPvMzbZJNwXSgjhDQA4gZ5hQX3oRbLYPwtmoTTqKuvSVHkFUVu7OIGtoJOiCQ9N0YVwqK01pixGlvpoXBsIJxsO9akcZQAB0BEJWjTjuq0ghkGl7Q0bJc+QERnfGlUtDD+NTO8mkASqA30ITzk21G1EQtoVEupxGoN/sAXYvXuoUO5wGvsX0EDEkVN2NBN25iqKVvwhoLw6Lhb/rzsxxV3DFM3a0F06adfcsYRwOujn+GfVPPVRD6QjhE1PUY/Dc85C0O8GBark7mTExgCeAKTN1Q9kPaH/lqFtJQ== 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)(508600001)(36756003)(6916009)(8936002)(1076003)(5660300002)(6512007)(2616005)(2906002)(66946007)(86362001)(38100700002)(66556008)(66476007)(316002)(6486002)(44832011)(8676002)(4326008)(6666004)(6506007)(186003)(52116002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?lNCRJ6SV4fnHF4A6EJ98VnLzNp/qiQL/oe1dLgiWRynerezpGQydG3TG7Bs6?= =?us-ascii?Q?7bFE+Fg2ZcabYYezlvIZqx1a7ZMeYEWaNozeJHVH6i1OBGeI+cQOAyVbQHtp?= =?us-ascii?Q?BQ446UpPqrjR7TocuFrz8fXjsuIhHEHVDsSKKMlnT8R5VOPcJFpnsj5EgD/z?= =?us-ascii?Q?kt8BSS5ru/J5A2aLqt+RJlQWNIXOOJedieGdDxHkJpn7lQZKi4SPHqkuVW03?= =?us-ascii?Q?Rq2nms5G2qMnTzb4TQityaCyWysDDGvcp0HXjMleth7x0GOTkgFrgeE16q4L?= =?us-ascii?Q?KqMd8mHhPJYWTsnxo1Bltr0+u6m/4dVob0VW9kTQUTkGkLFhMJuz9jbawqyj?= =?us-ascii?Q?doc5oeob1W/O+l8TsOPmSGDSs2bz+kox4c1ms2WBhUk9MpizNitRtm51Ya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lsGsQoxAY57X0eq+nwBnC3Ay6np8oEKp8CGNQv53dg?= =?us-ascii?Q?YU2chS7HdOamv6KWqdEnyTkN769U5omLd2SoEIr37CApcZ3GqJ/4ikFhhgcQ?= =?us-ascii?Q?cwnNwn3QkCEBii18dOPJwujct1qz3Rj9FeVXVg51w+pi6jetX06cIA2GSRV7?= =?us-ascii?Q?1Uo8Tab8gbbrQffj1v2HXqsYJgmSh5m0WuMNju7M0FdTccMKI6K2y8Jl6qEd?= =?us-ascii?Q?5nZdd7i9gHdsh9RfXz/G49wzaHcZJznzw2msW4RBX/Z/ypbLxKu9W1BRxjAU?= =?us-ascii?Q?x3/6hZ7hSclu03ojNE99yyet/aJiZZ45p1r+T5ympu2RYDszvbK6xyNF7T87?= =?us-ascii?Q?2me8gfgEyo9AwywirXPmMuOioL2mVuFDaVb/rNYhWt+uapQ1UvbSx6wUvrlh?= =?us-ascii?Q?Fc+gVgMsShiQ6hSmeqPpyxtKeHcTGMWS/cVlDWXECn5b+56dyIQcCBNLbLRr?= =?us-ascii?Q?wfeNB1Ue8EvjacxG1kYq2K+9lPnhnw2q5u20oRKdV+qchOIFtluw?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 03fc503e-2f33-4e1d-805c-08da48ced751 X-MS-Exchange-CrossTenant-AuthSource: MN2PR10MB3213.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jun 2022 21:44:04.0814 (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: h1psVi6aJeyijtzt4/C/nA42mssOD4WFsJAar5uVr77Q6qG/hXRSt5xxnEjgTvLyjbSBr033FDrRp7PWeg3zzw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN0PR10MB5351 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.517, 18.0.874 definitions=2022-06-07_10:2022-06-07, 2022-06-07 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxscore=0 adultscore=0 spamscore=0 suspectscore=0 bulkscore=0 malwarescore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2204290000 definitions=main-2206070089 X-Proofpoint-ORIG-GUID: bvWPjpjHeTi-YzXRi9uHhTAZ6FumenGB X-Proofpoint-GUID: bvWPjpjHeTi-YzXRi9uHhTAZ6FumenGB X-Spam-Status: No, score=-12.8 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_H2, 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-List-Received-Date: Tue, 07 Jun 2022 21:44:11 -0000 The "debug_annotate_decl" and "debug_annotate_type" attributes are handled by constructing DW_TAG_GNU_annotation DIEs. These DIEs are children of the declarations or types which they annotate, and convey the information via a string constant. gcc/ * dwarf2out.cc (gen_decl_annotation_dies): New function. (gen_type_annotation_dies): Likewise. (modified_type_die): Call them here, if appropriate. (gen_formal_parameter_die): Likewise. (gen_typedef_die): Likewise. (gen_type_die): Likewise. (gen_decl_die): Likewise. --- gcc/dwarf2out.cc | 94 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) diff --git a/gcc/dwarf2out.cc b/gcc/dwarf2out.cc index 9c61026bb34..aff9f72bd55 100644 --- a/gcc/dwarf2out.cc +++ b/gcc/dwarf2out.cc @@ -13611,6 +13611,78 @@ long_double_as_float128 (tree type) return NULL_TREE; } +/* Given a tree T, which may be a decl or a type, process any + "debug_annotate_decl" attributes on T, provided in ATTR. Construct + DW_TAG_GNU_annotation DIEs appropriately as children of TARGET, usually + the DIE for T. */ + +static void +gen_decl_annotation_dies (tree t, dw_die_ref target) +{ + dw_die_ref die; + tree attr; + + if (t == NULL_TREE || !target) + return; + + if (TYPE_P (t)) + attr = lookup_attribute ("debug_annotate_decl", TYPE_ATTRIBUTES (t)); + else if (DECL_P (t)) + attr = lookup_attribute ("debug_annotate_decl", DECL_ATTRIBUTES (t)); + else + /* This is an error. */ + gcc_unreachable (); + + while (attr != NULL_TREE) + { + die = new_die (DW_TAG_GNU_annotation, target, t); + add_name_attribute (die, IDENTIFIER_POINTER (get_attribute_name (attr))); + add_AT_string (die, DW_AT_const_value, + TREE_STRING_POINTER (TREE_VALUE (TREE_VALUE (attr)))); + attr = TREE_CHAIN (attr); + } + + /* Strip the decl tag attribute to avoid creating multiple copies if we hit + this tree node again in some recursive call. */ + if (TYPE_P (t)) + TYPE_ATTRIBUTES (t) = + remove_attribute ("debug_annotate_decl", TYPE_ATTRIBUTES (t)); + else if (DECL_P (t)) + DECL_ATTRIBUTES (t) = + remove_attribute ("debug_annotate_decl", DECL_ATTRIBUTES (t)); +} + +/* Given a tree TYPE, process any "debug_annotate_type" attributes on + TYPE. Construct DW_TAG_GNU_annotation DIEs appropriately as children of + TARGET, usually the DIE for TYPE. */ + +static void +gen_type_annotation_dies (tree type, dw_die_ref target) +{ + dw_die_ref die; + tree attr; + + if (type == NULL_TREE || !target) + return; + + gcc_assert (TYPE_P (type)); + + attr = lookup_attribute ("debug_annotate_type", TYPE_ATTRIBUTES (type)); + while (attr != NULL_TREE) + { + die = new_die (DW_TAG_GNU_annotation, target, type); + add_name_attribute (die, IDENTIFIER_POINTER (get_attribute_name (attr))); + add_AT_string (die, DW_AT_const_value, + TREE_STRING_POINTER (TREE_VALUE (TREE_VALUE (attr)))); + attr = TREE_CHAIN (attr); + } + + /* Strip the type tag attribute to avoid creating multiple copies if we hit + this type again in some recursive call. */ + TYPE_ATTRIBUTES (type) = + remove_attribute ("debug_annotate_type", TYPE_ATTRIBUTES (type)); +} + /* Given a pointer to an arbitrary ..._TYPE tree node, return a debugging entry that chains the modifiers specified by CV_QUALS in front of the given type. REVERSE is true if the type is to be interpreted in the @@ -14009,6 +14081,9 @@ modified_type_die (tree type, int cv_quals, bool reverse, if (TYPE_ARTIFICIAL (type)) add_AT_flag (mod_type_die, DW_AT_artificial, 1); + /* Generate any annotation DIEs on this type. */ + gen_type_annotation_dies (type, mod_type_die); + return mod_type_die; } @@ -23002,6 +23077,9 @@ gen_formal_parameter_die (tree node, tree origin, bool emit_name_p, gcc_unreachable (); } + /* Generate any annotation DIEs for this decl. */ + gen_decl_annotation_dies (node, parm_die); + return parm_die; } @@ -26076,6 +26154,9 @@ gen_typedef_die (tree decl, dw_die_ref context_die) if (get_AT (type_die, DW_AT_name)) add_pubtype (decl, type_die); + + /* Generate any annotation DIEs for the typedef. */ + gen_decl_annotation_dies (decl, type_die); } /* Generate a DIE for a struct, class, enum or union type. */ @@ -26389,6 +26470,16 @@ gen_type_die (tree type, dw_die_ref context_die) if (die) check_die (die); } + + /* Generate any annotation DIEs on the type. */ + dw_die_ref die = lookup_type_die (type); + if (die) + { + gen_type_annotation_dies (type, die); + + /* "decl" annotations may also be attached to a type. */ + gen_decl_annotation_dies (type, die); + } } } @@ -27145,6 +27236,9 @@ gen_decl_die (tree decl, tree origin, struct vlr_context *ctx, break; } + /* Generate any annotation DIEs for the decl. */ + gen_decl_annotation_dies (decl, lookup_decl_die (decl_or_origin)); + return NULL; } -- 2.36.1