This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[for discussion] Update inferior address spaces


I ran into the same problem that Doug reported recently, about
update_address_spaces.  Pedro was kind enough to point me at the
problematic code.  This patch updates all inferiors, which does stop
the wrong behavior... but I can see why Pedro described this to me as
a quick fix.  It raises a question.

If I'm reading this right, there's no actual case of inf->aspace !=
inf->pspace->aspace in the GDB source code.  The DICOS target manages
this by having all breakpoints transparently global.  So the
inf->aspace pointer is redundant.

If I'm wrong, or if there's a patch I don't have which changes this
for DICOS, could you explain the relation of these three things to me?
There's a nice comment in progspace.h, but it doesn't answer this
question: if an inf->aspace != inf->pspace->aspace, what does that
mean for anything that looks at a program space's aspace pointer?

Also, I believe there's a double free in the existing code, fixed in
this patch.  For the shared address space case.

This patch works around the bug, but I don't think it's right as-is.

-- 
Daniel Jacobowitz
CodeSourcery

2010-03-01  Daniel Jacobowitz  <dan@codesourcery.com>

	* progspace.c (update_address_spaces): Update inferior address spaces
	also.

Index: progspace.c
===================================================================
--- progspace.c	(revision 277420)
+++ progspace.c	(working copy)
@@ -430,24 +430,30 @@ void
 update_address_spaces (void)
 {
   int shared_aspace = gdbarch_has_shared_address_space (target_gdbarch);
-  struct address_space *aspace = NULL;
   struct program_space *pspace;
+  struct inferior *inf;
+
+  for (inf = inferior_list; inf; inf = inf->next)
+    gdb_assert (inf->aspace == inf->pspace->aspace);
 
   init_address_spaces ();
 
-  ALL_PSPACES (pspace)
+  if (shared_aspace)
     {
-      free_address_space (pspace->aspace);
-
-      if (shared_aspace)
-	{
-	  if (aspace == NULL)
-	    aspace = new_address_space ();
-	  pspace->aspace = aspace;
-	}
-      else
-	pspace->aspace = new_address_space ();
+      struct address_space *aspace = new_address_space ();
+      free_address_space (current_program_space->aspace);
+      ALL_PSPACES (pspace)
+	pspace->aspace = aspace;
     }
+  else
+    ALL_PSPACES (pspace)
+      {
+	free_address_space (pspace->aspace);
+	pspace->aspace = new_address_space ();
+      }
+
+  for (inf = inferior_list; inf; inf = inf->next)
+    inf->aspace = inf->pspace->aspace;
 }
 
 /* Save the current program space so that it may be restored by a later


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]