From patchwork Sat Feb 15 16:54:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 38109 Received: (qmail 86815 invoked by alias); 15 Feb 2020 16:55:01 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 85853 invoked by uid 89); 15 Feb 2020 16:54:55 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-20.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=ham version=3.3.1 spammy= X-HELO: gateway32.websitewelcome.com Received: from gateway32.websitewelcome.com (HELO gateway32.websitewelcome.com) (192.185.145.125) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 15 Feb 2020 16:54:50 +0000 Received: from cm17.websitewelcome.com (cm17.websitewelcome.com [100.42.49.20]) by gateway32.websitewelcome.com (Postfix) with ESMTP id 779692987A for ; Sat, 15 Feb 2020 10:54:49 -0600 (CST) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id 30iPjD8PuAGTX30iPjOk7B; Sat, 15 Feb 2020 10:54:49 -0600 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=vQbW/0n0uyiYFXt9t5KnFuQ24zLHTD/Ulj2KJnyu5r4=; b=hlwaZFjkUh40lOwsZnbIsa9nh0 WczzRNZKI5rvBqn0nxivKsacOxNrB3Gr58Nokn+R4NAhgfN+kneWGTQDMNVDtzl51teyZLxCgaswh BgfpT/uDmw1DoZZMylaYM8lbJ; Received: from 75-166-123-50.hlrn.qwest.net ([75.166.123.50]:45240 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92) (envelope-from ) id 1j30iP-000xcC-84; Sat, 15 Feb 2020 09:54:49 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 12/14] Fix a memory leak and remove an unused member Date: Sat, 15 Feb 2020 09:54:42 -0700 Message-Id: <20200215165444.32653-13-tom@tromey.com> In-Reply-To: <20200215165444.32653-1-tom@tromey.com> References: <20200215165444.32653-1-tom@tromey.com> I noticed that setup_type_unit_groups leaks the symtab vector -- it allocates this with XNEWVEC, but from what I can tell, nothing frees it. This patch changes it to use XOBNEWVEC. Also, the type_unit_unshareable::num_symtabs member is assigned but never read. So, this removes it. 2020-02-15 Tom Tromey * dwarf2/read.h (struct type_unit_unshareable) : Remove. * dwarf2/read.c (dwarf2_cu::setup_type_unit_groups): Use XOBNEWVEC. --- gdb/ChangeLog | 7 +++++++ gdb/dwarf2/read.c | 7 ++++--- gdb/dwarf2/read.h | 4 ---- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index d1c5bee1109..765fc4e8272 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -10973,9 +10973,10 @@ dwarf2_cu::setup_type_unit_groups (struct die_info *die) process_full_type_unit still needs to know if this is the first time. */ - tu_unshare->num_symtabs = line_header->file_names_size (); - tu_unshare->symtabs = XNEWVEC (struct symtab *, - line_header->file_names_size ()); + tu_unshare->symtabs + = XOBNEWVEC (&COMPUNIT_OBJFILE (cust)->objfile_obstack, + struct symtab *, + line_header->file_names_size ()); auto &file_names = line_header->file_names (); for (i = 0; i < file_names.size (); ++i) diff --git a/gdb/dwarf2/read.h b/gdb/dwarf2/read.h index 8b2e8703aa0..18f3c264a0a 100644 --- a/gdb/dwarf2/read.h +++ b/gdb/dwarf2/read.h @@ -76,10 +76,6 @@ struct type_unit_unshareable so we create an essentially anonymous symtab as the compunit symtab. */ struct compunit_symtab *compunit_symtab = nullptr; - /* The number of symtabs from the line header. - The value here must match line_header.num_file_names. */ - unsigned int num_symtabs = 0; - /* The symbol tables for this TU (obtained from the files listed in DW_AT_stmt_list). WARNING: The order of entries here must match the order of entries