This is the mail archive of the gdb-cvs@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]

[binutils-gdb] Revert "Delete program spaces directly when removing inferiors"


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=ef3f321b39c3e31fc49f034257a944d515af182a

commit ef3f321b39c3e31fc49f034257a944d515af182a
Author: Simon Marchi <simon.marchi@ericsson.com>
Date:   Wed Jul 8 11:40:35 2015 -0400

    Revert "Delete program spaces directly when removing inferiors"
    
    Reverted, since it causes a build failure.  It turns out that
    delete_inferior_silent wasn't actually unused.
    
    This reverts commit 0560c645c02eba2828a053039dcfdf676cdd1d00.

Diff:
---
 gdb/ChangeLog    | 26 --------------------------
 gdb/inferior.c   | 39 +++++++++++++++++++++++++++++++--------
 gdb/inferior.h   |  9 ++++++++-
 gdb/mi/mi-main.c |  2 +-
 gdb/progspace.c  | 27 +++++++++++++--------------
 gdb/progspace.h  | 11 ++++-------
 6 files changed, 57 insertions(+), 57 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 0a0d50a..b565dde 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,29 +1,3 @@
-2015-07-08  Simon Marchi  <simon.marchi@ericsson.com>
-
-	* inferior.c (delete_inferior_1): Rename to ...
-	(delete_inferior): ..., remove 'silent' parameter, delete
-	program space when unused and remove call to prune_program_spaces.
-	Remove the old, unused, delete_inferior.
-	(delete_inferior_silent): Remove.
-	(prune_inferiors): Change call from delete_inferior_1 to
-	delete_inferior and remove 'silent' parameter. Remove call to
-	prune_program_spaces.
-	(remove_inferior_command): Idem.
-	* inferior.h (delete_inferior_1): Rename to...
-	(delete_inferior): ..., remove 'silent' parameter and remove the
-	original delete_inferior.
-	(delete_inferior_silent): Remove.
-	* mi/mi-main.c (mi_cmd_remove_inferior): Change call from
-	delete_inferior_1 to delete_inferior and remove 'silent'
-	parameter.
-	* progspace.c (prune_program_spaces): Remove.
-	(pspace_empty_p): Rename to...
-	(program_space_empty_p): ... and make non-static.
-	(delete_program_space): New.
-	* progspace.h (prune_program_spaces): Remove declaration.
-	(program_space_empty_p): New declaration.
-	(delete_program_space): New declaration.
-
 2015-07-08  Jan Kratochvil  <jan.kratochvil@redhat.com>
 
 	PR compile/18484
diff --git a/gdb/inferior.c b/gdb/inferior.c
index 5e98df5..d0783d3 100644
--- a/gdb/inferior.c
+++ b/gdb/inferior.c
@@ -184,8 +184,11 @@ delete_thread_of_inferior (struct thread_info *tp, void *data)
   return 0;
 }
 
+/* If SILENT then be quiet -- don't announce a inferior death, or the
+   exit of its threads.  */
+
 void
-delete_inferior (struct inferior *todel)
+delete_inferior_1 (struct inferior *todel, int silent)
 {
   struct inferior *inf, *infprev;
   struct delete_thread_of_inferior_arg arg;
@@ -200,7 +203,7 @@ delete_inferior (struct inferior *todel)
     return;
 
   arg.pid = inf->pid;
-  arg.silent = 1;
+  arg.silent = silent;
 
   iterate_over_threads (delete_thread_of_inferior, &arg);
 
@@ -211,13 +214,29 @@ delete_inferior (struct inferior *todel)
 
   observer_notify_inferior_removed (inf);
 
-  /* If this program space is rendered useless, remove it. */
-  if (program_space_empty_p (inf->pspace))
-    delete_program_space (inf->pspace);
-
   free_inferior (inf);
 }
 
+void
+delete_inferior (int pid)
+{
+  struct inferior *inf = find_inferior_pid (pid);
+
+  delete_inferior_1 (inf, 0);
+
+  if (print_inferior_events)
+    printf_unfiltered (_("[Inferior %d exited]\n"), pid);
+}
+
+void
+delete_inferior_silent (int pid)
+{
+  struct inferior *inf = find_inferior_pid (pid);
+
+  delete_inferior_1 (inf, 1);
+}
+
+
 /* If SILENT then be quiet -- don't announce a inferior exit, or the
    exit of its threads.  */
 
@@ -490,9 +509,11 @@ prune_inferiors (void)
 	}
 
       *ss_link = ss->next;
-      delete_inferior (ss);
+      delete_inferior_1 (ss, 1);
       ss = *ss_link;
     }
+
+  prune_program_spaces ();
 }
 
 /* Simply returns the count of inferiors.  */
@@ -776,8 +797,10 @@ remove_inferior_command (char *args, int from_tty)
 	  continue;
 	}
 
-      delete_inferior (inf);
+      delete_inferior_1 (inf, 1);
     }
+
+  prune_program_spaces ();
 }
 
 struct inferior *
diff --git a/gdb/inferior.h b/gdb/inferior.h
index 48cba45..2054a2a 100644
--- a/gdb/inferior.h
+++ b/gdb/inferior.h
@@ -418,7 +418,14 @@ extern struct inferior *add_inferior (int pid);
    the CLI.  */
 extern struct inferior *add_inferior_silent (int pid);
 
-extern void delete_inferior (struct inferior *todel);
+/* Delete an existing inferior list entry, due to inferior exit.  */
+extern void delete_inferior (int pid);
+
+extern void delete_inferior_1 (struct inferior *todel, int silent);
+
+/* Same as delete_inferior, but don't print new inferior notifications
+   to the CLI.  */
+extern void delete_inferior_silent (int pid);
 
 /* Delete an existing inferior list entry, due to inferior detaching.  */
 extern void detach_inferior (int pid);
diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c
index 66bcd88..ddfc9d9 100644
--- a/gdb/mi/mi-main.c
+++ b/gdb/mi/mi-main.c
@@ -1964,7 +1964,7 @@ mi_cmd_remove_inferior (char *command, char **argv, int argc)
       set_current_program_space (new_inferior->pspace);
     }
 
-  delete_inferior (inf);
+  delete_inferior_1 (inf, 1 /* silent */);
 }
 
 
diff --git a/gdb/progspace.c b/gdb/progspace.c
index a8f5ea0..1c0a254 100644
--- a/gdb/progspace.c
+++ b/gdb/progspace.c
@@ -235,8 +235,8 @@ save_current_program_space (void)
 
 /* Returns true iff there's no inferior bound to PSPACE.  */
 
-int
-program_space_empty_p (struct program_space *pspace)
+static int
+pspace_empty_p (struct program_space *pspace)
 {
   if (find_inferior_for_program_space (pspace) != NULL)
       return 0;
@@ -244,31 +244,30 @@ program_space_empty_p (struct program_space *pspace)
   return 1;
 }
 
-/* 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. */
+/* Prune away automatically added program spaces that aren't required
+   anymore.  */
 
 void
-delete_program_space (struct program_space *pspace)
+prune_program_spaces (void)
 {
   struct program_space *ss, **ss_link;
-  gdb_assert(pspace != NULL);
-  gdb_assert(pspace != current_program_space);
+  struct program_space *current = current_program_space;
 
   ss = program_spaces;
   ss_link = &program_spaces;
-  while (ss != NULL)
+  while (ss)
     {
-      if (ss == pspace)
+      if (ss == current || !pspace_empty_p (ss))
 	{
-	  *ss_link = ss->next;
-	  break;
+	  ss_link = &ss->next;
+	  ss = *ss_link;
+	  continue;
 	}
 
-      ss_link = &ss->next;
+      *ss_link = ss->next;
+      release_program_space (ss);
       ss = *ss_link;
     }
-
-  release_program_space (pspace);
 }
 
 /* Prints the list of program spaces and their details on UIOUT.  If
diff --git a/gdb/progspace.h b/gdb/progspace.h
index 48f206e..f960093 100644
--- a/gdb/progspace.h
+++ b/gdb/progspace.h
@@ -236,16 +236,9 @@ extern struct program_space *current_program_space;
    pointer to the new object.  */
 extern struct program_space *add_program_space (struct address_space *aspace);
 
-/* 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. */
-extern void delete_program_space (struct program_space *pspace);
-
 /* Returns the number of program spaces listed.  */
 extern int number_of_program_spaces (void);
 
-/* Returns true iff there's no inferior bound to PSPACE.  */
-extern int program_space_empty_p (struct program_space *pspace);
-
 /* Copies program space SRC to DEST.  Copies the main executable file,
    and the main symbol file.  Returns DEST.  */
 extern struct program_space *clone_program_space (struct program_space *dest,
@@ -296,6 +289,10 @@ extern int address_space_num (struct address_space *aspace);
    mappings.  */
 extern void update_address_spaces (void);
 
+/* Prune away automatically added program spaces that aren't required
+   anymore.  */
+extern void prune_program_spaces (void);
+
 /* Reset saved solib data at the start of an solib event.  This lets
    us properly collect the data when calling solib_add, so it can then
    later be printed.  */


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