From patchwork Sun Nov 25 19:20:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 30295 Received: (qmail 29814 invoked by alias); 25 Nov 2018 19:20:55 -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 29571 invoked by uid 89); 25 Nov 2018 19:20:53 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.4 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.2 spammy=Reset, pointers X-HELO: gateway34.websitewelcome.com Received: from gateway34.websitewelcome.com (HELO gateway34.websitewelcome.com) (192.185.149.222) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 25 Nov 2018 19:20:50 +0000 Received: from cm12.websitewelcome.com (cm12.websitewelcome.com [100.42.49.8]) by gateway34.websitewelcome.com (Postfix) with ESMTP id 97966CF05 for ; Sun, 25 Nov 2018 13:20:48 -0600 (CST) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id QzxYgGCaXSjJAQzxYge7r5; Sun, 25 Nov 2018 13:20:48 -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=jrgG9cbBwZ6QNSHvLtwMweDvuSIhvtdiVDrB8VMmvVA=; b=KpEufaLeLf2CDbv4DKF9u/VecP N0CCtQemXQ5hvbp4fIF0mTcHyOW7BIlRP3RS7QoqpbHnXLMX2zzIS9b4mXiTwsfAAwyn5z0guEbiw TTdgQRjScHhYmcs5P3bp/c7/C; Received: from 97-122-190-66.hlrn.qwest.net ([97.122.190.66]:52060 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.91) (envelope-from ) id 1gQzxY-001TOx-Cm; Sun, 25 Nov 2018 13:20:48 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH v2 07/12] Introduce objfile::reset_psymtabs Date: Sun, 25 Nov 2018 12:20:38 -0700 Message-Id: <20181125192043.8405-8-tom@tromey.com> In-Reply-To: <20181125192043.8405-1-tom@tromey.com> References: <20181125192043.8405-1-tom@tromey.com> This introduces a new method, objfile::reset_psymtabs, and changes reread_symbols to use it. This method simply destroys the existing partial symbols and recreates the psymtab_storage object. This patch fixes a latent bug -- namely, that reread_symbols should clear objfile::psymbol_map, but does not. I can submit that separately if you'd prefer. gdb/ChangeLog 2018-11-25 Tom Tromey * symfile.c (reread_symbols): Call objfile->reset_psymtabs. * objfiles.h (objfile::reset_psymtabs): New method. --- gdb/ChangeLog | 5 +++++ gdb/objfiles.h | 9 +++++++++ gdb/symfile.c | 12 +----------- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/gdb/objfiles.h b/gdb/objfiles.h index a3ec3884cf..7b132db395 100644 --- a/gdb/objfiles.h +++ b/gdb/objfiles.h @@ -291,6 +291,15 @@ struct objfile DISABLE_COPY_AND_ASSIGN (objfile); + /* Reset the storage for the partial symbol tables. */ + + void reset_psymtabs () + { + psymbol_map.clear (); + partial_symtabs.reset (new psymtab_storage (this)); + } + + /* All struct objfile's are chained together by their next pointers. The program space field "objfiles" (frequently referenced via the macro "object_files") points to the first link in this chain. */ diff --git a/gdb/symfile.c b/gdb/symfile.c index 64fbfb43db..f2d29066b5 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -2479,23 +2479,13 @@ reread_symbols (void) memcpy (offsets, objfile->section_offsets, SIZEOF_N_SECTION_OFFSETS (num_offsets)); - /* FIXME: Do we have to free a whole linked list, or is this - enough? */ - objfile->partial_symtabs->global_psymbols.clear (); - objfile->partial_symtabs->static_psymbols.clear (); - - /* Free the obstacks for non-reusable objfiles. */ - psymbol_bcache_free (objfile->partial_symtabs->psymbol_cache); - objfile->partial_symtabs->psymbol_cache = psymbol_bcache_init (); + objfile->reset_psymtabs (); /* NB: after this call to obstack_free, objfiles_changed will need to be called (see discussion below). */ obstack_free (&objfile->objfile_obstack, 0); objfile->sections = NULL; objfile->compunit_symtabs = NULL; - objfile->partial_symtabs->psymtabs = NULL; - objfile->partial_symtabs->psymtabs_addrmap = NULL; - objfile->partial_symtabs->free_psymtabs = NULL; objfile->template_symbols = NULL; objfile->static_links = NULL;