From patchwork Wed May 23 04:58:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 27439 Received: (qmail 114747 invoked by alias); 23 May 2018 04:59: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 113745 invoked by uid 89); 23 May 2018 04:59:10 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.3 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: gateway21.websitewelcome.com Received: from gateway21.websitewelcome.com (HELO gateway21.websitewelcome.com) (192.185.45.95) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 23 May 2018 04:59:07 +0000 Received: from cm15.websitewelcome.com (cm15.websitewelcome.com [100.42.49.9]) by gateway21.websitewelcome.com (Postfix) with ESMTP id 41DA2400C9F35 for ; Tue, 22 May 2018 23:59:06 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id LLrefGDLGbXuJLLrefXsW5; Tue, 22 May 2018 23:59:06 -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 1fLLre-003S5D-0u; Tue, 22 May 2018 23:59:06 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFA 23/42] Move pending addrmap globals to buildsym_compunit Date: Tue, 22 May 2018 22:58:32 -0600 Message-Id: <20180523045851.11660-24-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: 1fLLre-003S5D-0u 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: 24 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes This moves the pending addrmap-related globals into buildsym_compunit. gdb/ChangeLog 2018-05-22 Tom Tromey * buildsym.c (struct buildsym_compunit) : New members. (pending_addrmap, pending_addrmap_obstack) (pending_addrmap_interesting): Remove. (scoped_free_pendings, record_block_range, make_blockvector) (prepare_for_building, reset_symtab_globals, buildsym_init): Update. --- gdb/ChangeLog | 11 ++++++++++ gdb/buildsym.c | 63 ++++++++++++++++++++++++---------------------------------- 2 files changed, 37 insertions(+), 37 deletions(-) diff --git a/gdb/buildsym.c b/gdb/buildsym.c index 4f820f5dc5..179810f463 100644 --- a/gdb/buildsym.c +++ b/gdb/buildsym.c @@ -218,6 +218,22 @@ struct buildsym_compunit struct context_stack m_popped_context {}; struct subfile *m_current_subfile = nullptr; + + /* The mutable address map for the compilation unit whose symbols + we're currently reading. The symtabs' shared blockvector will + point to a fixed copy of this. */ + struct addrmap *m_pending_addrmap = nullptr; + + /* The obstack on which we allocate pending_addrmap. + If pending_addrmap is NULL, this is uninitialized; otherwise, it is + initialized (and holds pending_addrmap). */ + auto_obstack m_pending_addrmap_obstack; + + /* True if we recorded any ranges in the addrmap that are different + from those in the blockvector already. We set this to false when + we start processing a symfile, and if it's still false at the + end, then we just toss the addrmap. */ + bool m_pending_addrmap_interesting = false; }; /* The work-in-progress of the compunit we are building. @@ -229,22 +245,6 @@ static struct buildsym_compunit *buildsym_compunit; static struct pending *free_pendings; -/* The mutable address map for the compilation unit whose symbols - we're currently reading. The symtabs' shared blockvector will - point to a fixed copy of this. */ -static struct addrmap *pending_addrmap; - -/* The obstack on which we allocate pending_addrmap. - If pending_addrmap is NULL, this is uninitialized; otherwise, it is - initialized (and holds pending_addrmap). */ -static struct obstack pending_addrmap_obstack; - -/* Non-zero if we recorded any ranges in the addrmap that are - different from those in the blockvector already. We set this to - zero when we start processing a symfile, and if it's still zero at - the end, then we just toss the addrmap. */ -static int pending_addrmap_interesting; - /* An obstack used for allocating pending blocks. */ static struct obstack pending_block_obstack; @@ -380,10 +380,6 @@ scoped_free_pendings::~scoped_free_pendings () } global_symbols = NULL; - if (pending_addrmap) - obstack_free (&pending_addrmap_obstack, NULL); - pending_addrmap = NULL; - free_buildsym_compunit (); } @@ -660,15 +656,14 @@ record_block_range (struct block *block, need to record this block in the addrmap. */ if (start != BLOCK_START (block) || end_inclusive + 1 != BLOCK_END (block)) - pending_addrmap_interesting = 1; + buildsym_compunit->m_pending_addrmap_interesting = true; - if (! pending_addrmap) - { - obstack_init (&pending_addrmap_obstack); - pending_addrmap = addrmap_create_mutable (&pending_addrmap_obstack); - } + if (! buildsym_compunit->m_pending_addrmap) + buildsym_compunit->m_pending_addrmap + = addrmap_create_mutable (&buildsym_compunit->m_pending_addrmap_obstack); - addrmap_set_empty (pending_addrmap, start, end_inclusive, block); + addrmap_set_empty (buildsym_compunit->m_pending_addrmap, + start, end_inclusive, block); } static struct blockvector * @@ -706,9 +701,11 @@ make_blockvector (void) /* If we needed an address map for this symtab, record it in the blockvector. */ - if (pending_addrmap && pending_addrmap_interesting) + if (buildsym_compunit->m_pending_addrmap + && buildsym_compunit->m_pending_addrmap_interesting) BLOCKVECTOR_MAP (blockvector) - = addrmap_create_fixed (pending_addrmap, &objfile->objfile_obstack); + = addrmap_create_fixed (buildsym_compunit->m_pending_addrmap, + &objfile->objfile_obstack); else BLOCKVECTOR_MAP (blockvector) = 0; @@ -1037,7 +1034,6 @@ prepare_for_building () a symtab, or by the scoped_free_pendings destructor. */ gdb_assert (file_symbols == NULL); gdb_assert (global_symbols == NULL); - gdb_assert (pending_addrmap == NULL); gdb_assert (buildsym_compunit == nullptr); } @@ -1191,10 +1187,6 @@ reset_symtab_globals (void) file_symbols = NULL; global_symbols = NULL; - if (pending_addrmap) - obstack_free (&pending_addrmap_obstack, NULL); - pending_addrmap = NULL; - free_buildsym_compunit (); } @@ -1785,14 +1777,11 @@ get_current_subfile () void buildsym_init () { - pending_addrmap_interesting = 0; - /* Ensure the scoped_free_pendings destructor was called after the last time. */ gdb_assert (free_pendings == NULL); gdb_assert (pending_blocks == NULL); gdb_assert (file_symbols == NULL); gdb_assert (global_symbols == NULL); - gdb_assert (pending_addrmap == NULL); gdb_assert (buildsym_compunit == NULL); }