gdb.trace/tfind.exp: Force call via global entry point on ppc64le.
[deliverable/binutils-gdb.git] / gdb / progspace.c
index 48cb34a5ce51842d64c1029d81856741bac7cb76..59a784658cdc4e2e112ed074b8447b16e74267d7 100644 (file)
@@ -1,6 +1,6 @@
 /* Program and address space management, for GDB, the GNU debugger.
 
-   Copyright (C) 2009-2014 Free Software Foundation, Inc.
+   Copyright (C) 2009-2016 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -133,8 +133,16 @@ add_program_space (struct address_space *aspace)
 
   program_space_alloc_data (pspace);
 
-  pspace->next = program_spaces;
-  program_spaces = pspace;
+  if (program_spaces == NULL)
+    program_spaces = pspace;
+  else
+    {
+      struct program_space *last;
+
+      for (last = program_spaces; last->next != NULL; last = last->next)
+       ;
+      last->next = pspace;
+    }
 
   return pspace;
 }
@@ -215,7 +223,7 @@ set_current_program_space (struct program_space *pspace)
 static void
 restore_program_space (void *arg)
 {
-  struct program_space *saved_pspace = arg;
+  struct program_space *saved_pspace = (struct program_space *) arg;
 
   set_current_program_space (saved_pspace);
 }
@@ -235,8 +243,8 @@ save_current_program_space (void)
 
 /* Returns true iff there's no inferior bound to PSPACE.  */
 
-static int
-pspace_empty_p (struct program_space *pspace)
+int
+program_space_empty_p (struct program_space *pspace)
 {
   if (find_inferior_for_program_space (pspace) != NULL)
       return 0;
@@ -244,30 +252,31 @@ pspace_empty_p (struct program_space *pspace)
   return 1;
 }
 
-/* Prune away automatically added program spaces that aren't required
-   anymore.  */
+/* Remove a program space from the program spaces list and release it.  It is
+   an error to call this function while PSPACE is the current program space. */
 
 void
-prune_program_spaces (void)
+delete_program_space (struct program_space *pspace)
 {
   struct program_space *ss, **ss_link;
-  struct program_space *current = current_program_space;
+  gdb_assert (pspace != NULL);
+  gdb_assert (pspace != current_program_space);
 
   ss = program_spaces;
   ss_link = &program_spaces;
-  while (ss)
+  while (ss != NULL)
     {
-      if (ss == current || !pspace_empty_p (ss))
+      if (ss == pspace)
        {
-         ss_link = &ss->next;
-         ss = *ss_link;
-         continue;
+         *ss_link = ss->next;
+         break;
        }
 
-      *ss_link = ss->next;
-      release_program_space (ss);
+      ss_link = &ss->next;
       ss = *ss_link;
     }
+
+  release_program_space (pspace);
 }
 
 /* Prints the list of program spaces and their details on UIOUT.  If
This page took 0.0285 seconds and 4 git commands to generate.