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.
This commit is contained in:
Simon Marchi
2015-07-08 15:41:01 -04:00
parent 7e30235281
commit 7a41607e01
7 changed files with 61 additions and 59 deletions

View File

@@ -184,11 +184,8 @@ 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_1 (struct inferior *todel, int silent)
delete_inferior (struct inferior *todel)
{
struct inferior *inf, *infprev;
struct delete_thread_of_inferior_arg arg;
@@ -203,7 +200,7 @@ delete_inferior_1 (struct inferior *todel, int silent)
return;
arg.pid = inf->pid;
arg.silent = silent;
arg.silent = 1;
iterate_over_threads (delete_thread_of_inferior, &arg);
@@ -214,29 +211,13 @@ delete_inferior_1 (struct inferior *todel, int silent)
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. */
@@ -509,11 +490,9 @@ prune_inferiors (void)
}
*ss_link = ss->next;
delete_inferior_1 (ss, 1);
delete_inferior (ss);
ss = *ss_link;
}
prune_program_spaces ();
}
/* Simply returns the count of inferiors. */
@@ -797,10 +776,8 @@ remove_inferior_command (char *args, int from_tty)
continue;
}
delete_inferior_1 (inf, 1);
delete_inferior (inf);
}
prune_program_spaces ();
}
struct inferior *