From patchwork Wed May 23 04:58:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 27419 Received: (qmail 113521 invoked by alias); 23 May 2018 04:59:08 -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 113195 invoked by uid 89); 23 May 2018 04:59:02 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.1 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= X-HELO: gateway36.websitewelcome.com Received: from gateway36.websitewelcome.com (HELO gateway36.websitewelcome.com) (192.185.185.36) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 23 May 2018 04:59:01 +0000 Received: from cm10.websitewelcome.com (cm10.websitewelcome.com [100.42.49.4]) by gateway36.websitewelcome.com (Postfix) with ESMTP id EB2F6400DE803 for ; Tue, 22 May 2018 23:58:59 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id LLrXfwLTABcCXLLrXfqn77; Tue, 22 May 2018 23:58:59 -0500 X-Authority-Reason: nr=8 Received: from 174-29-44-154.hlrn.qwest.net ([174.29.44.154]:56108 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89_1) (envelope-from ) id 1fLLrX-003S5D-Mr; Tue, 22 May 2018 23:58:59 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFA 05/42] Move pending_macros to buildsym_compunit Date: Tue, 22 May 2018 22:58:14 -0600 Message-Id: <20180523045851.11660-6-tom@tromey.com> In-Reply-To: <20180523045851.11660-1-tom@tromey.com> References: <20180523045851.11660-1-tom@tromey.com> X-BWhitelist: no X-Source-L: No X-Exim-ID: 1fLLrX-003S5D-Mr X-Source-Sender: 174-29-44-154.hlrn.qwest.net (bapiya.Home) [174.29.44.154]:56108 X-Source-Auth: tom+tromey.com X-Email-Count: 6 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes This moves the pending_macros global into buildsym_compunit. gdb/ChangeLog 2018-05-22 Tom Tromey * buildsym.c (~buildsym_compunit): Free the macro table. (struct buildsym_compunit) : New methods. : New member. (pending_macros): Remove. (~scoped_free_pendings, get_macro_table, prepare_for_building) (reset_symtab_globals, end_symtab_get_static_block) (end_symtab_with_blockvector, augment_type_symtab) (buildsym_init): Update. --- gdb/ChangeLog | 12 ++++++++++++ gdb/buildsym.c | 55 +++++++++++++++++++++++++++---------------------------- 2 files changed, 39 insertions(+), 28 deletions(-) diff --git a/gdb/buildsym.c b/gdb/buildsym.c index 5dd6f7e343..c3961254da 100644 --- a/gdb/buildsym.c +++ b/gdb/buildsym.c @@ -118,6 +118,9 @@ struct buildsym_compunit { struct subfile *subfile, *nextsub; + if (m_pending_macros != nullptr) + free_macro_table (m_pending_macros); + for (subfile = subfiles; subfile != NULL; subfile = nextsub) @@ -135,6 +138,22 @@ struct buildsym_compunit m_last_source_file.reset (new_name); } + struct macro_table *get_macro_table () + { + if (m_pending_macros == nullptr) + m_pending_macros = new_macro_table (&objfile->per_bfd->storage_obstack, + objfile->per_bfd->macro_cache, + compunit_symtab); + return m_pending_macros; + } + + struct macro_table *release_macros () + { + struct macro_table *result = m_pending_macros; + m_pending_macros = nullptr; + return result; + } + /* The objfile we're reading debug info from. */ struct objfile *objfile; @@ -169,6 +188,10 @@ struct buildsym_compunit /* Language of this compunit_symtab. */ enum language language; + + /* The macro table for the compilation unit whose symbols we're + currently reading. */ + struct macro_table *m_pending_macros = nullptr; }; /* The work-in-progress of the compunit we are building. @@ -229,10 +252,6 @@ struct subfile_stack static struct subfile_stack *subfile_stack; -/* The macro table for the compilation unit whose symbols we're - currently reading. */ -static struct macro_table *pending_macros; - static void free_buildsym_compunit (void); static int compare_line_numbers (const void *ln1p, const void *ln2p); @@ -342,10 +361,6 @@ scoped_free_pendings::~scoped_free_pendings () } global_symbols = NULL; - if (pending_macros) - free_macro_table (pending_macros); - pending_macros = NULL; - if (pending_addrmap) obstack_free (&pending_addrmap_obstack, NULL); pending_addrmap = NULL; @@ -999,17 +1014,7 @@ get_macro_table (void) struct objfile *objfile; gdb_assert (buildsym_compunit != NULL); - - objfile = buildsym_compunit->objfile; - - if (! pending_macros) - { - pending_macros = new_macro_table (&objfile->per_bfd->storage_obstack, - objfile->per_bfd->macro_cache, - buildsym_compunit->compunit_symtab); - } - - return pending_macros; + return buildsym_compunit->get_macro_table (); } /* Init state to prepare for building a symtab. @@ -1034,7 +1039,6 @@ prepare_for_building (CORE_ADDR start_addr) gdb_assert (file_symbols == NULL); gdb_assert (global_symbols == NULL); gdb_assert (global_using_directives == NULL); - gdb_assert (pending_macros == NULL); gdb_assert (pending_addrmap == NULL); gdb_assert (current_subfile == NULL); gdb_assert (buildsym_compunit == nullptr); @@ -1191,10 +1195,6 @@ reset_symtab_globals (void) global_symbols = NULL; global_using_directives = NULL; - /* We don't free pending_macros here because if the symtab was successfully - built then ownership was transferred to the symtab. */ - pending_macros = NULL; - if (pending_addrmap) obstack_free (&pending_addrmap_obstack, NULL); pending_addrmap = NULL; @@ -1289,7 +1289,7 @@ end_symtab_get_static_block (CORE_ADDR end_addr, int expandable, int required) && file_symbols == NULL && global_symbols == NULL && have_line_numbers == 0 - && pending_macros == NULL + && buildsym_compunit->m_pending_macros == NULL && global_using_directives == NULL) { /* Ignore symtabs that have no functions with real debugging info. */ @@ -1442,7 +1442,7 @@ end_symtab_with_blockvector (struct block *static_block, COMPUNIT_BLOCK_LINE_SECTION (cu) = section; - COMPUNIT_MACRO_TABLE (cu) = pending_macros; + COMPUNIT_MACRO_TABLE (cu) = buildsym_compunit->release_macros (); /* Default any symbols without a specified symtab to the primary symtab. */ { @@ -1593,7 +1593,7 @@ augment_type_symtab (void) } if (pending_blocks != NULL) complaint (&symfile_complaints, _("Blocks in a type symtab")); - if (pending_macros != NULL) + if (buildsym_compunit->m_pending_macros != NULL) complaint (&symfile_complaints, _("Macro in a type symtab")); if (have_line_numbers) complaint (&symfile_complaints, @@ -1765,7 +1765,6 @@ buildsym_init (void) gdb_assert (file_symbols == NULL); gdb_assert (global_symbols == NULL); gdb_assert (global_using_directives == NULL); - gdb_assert (pending_macros == NULL); gdb_assert (pending_addrmap == NULL); gdb_assert (buildsym_compunit == NULL); }