From patchwork Thu May 10 22:23:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 27221 Received: (qmail 69374 invoked by alias); 10 May 2018 22:25:19 -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 42171 invoked by uid 89); 10 May 2018 22:24:28 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.8 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=sk:templat X-HELO: gateway24.websitewelcome.com Received: from gateway24.websitewelcome.com (HELO gateway24.websitewelcome.com) (192.185.51.251) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 10 May 2018 22:24:23 +0000 Received: from cm10.websitewelcome.com (cm10.websitewelcome.com [100.42.49.4]) by gateway24.websitewelcome.com (Postfix) with ESMTP id 1091A4F677 for ; Thu, 10 May 2018 17:24:08 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id Gtyqfw91dBcCXGtyqftsHv; Thu, 10 May 2018 17:24:08 -0500 X-Authority-Reason: nr=8 Received: from 97-122-176-117.hlrn.qwest.net ([97.122.176.117]:54520 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89_1) (envelope-from ) id 1fGtyp-001ijL-Rm; Thu, 10 May 2018 17:24:07 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFA 10/15] Introduce objfile::reset_psymtabs Date: Thu, 10 May 2018 16:23:52 -0600 Message-Id: <20180510222357.27332-11-tom@tromey.com> In-Reply-To: <20180510222357.27332-1-tom@tromey.com> References: <20180510222357.27332-1-tom@tromey.com> X-BWhitelist: no X-Source-L: No X-Exim-ID: 1fGtyp-001ijL-Rm X-Source-Sender: 97-122-176-117.hlrn.qwest.net (bapiya.Home) [97.122.176.117]:54520 X-Source-Auth: tom+tromey.com X-Email-Count: 11 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes 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-05-09 Tom Tromey * symfile.c (reread_symbols): Call objfile->reset_psymtabs. * objfiles.h (objfile::reset_psymtabs): New method. --- gdb/ChangeLog | 5 +++++ gdb/objfiles.h | 10 ++++++++++ gdb/symfile.c | 13 +------------ 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/gdb/objfiles.h b/gdb/objfiles.h index a49954df60..fd4266d6bf 100644 --- a/gdb/objfiles.h +++ b/gdb/objfiles.h @@ -292,6 +292,16 @@ struct objfile DISABLE_COPY_AND_ASSIGN (objfile); + /* Reset the storage for the partial symbol tables. */ + + void reset_psymtabs () + { + psymbol_map.clear (); + psymtab_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 a23c051c3e..98b063ed02 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -2395,24 +2395,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 (); - objfile->psymtab_map.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; /* obstack_init also initializes the obstack so it is