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_silent and delete_inferior were unused, which allowed
renaming delete_inferior_1 to delete_inferior. Also, since all calls to
it were with silent=1, I removed that parameter completely.

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.

This obsoletes my previous patch "Add call to prune_program_spaces in
mi_cmd_remove_inferior" [1].

[1] https://sourceware.org/ml/gdb-patches/2014-09/msg00717.html

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.
This commit is contained in:
Simon Marchi 2014-09-29 16:33:10 -04:00
parent 084641963d
commit 0560c645c0
6 changed files with 57 additions and 57 deletions

View file

@ -235,8 +235,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 +244,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