Consolidate partial symtab dependency reading
authorTom Tromey <tom@tromey.com>
Wed, 23 Oct 2019 15:46:25 +0000 (09:46 -0600)
committerTom Tromey <tom@tromey.com>
Sun, 26 Jan 2020 23:40:21 +0000 (16:40 -0700)
Most of the symbol readers have code to iterate over a partial symtabs
dependencies, expanding each one and optionally printing a message.
Now that the "second-stage" psymtab expansion is available as a
method, these implementations can all be merged.

This patch also changes a couple more warnings into assertions.

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

* xcoffread.c (xcoff_psymtab_to_symtab_1): Call
read_dependencies.  Add assert.
* psymtab.c (partial_symtab::read_dependencies): New method.
* psympriv.h (struct partial_symtab) <read_dependencies>: New
method.
* mdebugread.c (psymtab_to_symtab_1): Call read_dependencies.
* dwarf2read.c (dwarf2_psymtab::expand_psymtab): Call
read_dependencies.
* dbxread.c (dbx_psymtab_to_symtab_1): Call read_dependencies.
Add assert.

Change-Id: I8151e05677794e90223edc1a4cb70f7f69137d46

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

index c6a0251e8dbbbf456eeb848f4c154ad57c8e6b66..69f26892bcf3c3f0846d0364b20eaa879cdf7b0e 100644 (file)
@@ -1,3 +1,16 @@
+2020-01-26  Tom Tromey  <tom@tromey.com>
+
+       * xcoffread.c (xcoff_psymtab_to_symtab_1): Call
+       read_dependencies.  Add assert.
+       * psymtab.c (partial_symtab::read_dependencies): New method.
+       * psympriv.h (struct partial_symtab) <read_dependencies>: New
+       method.
+       * mdebugread.c (psymtab_to_symtab_1): Call read_dependencies.
+       * dwarf2read.c (dwarf2_psymtab::expand_psymtab): Call
+       read_dependencies.
+       * dbxread.c (dbx_psymtab_to_symtab_1): Call read_dependencies.
+       Add assert.
+
 2020-01-26  Tom Tromey  <tom@tromey.com>
 
        * xcoffread.c (xcoff_psymtab_to_symtab_1): Change argument order.
index 2711ea86b851018b15f7c3c43b6b1b68a733cc0a..99f47c0c9177caa728b4280faa429fe0a3189470 100644 (file)
@@ -2068,33 +2068,10 @@ dbx_end_psymtab (struct objfile *objfile, legacy_psymtab *pst,
 static void
 dbx_psymtab_to_symtab_1 (legacy_psymtab *pst, struct objfile *objfile)
 {
-  int i;
-
-  if (pst->readin)
-    {
-      fprintf_unfiltered (gdb_stderr, "Psymtab for %s already read in.  "
-                         "Shouldn't happen.\n",
-                         pst->filename);
-      return;
-    }
+  gdb_assert (!pst->readin);
 
   /* Read in all partial symtabs on which this one is dependent.  */
-  for (i = 0; i < pst->number_of_dependencies; i++)
-    if (!pst->dependencies[i]->readin)
-      {
-       /* Inform about additional files that need to be read in.  */
-       if (info_verbose)
-         {
-           fputs_filtered (" ", gdb_stdout);
-           wrap_here ("");
-           fputs_filtered ("and ", gdb_stdout);
-           wrap_here ("");
-           printf_filtered ("%s...", pst->dependencies[i]->filename);
-           wrap_here ("");     /* Flush output.  */
-           gdb_flush (gdb_stdout);
-         }
-       pst->dependencies[i]->expand_psymtab (objfile);
-      }
+  pst->read_dependencies (objfile);
 
   if (LDSYMLEN (pst))          /* Otherwise it's a dummy.  */
     {
index c3e0866f37d4ea7f7db6eab5814f65cb42898b10..dafe01d94a08240e146d12b4b4a3055730024dcb 100644 (file)
@@ -9663,29 +9663,11 @@ void
 dwarf2_psymtab::expand_psymtab (struct objfile *objfile)
 {
   struct dwarf2_per_cu_data *per_cu;
-  int i;
 
   if (readin)
     return;
 
-  for (i = 0; i < number_of_dependencies; i++)
-    if (!dependencies[i]->readin
-       && dependencies[i]->user == NULL)
-      {
-        /* Inform about additional files that need to be read in.  */
-        if (info_verbose)
-          {
-           /* FIXME: i18n: Need to make this a single string.  */
-            fputs_filtered (" ", gdb_stdout);
-            wrap_here ("");
-            fputs_filtered ("and ", gdb_stdout);
-            wrap_here ("");
-            printf_filtered ("%s...", dependencies[i]->filename);
-            wrap_here ("");     /* Flush output.  */
-            gdb_flush (gdb_stdout);
-          }
-       dependencies[i]->expand_psymtab (objfile);
-      }
+  read_dependencies (objfile);
 
   per_cu = per_cu_data;
 
index 1d0a0fcdf8f777db26b751936fc07e923a0900c0..5d2fbcd27490c52369c740c04b08011a71fd61b2 100644 (file)
@@ -3856,24 +3856,7 @@ psymtab_to_symtab_1 (legacy_psymtab *pst, struct objfile *objfile)
   /* Read in all partial symtabs on which this one is dependent.
      NOTE that we do have circular dependencies, sigh.  We solved
      that by setting pst->readin before this point.  */
-
-  for (i = 0; i < pst->number_of_dependencies; i++)
-    if (!pst->dependencies[i]->readin)
-      {
-       /* Inform about additional files to be read in.  */
-       if (info_verbose)
-         {
-           fputs_filtered (" ", gdb_stdout);
-           wrap_here ("");
-           fputs_filtered ("and ", gdb_stdout);
-           wrap_here ("");
-           printf_filtered ("%s...",
-                            pst->dependencies[i]->filename);
-           wrap_here ("");     /* Flush output */
-           gdb_flush (gdb_stdout);
-         }
-       pst->dependencies[i]->expand_psymtab (objfile);
-      }
+  pst->read_dependencies (objfile);
 
   /* Do nothing if this is a dummy psymtab.  */
 
index ae98a69bcc678306e4b0800e5917d7e21f17c3d9..e4b23301e9c53f0d1696e440c250e6960d75ea87 100644 (file)
@@ -134,6 +134,9 @@ struct partial_symtab
      expand_psymtab can be made.  */
   virtual void expand_psymtab (struct objfile *) = 0;
 
+  /* Ensure that all the dependencies are read in.  */
+  void read_dependencies (struct objfile *);
+
   /* Return the raw low text address of this partial_symtab.  */
   CORE_ADDR raw_text_low () const
   {
index 6abc829e2ee0a41067efebc98306a24c7fdcfbc6..c020d15721c90bea04829715e45ce93a89bd370c 100644 (file)
@@ -1682,6 +1682,32 @@ partial_symtab::partial_symtab (const char *filename_, struct objfile *objfile)
     }
 }
 
+/* See psympriv.h.  */
+
+void
+partial_symtab::read_dependencies (struct objfile *objfile)
+{
+  for (int i = 0; i < number_of_dependencies; ++i)
+    {
+      if (!dependencies[i]->readin)
+       {
+         /* Inform about additional files to be read in.  */
+         if (info_verbose)
+           {
+             fputs_filtered (" ", gdb_stdout);
+             wrap_here ("");
+             fputs_filtered ("and ", gdb_stdout);
+             wrap_here ("");
+             printf_filtered ("%s...", dependencies[i]->filename);
+             wrap_here ("");   /* Flush output */
+             gdb_flush (gdb_stdout);
+           }
+         dependencies[i]->expand_psymtab (objfile);
+       }
+    }
+}
+
+
 void
 psymtab_storage::discard_psymtab (struct partial_symtab *pst)
 {
index 1c0db67f05b5d5aed1cc0e4c31771342585500f5..b7da3f944c788a51585c3b3abab09e8b03a7040f 100644 (file)
@@ -1819,36 +1819,10 @@ find_linenos (struct bfd *abfd, struct bfd_section *asect, void *vpinfo)
 static void
 xcoff_psymtab_to_symtab_1 (legacy_psymtab *pst, struct objfile *objfile)
 {
-  int i;
-
-  if (!pst)
-    return;
-
-  if (pst->readin)
-    {
-      fprintf_unfiltered
-       (gdb_stderr, "Psymtab for %s already read in.  Shouldn't happen.\n",
-        pst->filename);
-      return;
-    }
+  gdb_assert (!pst->readin);
 
   /* Read in all partial symtabs on which this one is dependent.  */
-  for (i = 0; i < pst->number_of_dependencies; i++)
-    if (!pst->dependencies[i]->readin)
-      {
-       /* Inform about additional files that need to be read in.  */
-       if (info_verbose)
-         {
-           fputs_filtered (" ", gdb_stdout);
-           wrap_here ("");
-           fputs_filtered ("and ", gdb_stdout);
-           wrap_here ("");
-           printf_filtered ("%s...", pst->dependencies[i]->filename);
-           wrap_here ("");     /* Flush output */
-           gdb_flush (gdb_stdout);
-         }
-       pst->dependencies[i]->expand_psymtab (objfile);
-      }
+  pst->read_dependencies (objfile);
 
   if (((struct symloc *) pst->read_symtab_private)->numsyms != 0)
     {
This page took 0.038079 seconds and 4 git commands to generate.