Change allocate_psymtab to be a constructor
authorTom Tromey <tom@tromey.com>
Tue, 22 Oct 2019 22:57:35 +0000 (16:57 -0600)
committerTom Tromey <tom@tromey.com>
Sun, 26 Jan 2020 23:40:21 +0000 (16:40 -0700)
This is the next step in getting the symbol readers to allocate
psymtabs themselves: change allocate_psymtab to be an ordinary
constructor, and then use "new" at the previous call sites.  Note that
this doesn't get us all the way -- start_psymtab_common is still
allocating a partial symtab.

gdb/ChangeLog
2020-01-26  Tom Tromey  <tom@tromey.com>

* xcoffread.c (xcoff_end_psymtab): Use new.
* psymtab.c (start_psymtab_common): Use new.
(partial_symtab::partial_symtab): Rename from allocate_psymtab.
Update.
* psympriv.h (struct partial_symtab): Add parameters to
constructor.  Don't inline.
(allocate_psymtab): Don't declare.
* mdebugread.c (new_psymtab): Use new.
* dwarf2read.c (dwarf2_create_include_psymtab): Use new.
* dbxread.c (dbx_end_psymtab): Use new.

Change-Id: Iffeae64c925050b90b9916cbc36e15b26ff42226

gdb/ChangeLog
gdb/dbxread.c
gdb/dwarf2read.c
gdb/mdebugread.c
gdb/psympriv.h
gdb/psymtab.c
gdb/xcoffread.c

index 475ebbb116b3ea544fbb8bdb6dbf53c4ef9d5ce5..854ac3144cf6b9f7cb6e9bfe2aa69a37075fee2d 100644 (file)
@@ -1,3 +1,16 @@
+2020-01-26  Tom Tromey  <tom@tromey.com>
+
+       * xcoffread.c (xcoff_end_psymtab): Use new.
+       * psymtab.c (start_psymtab_common): Use new.
+       (partial_symtab::partial_symtab): Rename from allocate_psymtab.
+       Update.
+       * psympriv.h (struct partial_symtab): Add parameters to
+       constructor.  Don't inline.
+       (allocate_psymtab): Don't declare.
+       * mdebugread.c (new_psymtab): Use new.
+       * dwarf2read.c (dwarf2_create_include_psymtab): Use new.
+       * dbxread.c (dbx_end_psymtab): Use new.
+
 2020-01-26  Tom Tromey  <tom@tromey.com>
 
        * psymtab.h (class psymtab_storage) <install_psymtab>: Rename from
index d4d7901e914885b404f08a06a371acb2989cc09d..95270856a07df78b7e1733f512d17dab70025876 100644 (file)
@@ -2025,7 +2025,7 @@ dbx_end_psymtab (struct objfile *objfile, struct partial_symtab *pst,
   for (i = 0; i < num_includes; i++)
     {
       struct partial_symtab *subpst =
-       allocate_psymtab (include_list[i], objfile);
+       new partial_symtab (include_list[i], objfile);
 
       subpst->read_symtab_private =
        XOBNEW (&objfile->objfile_obstack, struct symloc);
index 63944105edc1d88c059e1df63906b6b015159ade..2cac2864350036cf660a0557811c2160df427bc0 100644 (file)
@@ -6695,7 +6695,7 @@ static void
 dwarf2_create_include_psymtab (const char *name, struct partial_symtab *pst,
                                struct objfile *objfile)
 {
-  struct partial_symtab *subpst = allocate_psymtab (name, objfile);
+  struct partial_symtab *subpst = new partial_symtab (name, objfile);
 
   if (!IS_ABSOLUTE_PATH (subpst->filename))
     {
index f28c0b25cbfc6f71cb21fa8d9f3976c90862346a..2ec30ec1deb7244263e815068435960accd111b4 100644 (file)
@@ -4662,7 +4662,7 @@ new_psymtab (const char *name, struct objfile *objfile)
 {
   struct partial_symtab *psymtab;
 
-  psymtab = allocate_psymtab (name, objfile);
+  psymtab = new partial_symtab (name, objfile);
 
   /* Keep a backpointer to the file's symbols.  */
 
index ce28112439caf4c94295ebd2dc2fa606fa70fa9f..74ff10ef6a6f2c1ac48b77dbe078723795d8ee6b 100644 (file)
@@ -104,12 +104,14 @@ enum psymtab_search_status
 
 struct partial_symtab
 {
-  partial_symtab ()
-    : searched_flag (PST_NOT_SEARCHED),
-      text_low_valid (0),
-      text_high_valid (0)
-  {
-  }
+  /* Allocate a new partial symbol table associated with OBJFILE.
+     FILENAME (which must be non-NULL) is the filename of this partial
+     symbol table; it is copied into the appropriate storage.  The
+     partial symtab will also be installed using
+     psymtab_storage::install.  */
+
+  partial_symtab (const char *filename, struct objfile *objfile)
+    ATTRIBUTE_NONNULL (2) ATTRIBUTE_NONNULL (3);
 
   /* Return the raw low text address of this partial_symtab.  */
   CORE_ADDR raw_text_low () const
@@ -329,16 +331,6 @@ extern struct partial_symtab *start_psymtab_common (struct objfile *,
 
 extern void end_psymtab_common (struct objfile *, struct partial_symtab *);
 
-/* Allocate a new partial symbol table associated with OBJFILE.
-   FILENAME (which must be non-NULL) is the filename of this partial
-   symbol table; it is copied into the appropriate storage.  A new
-   partial symbol table is returned; aside from "next" and "filename",
-   its fields are initialized to zero.  */
-
-extern struct partial_symtab *allocate_psymtab (const char *filename,
-                                               struct objfile *objfile)
-  ATTRIBUTE_NONNULL (1);
-
 static inline void
 discard_psymtab (struct objfile *objfile, struct partial_symtab *pst)
 {
index 975737c559fcae96668aafeb47b4a5b9b1daba06..844e71861422434b8b3534a4c7e2f1073983c9f2 100644 (file)
@@ -1487,7 +1487,7 @@ start_psymtab_common (struct objfile *objfile,
 {
   struct partial_symtab *psymtab;
 
-  psymtab = allocate_psymtab (filename, objfile);
+  psymtab = new partial_symtab (filename, objfile);
   psymtab->set_text_low (textlow);
   psymtab->set_text_high (psymtab->raw_text_low ()); /* default */
   psymtab->globals_offset = objfile->partial_symtabs->global_psymbols.size ();
@@ -1646,16 +1646,17 @@ init_psymbol_list (struct objfile *objfile, int total_symbols)
 
 /* See psympriv.h.  */
 
-struct partial_symtab *
-allocate_psymtab (const char *filename, struct objfile *objfile)
+partial_symtab::partial_symtab (const char *filename_, struct objfile *objfile)
+  : searched_flag (PST_NOT_SEARCHED),
+    text_low_valid (0),
+    text_high_valid (0)
 {
-  struct partial_symtab *psymtab = new partial_symtab;
-  objfile->partial_symtabs->install_psymtab (psymtab);
+  objfile->partial_symtabs->install_psymtab (this);
 
-  psymtab->filename
+  filename
     = ((const char *) objfile->per_bfd->filename_cache.insert
-       (filename, strlen (filename) + 1));
-  psymtab->compunit_symtab = NULL;
+       (filename_, strlen (filename_) + 1));
+  compunit_symtab = NULL;
 
   if (symtab_create_debug)
     {
@@ -1674,10 +1675,8 @@ allocate_psymtab (const char *filename, struct objfile *objfile)
        }
       fprintf_filtered (gdb_stdlog,
                        "Created psymtab %s for module %s.\n",
-                       host_address_to_string (psymtab), filename);
+                       host_address_to_string (this), filename);
     }
-
-  return psymtab;
 }
 
 void
index 27e49f755e8674b0e11e3f895c6d58ff2ff4a13f..be10c4f3d5c834e2ea99ddc52af2175a018c05a1 100644 (file)
@@ -2065,7 +2065,7 @@ xcoff_end_psymtab (struct objfile *objfile, struct partial_symtab *pst,
   for (i = 0; i < num_includes; i++)
     {
       struct partial_symtab *subpst =
-       allocate_psymtab (include_list[i], objfile);
+       new partial_symtab (include_list[i], objfile);
 
       subpst->read_symtab_private = XOBNEW (&objfile->objfile_obstack, symloc);
       ((struct symloc *) subpst->read_symtab_private)->first_symnum = 0;
This page took 0.054863 seconds and 4 git commands to generate.