forked from Imagelibrary/binutils-gdb
gdb: make inferior_list use intrusive_list
Change inferior_list, the global list of inferiors, to use intrusive_list. I think most other changes are somewhat obvious fallouts from this change. There is a small change in behavior in scoped_mock_context. Before this patch, constructing a scoped_mock_context would replace the whole inferior list with only the new mock inferior. Tests using two scoped_mock_contexts therefore needed to manually link the two inferiors together, as the second scoped_mock_context would bump the first mock inferior from the thread list. With this patch, a scoped_mock_context adds its mock inferior to the inferior list on construction, and removes it on destruction. This means that tests run with mock inferiors in the inferior list in addition to any pre-existing inferiors (there is always at least one). There is no possible pid clash problem, since each scoped mock inferior uses its own process target, and pids are per process target. Co-Authored-By: Simon Marchi <simon.marchi@efficios.com> Change-Id: I7eb6a8f867d4dcf8b8cd2dcffd118f7270756018
This commit is contained in:
committed by
Simon Marchi
parent
bf80931081
commit
08bdefb58b
@@ -41,7 +41,7 @@
|
||||
|
||||
DEFINE_REGISTRY (inferior, REGISTRY_ACCESS_FIELD)
|
||||
|
||||
struct inferior *inferior_list = NULL;
|
||||
intrusive_list<inferior> inferior_list;
|
||||
static int highest_inferior_num;
|
||||
|
||||
/* See inferior.h. */
|
||||
@@ -126,16 +126,7 @@ add_inferior_silent (int pid)
|
||||
{
|
||||
inferior *inf = new inferior (pid);
|
||||
|
||||
if (inferior_list == NULL)
|
||||
inferior_list = inf;
|
||||
else
|
||||
{
|
||||
inferior *last;
|
||||
|
||||
for (last = inferior_list; last->next != NULL; last = last->next)
|
||||
;
|
||||
last->next = inf;
|
||||
}
|
||||
inferior_list.push_back (*inf);
|
||||
|
||||
gdb::observers::inferior_added.notify (inf);
|
||||
|
||||
@@ -177,25 +168,12 @@ inferior::clear_thread_list (bool silent)
|
||||
}
|
||||
|
||||
void
|
||||
delete_inferior (struct inferior *todel)
|
||||
delete_inferior (struct inferior *inf)
|
||||
{
|
||||
struct inferior *inf, *infprev;
|
||||
|
||||
infprev = NULL;
|
||||
|
||||
for (inf = inferior_list; inf; infprev = inf, inf = inf->next)
|
||||
if (inf == todel)
|
||||
break;
|
||||
|
||||
if (!inf)
|
||||
return;
|
||||
|
||||
inf->clear_thread_list (true);
|
||||
|
||||
if (infprev)
|
||||
infprev->next = inf->next;
|
||||
else
|
||||
inferior_list = inf->next;
|
||||
auto it = inferior_list.iterator_to (*inf);
|
||||
inferior_list.erase (it);
|
||||
|
||||
gdb::observers::inferior_removed.notify (inf);
|
||||
|
||||
@@ -210,17 +188,8 @@ delete_inferior (struct inferior *todel)
|
||||
exit of its threads. */
|
||||
|
||||
static void
|
||||
exit_inferior_1 (struct inferior *inftoex, int silent)
|
||||
exit_inferior_1 (struct inferior *inf, int silent)
|
||||
{
|
||||
struct inferior *inf;
|
||||
|
||||
for (inf = inferior_list; inf; inf = inf->next)
|
||||
if (inf == inftoex)
|
||||
break;
|
||||
|
||||
if (!inf)
|
||||
return;
|
||||
|
||||
inf->clear_thread_list (silent);
|
||||
|
||||
gdb::observers::inferior_exit.notify (inf);
|
||||
@@ -388,22 +357,14 @@ have_live_inferiors (void)
|
||||
void
|
||||
prune_inferiors (void)
|
||||
{
|
||||
inferior *ss;
|
||||
|
||||
ss = inferior_list;
|
||||
while (ss)
|
||||
for (inferior *inf : all_inferiors_safe ())
|
||||
{
|
||||
if (!ss->deletable ()
|
||||
|| !ss->removable
|
||||
|| ss->pid != 0)
|
||||
{
|
||||
ss = ss->next;
|
||||
continue;
|
||||
}
|
||||
if (!inf->deletable ()
|
||||
|| !inf->removable
|
||||
|| inf->pid != 0)
|
||||
continue;
|
||||
|
||||
inferior *ss_next = ss->next;
|
||||
delete_inferior (ss);
|
||||
ss = ss_next;
|
||||
delete_inferior (inf);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user