]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Add psymtab_storage::allocate_dependencies
authorTom Tromey <tom@tromey.com>
Thu, 10 May 2018 22:23:55 +0000 (16:23 -0600)
committerTom Tromey <tom@tromey.com>
Thu, 10 Jan 2019 14:08:14 +0000 (07:08 -0700)
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
2019-01-10  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
gdb/dbxread.c
gdb/dwarf2read.c
gdb/mdebugread.c
gdb/psymtab.h
gdb/xcoffread.c

index 84797bb0a0980fef9aba42fa1ff45b8fa86a738d..5b7551b83e740131ec1964828ae25847c0a6c2ff 100644 (file)
@@ -1,3 +1,15 @@
+2019-01-10  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.
+
 2019-01-10  Tom Tromey  <tom@tromey.com>
 
        * psymtab.c (add_psymbol_to_bcache): Pass psymtab obstack to
index 6149175d732d42c5dfd35fc476a7e88c60833bd2..25bcc2778c57c100fc1e4c60cfef2c63f1f7f7c4 100644 (file)
@@ -2023,9 +2023,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 *));
     }
@@ -2045,7 +2044,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;
 
index 97ca3414b02aeaf5a1034a3b09484229d75ccc97..7546c481812d3af64f6381f9b34261e5e8e24c04 100644 (file)
@@ -6585,8 +6585,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;
 
@@ -8061,8 +8060,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);
@@ -8315,8 +8314,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)
index 7e098009c7de5840429ff2cf3513814c3cb927d7..150cd16f3497ba036082a797aeacd32d28130fe6 100644 (file)
@@ -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;
index d0e596980d12d12548f9c755175c973199705c1e..57570e3d2f41f4827692d0e37adacb70d0af31eb 100644 (file)
@@ -20,6 +20,7 @@
 #ifndef PSYMTAB_H
 #define PSYMTAB_H
 
+#include "gdb_obstack.h"
 #include "symfile.h"
 #include "common/next-iterator.h"
 
@@ -62,6 +63,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
index 50da0789755289943ac5696dbd45bf0377b0fcbf..e93a34b411f831d6ed1defa981c4b161fcc7a02c 100644 (file)
@@ -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;