Message ID | 1633473450-26539-1-git-send-email-indu.bhagat@oracle.com |
---|---|
State | New |
Headers |
Return-Path: <gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D241B3858036 for <patchwork@sourceware.org>; Tue, 5 Oct 2021 22:38:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D241B3858036 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1633473497; bh=mpnKhq5a5llge0W+g8D0lofz96+GQMyOBjemoBATWSQ=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=V3kN5SgOaGy3y98vxSLt4XQKwbSh4uRmzYoaCCeqwd9YfFcaGSPDm541vJPQbzLx1 aZJb4qBLY/ns+1z8U2jSHErJLfz5ctL1RTC5pv8mCmpr/5+X7TyHVzl19SEL2G5wNu gc0Pfqs7H56amJ9KaB/Ie4Df0ruHZc5ZJR7ppDdM= 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 157833858415 for <gcc-patches@gcc.gnu.org>; Tue, 5 Oct 2021 22:37:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 157833858415 Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 195LmgpG020540 for <gcc-patches@gcc.gnu.org>; Tue, 5 Oct 2021 22:37:45 GMT Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by mx0b-00069f02.pphosted.com with ESMTP id 3bg42kuqdn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for <gcc-patches@gcc.gnu.org>; Tue, 05 Oct 2021 22:37:45 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 195MULZ7195770 for <gcc-patches@gcc.gnu.org>; Tue, 5 Oct 2021 22:37:43 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2103.outbound.protection.outlook.com [104.47.58.103]) by aserp3020.oracle.com with ESMTP id 3bev8xewqp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for <gcc-patches@gcc.gnu.org>; Tue, 05 Oct 2021 22:37:42 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MQx+Zdwdd1baidfil7JA5CBUFE2wRgkUYofYafKmqpUB8J7ljjQxObH9ztxXCb2dd8zvkjDsjuxDGqHDo9CM3jZZ2TmNBXXrwkuUP7/hYRSeWz85qbE2yrxBq8HlAFOKPB2kvoGF8mvNcokz1jQOpQZYQkc7H3vl6eEd26J9say27aNQuZFBLAcJ72aZNV95Zy9dMlwxKZtJQB4MgYQDhCUr44DGtLqKwyN3zX3gmopQ7GQQT80vjb3jN++jfKaJ4EavkHzwilvz8qskD/h48uFdEbeSH6hGrfv165Z8dhcTa7JT+9POni7Q/+L4gijS0hjPnBCC8/TV1tXi0xlAkw== 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=mpnKhq5a5llge0W+g8D0lofz96+GQMyOBjemoBATWSQ=; b=FsEboZ719VtomRn6QvkHFRC4nvkxs2DUDCYyFD3vT3oyjMaQsslEzRUK8rMZe7IBHQFEnN3FItx3tjTVkKkDGYhzhRq2s45QYvfbysvFh54cKz2P56TTzpPVm+PBn75cJDg/x3zXGlitQ1j6fVEvH8x0r/OS/XYx7yIR3qq6dvx89wftaNJFwiaZPaEDTR/i4pRW+pImEvuoEIROgZ412tDVi0vFhBLGmG3UWzPBEIWkKPEnpnJ46f6ow8ZkNCc3ZPbaRR0uESSLNF1FWvHjTsaKbmmyIBLfar1OuGI6UBle1syOkcD9exsX9iZKQewsMj0Zn7qGozkHeQJbHer9dw== 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 MWHPR1001MB2158.namprd10.prod.outlook.com (2603:10b6:301:2d::17) by CO6PR10MB5556.namprd10.prod.outlook.com (2603:10b6:303:143::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.18; Tue, 5 Oct 2021 22:37:41 +0000 Received: from MWHPR1001MB2158.namprd10.prod.outlook.com ([fe80::3881:54e3:8f7:d8df]) by MWHPR1001MB2158.namprd10.prod.outlook.com ([fe80::3881:54e3:8f7:d8df%7]) with mapi id 15.20.4566.022; Tue, 5 Oct 2021 22:37:41 +0000 To: gcc-patches@gcc.gnu.org Subject: [PATCH] ctfc: Free CTF type and CTF variable objects in ctfc_delete_container () Date: Tue, 5 Oct 2021 15:37:30 -0700 Message-Id: <1633473450-26539-1-git-send-email-indu.bhagat@oracle.com> X-Mailer: git-send-email 1.8.3.1 Content-Type: text/plain X-ClientProxiedBy: SN4PR0401CA0046.namprd04.prod.outlook.com (2603:10b6:803:2a::32) To MWHPR1001MB2158.namprd10.prod.outlook.com (2603:10b6:301:2d::17) MIME-Version: 1.0 Received: from ibhagatpc.us.oracle.com (137.254.7.168) by SN4PR0401CA0046.namprd04.prod.outlook.com (2603:10b6:803:2a::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.15 via Frontend Transport; Tue, 5 Oct 2021 22:37:40 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f5e4a76e-1969-4e40-02aa-08d98850bdc4 X-MS-TrafficTypeDiagnostic: CO6PR10MB5556: X-Microsoft-Antispam-PRVS: <CO6PR10MB555687F5CDBD5847306BE3BC82AF9@CO6PR10MB5556.namprd10.prod.outlook.com> X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 05ecjjLgo6lyXzLY8zzTNOE6ptx+gqfpftjwI2P66AnjA7gwBhjtLrAndjGYv7tIFp2HHmq5qKsr/SrP3BbZwk4KvBTZl9f7wLtckovuTrFC1GVyh01jFhRViESPPkN5wRuQtpsAnT5C5rC38DSAWgTJOtBfw0k0PohXdkgYawh27MgX4io5pTzCNLEcrXrjHgUi0U0RMbN5M4z9kJjXEdbKOodn8oPKAcNWAs0jBjiPAlc1D5IOuLxLat9IuMc7Sn1Mrit8flg4DsfPLAbL2MP4wEEr0YDNOeZCo2ptyjHEPdKltquqVwml1H4BLUoB01Ei1dj8TRf+86VBH6XsGtUMuEZctXs9rOrHKTgKHX8TvQjUlrC1zoau1Rr9t4XWzR5xHfFCiYxSaa01g+IhtqYFIklw9mvh9NXVaMSfwO5RLfC8gvuFHRk6ypLKpRny4hWplO8VbJFlwLLjO3oe9Vscsc3PnTdlkobTpcfC8JObLjpRhlYoODkEsL4u4lBnPFkkbV63yp9QPUv/oMtl2qehp3Srw/oo05bGA4YdmuFW7I8Zk/1o8cL2A2GCvQONBuKnqQlXQCk8Rgv6byif5t6nBkRzmYsIHMYfm83VzWCfPTbA5OH3EqQnSMyPVTb3scDuWqFpCMbquH8C1omACZu4J83A4FpNL3KhDfvGRDc7XBTn4VWyXYFT5Un9Tcf8MKCFZgNMi5Dzt+hSyM/bgA== 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:(366004)(26005)(508600001)(66476007)(83380400001)(6916009)(2616005)(5660300002)(956004)(316002)(36756003)(7696005)(8936002)(66946007)(6666004)(186003)(2906002)(6486002)(38350700002)(66556008)(86362001)(38100700002)(8676002)(44832011)(52116002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: /2gNl4RFY3cKZFPkQV6lnCPIFwsXEuHpOG/PfvFGM6eAb0iHWQ6PI4zvCtmfA+fdVDm2/aLXPgbIONiw0Jce2hFyjdr9UWVlYf9x4Dp6INwCD5cR1RIpPc2Qj3l8xUyhxgZT+Zghslhg8eRFokgMkv9OxrHyJoi7yeUT7dKZmwBo9ngJVcNkTTpmyDh7TH0/MHsmlpC4tsMkmF262ynUhyk5+z938ek+4v7p8Y4NLrGGtlnv7HBj4aenajWCnMz2s+fz5hJwTEI/9R3TlTO6MA0G2+pFH08Yq1OqKtUBBf061rbSxYYM4ZOYWdbUzNKfFovNvT6BbVq5Plbn71FlOKhjIvh+tnH9UODzY1pFv6HmJW8h4UAopsZ3KY+zVgWJptY1/nMGWetIbZ0fI30ZkjPcrdQ1hWW7/xPT96PO/lzknXlbIGHV7jVlNvuprXv6tIjK+UU7jmXF3WXAVbtk9Hb1CkDyrMNqxHeYdp/tfSoJ0DxS7SuFS8bQ1JWpm5nIaYxaLnI36u0NjCx03NznQvboN2gRXoO7PKKKB9jf/hyC2qCr0+Wxlk077H/GRaSg5olv7ZCjNcicKrBEl55l+ZJ6Vw5RM9UWxX+kg63kPUEn7ikq5dMsK+qtwJOgsnv0gpC2cgG9bWc0lqIXWB4ezBSb+yFAmvgLBW175HbdbG3mkKAuc86UudmmpR/OCL4hyaOwCZ9j6lEmz3AHBXzJjGOKyChRjGPB/DQCoh8K9JIjkX8yUdnJT9uy4pA4sYv9Rgsa3HsukHokriAIZ3CNa7KgNzjTkmQN9bgdqG8YW1MTCU15l27P5aIG16wYbalzWqH13OpzF371RnVcVDOcbKwHouuNZc/7RwNp6tjVwS2p41C0Zf+CwzNjYew5b8E+52t0CF7RmfMujXaSe8mwKFnBySvNRZ/tbTauJOQhpSeRPINz/pb+LFyDJwO5AMlOdX3kCF1qvm3APgDMgll5xFlpxNr4Gu84c3cNNV3uLYzyolJXT6GnPEMgeIva6hpqHHPcpRpqVVx1aoK1+jo3kcgP3rA6p6DuIRy8L8Hcfj+HpkIT/+emWL+3qCJjNquT8wxmLVCstbwbC/UHKwEl2eYG6KAoigepwFPK+fA27S2fbjqyCIFYOOKkAlycPmWA3vNi4Hp8RWxKbuh49xCc0mSji5wTWfKYOjlsKSECDqh6B7cJfJlaQLsST/g9mFhSvsiq7LOdswqNsdOG03chZTrw9Yk6nnCYBnpWUdemC6K8Fwleq7Cs0/4fHjpPUDBgOhdX+XWjiU9q40dqsNsBlEau/tIvPw40M51qoPnAT9BxaBC4SnOfaLZUb30yqzrP X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: f5e4a76e-1969-4e40-02aa-08d98850bdc4 X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2158.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Oct 2021 22:37:41.4055 (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: wsi6Ubcfni67wuWPtoeW2HfYVeo5EuwOufwST6nmwet1AE5/EClbT851BYGQdJxigNCFwDM4Y7CZ0pHMsXRY5w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR10MB5556 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10128 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 adultscore=0 phishscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 suspectscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2109230001 definitions=main-2110050132 X-Proofpoint-GUID: bOGlclslsdpmwzuQskDnZBvwmzBLhA3s X-Proofpoint-ORIG-GUID: bOGlclslsdpmwzuQskDnZBvwmzBLhA3s X-Spam-Status: No, score=-13.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, MSGID_FROM_MTA_HEADER, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP 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 <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> From: Indu Bhagat via Gcc-patches <gcc-patches@gcc.gnu.org> Reply-To: Indu Bhagat <indu.bhagat@oracle.com> Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" <gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org> |
Series |
ctfc: Free CTF type and CTF variable objects in ctfc_delete_container ()
|
|
Commit Message
Indu Bhagat
Oct. 5, 2021, 10:37 p.m. UTC
Hello, This patch fixes an outstanding issue with memory cleanup in the CTF container. Earlier the two hash tables in the CTF container were not cleaned up in ctfc_delete_container (). With this patch, we first free up the CTF type and CTF variable entries in the hash_table slots, followed by emptying of the hash tables. Bootstrapped and regression tested on x86_64. Thanks ------------------------ Free up the memory held by CTF type and CTF variable objects after CTF debug information has been emitted. In ctfc_delete_container (), traverse the hash_table of CTF types and CTF variables and free the memory held by the respective objects. gcc/ChangeLog: * ctfc.c (free_ctf_dtdef_cb): New function. (free_ctf_dvdef_cb): Likewise. (ctfc_delete_container): Free hash table contents. --- gcc/ctfc.c | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-)
Comments
On Wed, Oct 6, 2021 at 12:38 AM Indu Bhagat via Gcc-patches <gcc-patches@gcc.gnu.org> wrote: > > Hello, > > This patch fixes an outstanding issue with memory cleanup in the CTF container. > Earlier the two hash tables in the CTF container were not cleaned up in > ctfc_delete_container (). With this patch, we first free up the CTF type and > CTF variable entries in the hash_table slots, followed by emptying of the hash > tables. > > Bootstrapped and regression tested on x86_64. > > Thanks > > ------------------------ > > Free up the memory held by CTF type and CTF variable objects after CTF debug > information has been emitted. In ctfc_delete_container (), traverse the > hash_table of CTF types and CTF variables and free the memory held by the > respective objects. > > gcc/ChangeLog: > > * ctfc.c (free_ctf_dtdef_cb): New function. > (free_ctf_dvdef_cb): Likewise. > (ctfc_delete_container): Free hash table contents. > --- > gcc/ctfc.c | 31 ++++++++++++++++++++++++++++--- > 1 file changed, 28 insertions(+), 3 deletions(-) > > diff --git a/gcc/ctfc.c b/gcc/ctfc.c > index 73c118e..1f961c9 100644 > --- a/gcc/ctfc.c > +++ b/gcc/ctfc.c > @@ -179,6 +179,26 @@ ctf_dvd_lookup (const ctf_container_ref ctfc, dw_die_ref die) > return NULL; > } > > +/* Callback function to free the CTF type from hash table. */ > + > +static int > +free_ctf_dtdef_cb (ctf_dtdef_ref * slot, void * arg ATTRIBUTE_UNUSED) > +{ > + if (slot && *slot) > + ggc_free (*slot); > + return 1; > +} > + > +/* Callback function to free the CTF variable from hash table. */ > + > +static int > +free_ctf_dvdef_cb (ctf_dvdef_ref * slot, void * arg ATTRIBUTE_UNUSED) > +{ > + if (slot && *slot) > + ggc_free (*slot); > + return 1; > +} > + > /* Append member definition to the list. Member list is a singly-linked list > with list start pointing to the head. */ > > @@ -944,11 +964,16 @@ ctfc_delete_strtab (ctf_strtable_t * strtab) > void > ctfc_delete_container (ctf_container_ref ctfc) > { > - /* FIXME - CTF container can be cleaned up now. > - Will the ggc machinery take care of cleaning up the container structure > - including the hash_map members etc. ? */ > if (ctfc) > { > + ctfc->ctfc_types->traverse<void*, free_ctf_dtdef_cb> (NULL); > + ctfc->ctfc_types->empty (); > + ctfc->ctfc_types = NULL; > + > + ctfc->ctfc_vars->traverse<void*, free_ctf_dvdef_cb> (NULL); > + ctfc->ctfc_vars->empty (); > + ctfc->ctfc_types = NULL; > + it should be enough to set ctfc_types to NULL, in particular traversing the table shouldn't be needed. OK with that change. Thanks, Richard. > ctfc_delete_strtab (&ctfc->ctfc_strtable); > ctfc_delete_strtab (&ctfc->ctfc_aux_strtable); > if (ctfc->ctfc_vars_list) > -- > 1.8.3.1 >
diff --git a/gcc/ctfc.c b/gcc/ctfc.c index 73c118e..1f961c9 100644 --- a/gcc/ctfc.c +++ b/gcc/ctfc.c @@ -179,6 +179,26 @@ ctf_dvd_lookup (const ctf_container_ref ctfc, dw_die_ref die) return NULL; } +/* Callback function to free the CTF type from hash table. */ + +static int +free_ctf_dtdef_cb (ctf_dtdef_ref * slot, void * arg ATTRIBUTE_UNUSED) +{ + if (slot && *slot) + ggc_free (*slot); + return 1; +} + +/* Callback function to free the CTF variable from hash table. */ + +static int +free_ctf_dvdef_cb (ctf_dvdef_ref * slot, void * arg ATTRIBUTE_UNUSED) +{ + if (slot && *slot) + ggc_free (*slot); + return 1; +} + /* Append member definition to the list. Member list is a singly-linked list with list start pointing to the head. */ @@ -944,11 +964,16 @@ ctfc_delete_strtab (ctf_strtable_t * strtab) void ctfc_delete_container (ctf_container_ref ctfc) { - /* FIXME - CTF container can be cleaned up now. - Will the ggc machinery take care of cleaning up the container structure - including the hash_map members etc. ? */ if (ctfc) { + ctfc->ctfc_types->traverse<void*, free_ctf_dtdef_cb> (NULL); + ctfc->ctfc_types->empty (); + ctfc->ctfc_types = NULL; + + ctfc->ctfc_vars->traverse<void*, free_ctf_dvdef_cb> (NULL); + ctfc->ctfc_vars->empty (); + ctfc->ctfc_types = NULL; + ctfc_delete_strtab (&ctfc->ctfc_strtable); ctfc_delete_strtab (&ctfc->ctfc_aux_strtable); if (ctfc->ctfc_vars_list)