public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [PATCH v2 10/12] Add psymtab_storage::allocate_dependencies
Date: Sun, 25 Nov 2018 19:20:00 -0000	[thread overview]
Message-ID: <20181125192043.8405-11-tom@tromey.com> (raw)
In-Reply-To: <20181125192043.8405-1-tom@tromey.com>

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.

gdb/ChangeLog
2018-11-25  Tom Tromey  <tom@tromey.com>

	* 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    |  7 +++----
 gdb/dwarf2read.c | 10 ++++------
 gdb/mdebugread.c |  4 ++--
 gdb/psymtab.h    |  9 +++++++++
 gdb/xcoffread.c  |  7 +++----
 6 files changed, 33 insertions(+), 16 deletions(-)

diff --git a/gdb/dbxread.c b/gdb/dbxread.c
index 7130bb13b4..0aea6e3008 100644
--- a/gdb/dbxread.c
+++ b/gdb/dbxread.c
@@ -2027,9 +2027,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);
+      pst->dependencies
+	= objfile->partial_symtabs->allocate_dependencies (number_dependencies);
       memcpy (pst->dependencies, dependency_list,
 	      number_dependencies * sizeof (struct partial_symtab *));
     }
@@ -2049,7 +2048,7 @@ dbx_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;
 
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 35717aa6a3..48e0cdadc4 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -6579,8 +6579,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;
 
@@ -8055,8 +8054,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);
@@ -8309,8 +8308,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 5cc944fefe..2720aca4cf 100644
--- a/gdb/mdebugread.c
+++ b/gdb/mdebugread.c
@@ -3709,8 +3709,8 @@ parse_partial_symbols (minimal_symbol_reader &reader,
       /* Skip the first file indirect entry as it is a self dependency for
          source files or a reverse .h -> .c dependency for header files.  */
       pst->number_of_dependencies = 0;
-      pst->dependencies = XOBNEWVEC (&objfile->objfile_obstack,
-				     partial_symtab *, (fh->crfd - 1));
+      pst->dependencies
+	= 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 d0b446b5ed..b4cac7834e 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"
 
 struct partial_symbol;
@@ -61,6 +62,14 @@ public:
     return m_obstack;
   }
 
+  /* Allocate storage for the "dependencies" field of a psymtab.
+     NUMBER says how many dependencies there are.  */
+
+  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 daff10db43..9c5fd70e3d 100644
--- a/gdb/xcoffread.c
+++ b/gdb/xcoffread.c
@@ -2075,9 +2075,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);
+      pst->dependencies
+	= objfile->partial_symtabs->allocate_dependencies (number_dependencies);
       memcpy (pst->dependencies, dependency_list,
 	      number_dependencies * sizeof (struct partial_symtab *));
     }
@@ -2096,7 +2095,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;
 
-- 
2.17.2

  reply	other threads:[~2018-11-25 19:20 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-25 19:20 [PATCH v2 00/12] Work toward making psymtabs reusable Tom Tromey
2018-11-25 19:20 ` Tom Tromey [this message]
2018-11-25 19:20 ` [PATCH v2 07/12] Introduce objfile::reset_psymtabs Tom Tromey
2018-11-25 19:20 ` [PATCH v2 08/12] Allocate the address map on the psymtab obstack Tom Tromey
2018-11-25 19:20 ` [PATCH v2 11/12] Make psymtab_storage::free_psymtabs private Tom Tromey
2018-11-25 19:20 ` [PATCH v2 09/12] Move more allocations to psymtab obstack Tom Tromey
2018-11-25 19:20 ` [PATCH v2 12/12] Move psymtabs to their own obstack Tom Tromey
2018-11-25 19:20 ` [PATCH v2 01/12] Remove parameters from start_psymtab_common Tom Tromey
2018-11-25 19:20 ` [PATCH v2 04/12] Change create_demangled_names_hash to take an objfile_per_bfd_storage Tom Tromey
2018-11-25 19:20 ` [PATCH v2 03/12] Simplify calls to init_psymbol_list Tom Tromey
2018-11-25 19:20 ` [PATCH v2 02/12] Change add_psymbol_to_list to use an enum Tom Tromey
2018-11-25 19:20 ` [PATCH v2 05/12] Change symbol_set_names to take an objfile_per_bfd_storage Tom Tromey
2018-11-25 19:22 ` [PATCH v2 06/12] Introduce class psymtab_storage Tom Tromey
2019-01-10 14:09 ` [PATCH v2 00/12] Work toward making psymtabs reusable Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181125192043.8405-11-tom@tromey.com \
    --to=tom@tromey.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).