From patchwork Thu May 10 22:23:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 27222 Received: (qmail 52972 invoked by alias); 10 May 2018 22:24:51 -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 42186 invoked by uid 89); 10 May 2018 22:24:29 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.9 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: gateway32.websitewelcome.com Received: from gateway32.websitewelcome.com (HELO gateway32.websitewelcome.com) (192.185.145.102) 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 gateway32.websitewelcome.com (Postfix) with ESMTP id 0024C57DC1F3 for ; Thu, 10 May 2018 17:24:08 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id Gtyqfw92DBcCXGtyqftsIT; 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 1fGtyq-001ijL-PT; Thu, 10 May 2018 17:24:08 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFA 13/15] Add psymtab_storage::allocate_dependencies Date: Thu, 10 May 2018 16:23:55 -0600 Message-Id: <20180510222357.27332-14-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: 1fGtyq-001ijL-PT 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: 14 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes This adds a new method to psymtab_storage to allocate storage for psymtab dependencies, then changes the symbol readers to use it. This has the effect of moving the storage to the psymtab storage obstack. 2018-05-10 Tom Tromey * xcoffread.c (xcoff_end_psymtab): Use allocate_dependencies. * psymtab.h (psymtab_storage::allocate_dependencies): New method. * mdebugread.c (parse_partial_symbols): Use allocate_dependencies. * dwarf2read.c (dwarf2_create_include_psymtab): Use allocate_dependencies. (process_psymtab_comp_unit_reader) (build_type_psymtab_dependencies): Likewise. * dbxread.c (dbx_end_psymtab): Use allocate_dependencies. --- gdb/ChangeLog | 12 ++++++++++++ gdb/dbxread.c | 9 ++------- gdb/dwarf2read.c | 10 ++++------ gdb/mdebugread.c | 5 +---- gdb/psymtab.h | 6 ++++++ gdb/xcoffread.c | 11 +++-------- 6 files changed, 28 insertions(+), 25 deletions(-) diff --git a/gdb/dbxread.c b/gdb/dbxread.c index c3741fda8a..e1aed48ff7 100644 --- a/gdb/dbxread.c +++ b/gdb/dbxread.c @@ -2092,13 +2092,8 @@ dbx_end_psymtab (struct objfile *objfile, struct partial_symtab *pst, pst->number_of_dependencies = number_dependencies; if (number_dependencies) - { - pst->dependencies = XOBNEWVEC (&objfile->objfile_obstack, - struct partial_symtab *, - number_dependencies); - memcpy (pst->dependencies, dependency_list, - number_dependencies * sizeof (struct partial_symtab *)); - } + pst->dependencies + = objfile->partial_symtabs->allocate_dependencies (number_dependencies); else pst->dependencies = 0; diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 034d5f477f..eca3c62493 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -6512,8 +6512,7 @@ dwarf2_create_include_psymtab (const char *name, struct partial_symtab *pst, subpst->dirname = pst->dirname; } - subpst->dependencies - = XOBNEW (&objfile->objfile_obstack, struct partial_symtab *); + subpst->dependencies = objfile->partial_symtabs->allocate_dependencies (1); subpst->dependencies[0] = pst; subpst->number_of_dependencies = 1; @@ -7989,8 +7988,8 @@ process_psymtab_comp_unit_reader (const struct die_reader_specs *reader, /* Fill in 'dependencies' here; we fill in 'users' in a post-pass. */ pst->number_of_dependencies = len; - pst->dependencies = - XOBNEWVEC (&objfile->objfile_obstack, struct partial_symtab *, len); + pst->dependencies + = objfile->partial_symtabs->allocate_dependencies (len); for (i = 0; VEC_iterate (dwarf2_per_cu_ptr, cu->per_cu->imported_symtabs, i, iter); @@ -8248,8 +8247,7 @@ build_type_psymtab_dependencies (void **slot, void *info) gdb_assert (IS_TYPE_UNIT_GROUP (per_cu)); pst->number_of_dependencies = len; - pst->dependencies = - XOBNEWVEC (&objfile->objfile_obstack, struct partial_symtab *, len); + pst->dependencies = objfile->partial_symtabs->allocate_dependencies (len); for (i = 0; VEC_iterate (sig_type_ptr, tu_group->tus, i, iter); ++i) diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c index 4e07d37f54..8a788b7c69 100644 --- a/gdb/mdebugread.c +++ b/gdb/mdebugread.c @@ -3752,10 +3752,7 @@ parse_partial_symbols (minimal_symbol_reader &reader, source files or a reverse .h -> .c dependency for header files. */ pst->number_of_dependencies = 0; pst->dependencies = - ((struct partial_symtab **) - obstack_alloc (&objfile->objfile_obstack, - ((fh->crfd - 1) - * sizeof (struct partial_symtab *)))); + objfile->partial_symtabs->allocate_dependencies (fh->crfd - 1); for (s_idx = 1; s_idx < fh->crfd; s_idx++) { RFDT rh; diff --git a/gdb/psymtab.h b/gdb/psymtab.h index 36dba3245c..8aacc30e38 100644 --- a/gdb/psymtab.h +++ b/gdb/psymtab.h @@ -20,6 +20,7 @@ #ifndef PSYMTAB_H #define PSYMTAB_H +#include "gdb_obstack.h" #include "symfile.h" /* A bcache for partial symbols. */ @@ -60,6 +61,11 @@ public: return m_obstack; } + struct partial_symtab **allocate_dependencies (int number) + { + return OBSTACK_CALLOC (obstack (), number, struct partial_symtab *); + } + /* Each objfile points to a linked list of partial symtabs derived from this file, one partial symtab structure for each compilation unit diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c index 218cfaef5e..3f2138caa3 100644 --- a/gdb/xcoffread.c +++ b/gdb/xcoffread.c @@ -2079,13 +2079,8 @@ xcoff_end_psymtab (struct objfile *objfile, struct partial_symtab *pst, pst->number_of_dependencies = number_dependencies; if (number_dependencies) - { - pst->dependencies = XOBNEWVEC (&objfile->objfile_obstack, - struct partial_symtab *, - number_dependencies); - memcpy (pst->dependencies, dependency_list, - number_dependencies * sizeof (struct partial_symtab *)); - } + pst->dependencies + = objfile->partial_symtabs->allocate_dependencies (number_dependencies); else pst->dependencies = 0; @@ -2102,7 +2097,7 @@ xcoff_end_psymtab (struct objfile *objfile, struct partial_symtab *pst, /* We could save slight bits of space by only making one of these, shared by the entire set of include files. FIXME-someday. */ subpst->dependencies = - XOBNEW (&objfile->objfile_obstack, struct partial_symtab *); + objfile->partial_symtabs->allocate_dependencies (1); subpst->dependencies[0] = pst; subpst->number_of_dependencies = 1;