public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [review] Consolidate partial symtab dependency reading
@ 2019-10-28  2:03 Tom Tromey (Code Review)
  2020-01-26 23:41 ` [pushed] " Sourceware to Gerrit sync (Code Review)
  2020-01-27  1:44 ` Sourceware to Gerrit sync (Code Review)
  0 siblings, 2 replies; 4+ messages in thread
From: Tom Tromey (Code Review) @ 2019-10-28  2:03 UTC (permalink / raw)
  To: gdb-patches

Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/382
......................................................................

Consolidate partial symtab dependency reading

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
2019-10-27  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
---
M gdb/ChangeLog
M gdb/dbxread.c
M gdb/dwarf2read.c
M gdb/mdebugread.c
M gdb/psympriv.h
M gdb/psymtab.c
M gdb/xcoffread.c
7 files changed, 48 insertions(+), 90 deletions(-)



diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 15951c4..81b2cc4 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,18 @@
 2019-10-27  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.
+
+2019-10-27  Tom Tromey  <tom@tromey.com>
+
 	* xcoffread.c (xcoff_psymtab_to_symtab_1): Change argument order.
 	Call expand_psymtab.
 	(xcoff_read_symtab): Call expand_psymtab.
diff --git a/gdb/dbxread.c b/gdb/dbxread.c
index f839cab..fc56823 100644
--- a/gdb/dbxread.c
+++ b/gdb/dbxread.c
@@ -2070,33 +2070,10 @@
 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.  */
     {
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 9b84ae7..aff49f0 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -9641,29 +9641,11 @@
 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;
 
diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c
index a99e3de..51344df 100644
--- a/gdb/mdebugread.c
+++ b/gdb/mdebugread.c
@@ -3855,24 +3855,7 @@
   /* 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.  */
 
diff --git a/gdb/psympriv.h b/gdb/psympriv.h
index c9bf4c4..d6b2ab8 100644
--- a/gdb/psympriv.h
+++ b/gdb/psympriv.h
@@ -134,6 +134,9 @@
      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
   {
diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index ee7f9dc..5554e42 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -1684,6 +1684,32 @@
     }
 }
 
+/* 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)
 {
diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c
index 99ac82f..227ff40 100644
--- a/gdb/xcoffread.c
+++ b/gdb/xcoffread.c
@@ -1824,36 +1824,10 @@
 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)
     {

-- 
Gerrit-Project: binutils-gdb
Gerrit-Branch: master
Gerrit-Change-Id: I8151e05677794e90223edc1a4cb70f7f69137d46
Gerrit-Change-Number: 382
Gerrit-PatchSet: 1
Gerrit-Owner: Tom Tromey <tromey@sourceware.org>
Gerrit-MessageType: newchange

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [pushed] Consolidate partial symtab dependency reading
  2019-10-28  2:03 [review] Consolidate partial symtab dependency reading Tom Tromey (Code Review)
@ 2020-01-26 23:41 ` Sourceware to Gerrit sync (Code Review)
  2020-01-27  1:44 ` Sourceware to Gerrit sync (Code Review)
  1 sibling, 0 replies; 4+ messages in thread
From: Sourceware to Gerrit sync (Code Review) @ 2020-01-26 23:41 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

The original change was created by Tom Tromey.

Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/382
......................................................................

Consolidate partial symtab dependency reading

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
---
M gdb/ChangeLog
M gdb/dbxread.c
M gdb/dwarf2read.c
M gdb/mdebugread.c
M gdb/psympriv.h
M gdb/psymtab.c
M gdb/xcoffread.c
7 files changed, 48 insertions(+), 90 deletions(-)



diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index c6a0251..69f2689 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,18 @@
 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.
 	Call expand_psymtab.
 	(xcoff_read_symtab): Call expand_psymtab.
diff --git a/gdb/dbxread.c b/gdb/dbxread.c
index 2711ea8..99f47c0 100644
--- a/gdb/dbxread.c
+++ b/gdb/dbxread.c
@@ -2068,33 +2068,10 @@
 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.  */
     {
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index c3e0866..dafe01d 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -9663,29 +9663,11 @@
 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;
 
diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c
index 1d0a0fc..5d2fbcd 100644
--- a/gdb/mdebugread.c
+++ b/gdb/mdebugread.c
@@ -3856,24 +3856,7 @@
   /* 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.  */
 
diff --git a/gdb/psympriv.h b/gdb/psympriv.h
index ae98a69..e4b2330 100644
--- a/gdb/psympriv.h
+++ b/gdb/psympriv.h
@@ -134,6 +134,9 @@
      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
   {
diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index 6abc829..c020d15 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -1682,6 +1682,32 @@
     }
 }
 
+/* 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)
 {
diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c
index 1c0db67..b7da3f9 100644
--- a/gdb/xcoffread.c
+++ b/gdb/xcoffread.c
@@ -1819,36 +1819,10 @@
 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)
     {

-- 
Gerrit-Project: binutils-gdb
Gerrit-Branch: master
Gerrit-Change-Id: I8151e05677794e90223edc1a4cb70f7f69137d46
Gerrit-Change-Number: 382
Gerrit-PatchSet: 2
Gerrit-Owner: Tom Tromey <tromey@sourceware.org>
Gerrit-MessageType: newpatchset

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [pushed] Consolidate partial symtab dependency reading
  2019-10-28  2:03 [review] Consolidate partial symtab dependency reading Tom Tromey (Code Review)
  2020-01-26 23:41 ` [pushed] " Sourceware to Gerrit sync (Code Review)
@ 2020-01-27  1:44 ` Sourceware to Gerrit sync (Code Review)
  2020-02-11 19:34   ` Tom de Vries
  1 sibling, 1 reply; 4+ messages in thread
From: Sourceware to Gerrit sync (Code Review) @ 2020-01-27  1:44 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

Sourceware to Gerrit sync has submitted this change.

Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/382
......................................................................

Consolidate partial symtab dependency reading

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
---
M gdb/ChangeLog
M gdb/dbxread.c
M gdb/dwarf2read.c
M gdb/mdebugread.c
M gdb/psympriv.h
M gdb/psymtab.c
M gdb/xcoffread.c
7 files changed, 48 insertions(+), 90 deletions(-)


diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index c6a0251..69f2689 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,18 @@
 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.
 	Call expand_psymtab.
 	(xcoff_read_symtab): Call expand_psymtab.
diff --git a/gdb/dbxread.c b/gdb/dbxread.c
index 2711ea8..99f47c0 100644
--- a/gdb/dbxread.c
+++ b/gdb/dbxread.c
@@ -2068,33 +2068,10 @@
 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.  */
     {
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index c3e0866..dafe01d 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -9663,29 +9663,11 @@
 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;
 
diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c
index 1d0a0fc..5d2fbcd 100644
--- a/gdb/mdebugread.c
+++ b/gdb/mdebugread.c
@@ -3856,24 +3856,7 @@
   /* 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.  */
 
diff --git a/gdb/psympriv.h b/gdb/psympriv.h
index ae98a69..e4b2330 100644
--- a/gdb/psympriv.h
+++ b/gdb/psympriv.h
@@ -134,6 +134,9 @@
      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
   {
diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index 6abc829..c020d15 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -1682,6 +1682,32 @@
     }
 }
 
+/* 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)
 {
diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c
index 1c0db67..b7da3f9 100644
--- a/gdb/xcoffread.c
+++ b/gdb/xcoffread.c
@@ -1819,36 +1819,10 @@
 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)
     {

-- 
Gerrit-Project: binutils-gdb
Gerrit-Branch: master
Gerrit-Change-Id: I8151e05677794e90223edc1a4cb70f7f69137d46
Gerrit-Change-Number: 382
Gerrit-PatchSet: 2
Gerrit-Owner: Tom Tromey <tromey@sourceware.org>
Gerrit-MessageType: merged

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [pushed] Consolidate partial symtab dependency reading
  2020-01-27  1:44 ` Sourceware to Gerrit sync (Code Review)
@ 2020-02-11 19:34   ` Tom de Vries
  0 siblings, 0 replies; 4+ messages in thread
From: Tom de Vries @ 2020-02-11 19:34 UTC (permalink / raw)
  To: tromey, gdb-patches

On 27-01-2020 00:41, Sourceware to Gerrit sync (Code Review) wrote:
> Sourceware to Gerrit sync has submitted this change.
> 
> Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/382
> ......................................................................
> 
> Consolidate partial symtab dependency reading
> 
> 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.

This caused PR25534 - "[cc-with-dwz] FAIL: gdb.cp/m-static.exp: static
const int initialized elsewhere" (
https://sourceware.org/bugzilla/show_bug.cgi?id=25534 ).

Thanks,
- Tom

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-02-11 19:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-28  2:03 [review] Consolidate partial symtab dependency reading Tom Tromey (Code Review)
2020-01-26 23:41 ` [pushed] " Sourceware to Gerrit sync (Code Review)
2020-01-27  1:44 ` Sourceware to Gerrit sync (Code Review)
2020-02-11 19:34   ` Tom de Vries

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).