From 7a41607e01b505db895fcebcad618606cfab1ecf Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Wed, 8 Jul 2015 15:41:01 -0400 Subject: Delete program spaces directly when removing inferiors When deleting an inferior, delete the associated program space as well if it becomes unused. This replaces the "pruning" approach, with which you could forget to call prune_program_spaces (as seen, with the -remove-inferior command, see [1]). This allows to remove the prune_program_spaces function. At the same time, I was able to clean up the delete_inferior* family: - delete_inferior is unused - delete_inferior_silent is only used in monitor_close, but is replaced with discard_all_inferiors [2], so it becomes unused - All remaining calls to delete_inferior_1 are with silent=1, so the parameter is removed - delete_inferior_1 is renamed to delete_inferior I renamed pspace_empty_p to program_space_empty_p. I prefer if the "exported" functions have a more explicit and standard name. Tested on Ubuntu 14.10. [1] https://sourceware.org/ml/gdb-patches/2014-09/msg00717.html [2] See https://sourceware.org/ml/gdb-patches/2015-07/msg00228.html and follow-ups for details. gdb/Changelog: * 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. * monitor.c (monitor_close): Replace call to delete_thread_silent and delete_inferior_silent with discard_all_inferiors. --- gdb/progspace.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'gdb/progspace.h') diff --git a/gdb/progspace.h b/gdb/progspace.h index f960093..48f206e 100644 --- a/gdb/progspace.h +++ b/gdb/progspace.h @@ -236,9 +236,16 @@ 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, @@ -289,10 +296,6 @@ 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. */ -- cgit v1.1