diff options
author | Pedro Alves <pedro@palves.net> | 2020-06-14 20:57:04 +0100 |
---|---|---|
committer | Simon Marchi <simon.marchi@polymtl.ca> | 2021-07-12 20:46:52 -0400 |
commit | 08bdefb58b78621f50b30f64170e2cdc31c1b2cf (patch) | |
tree | 05c3de69ddd7f935e415b7f9c88af0ef798daa91 /gdb/inferior.h | |
parent | bf8093108164a7ed7fdf4c6dc751e0b2043caf7b (diff) | |
download | fsf-binutils-gdb-08bdefb58b78621f50b30f64170e2cdc31c1b2cf.zip fsf-binutils-gdb-08bdefb58b78621f50b30f64170e2cdc31c1b2cf.tar.gz fsf-binutils-gdb-08bdefb58b78621f50b30f64170e2cdc31c1b2cf.tar.bz2 |
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
Diffstat (limited to 'gdb/inferior.h')
-rw-r--r-- | gdb/inferior.h | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/gdb/inferior.h b/gdb/inferior.h index 2ae9f9a..830dec3 100644 --- a/gdb/inferior.h +++ b/gdb/inferior.h @@ -55,6 +55,7 @@ struct thread_info; #include "gdbsupport/refcounted-object.h" #include "gdbsupport/forward-scope-exit.h" #include "gdbsupport/gdb_unique_ptr.h" +#include "gdbsupport/intrusive_list.h" #include "gdbsupport/common-inferior.h" #include "gdbthread.h" @@ -339,7 +340,8 @@ extern void switch_to_inferior_no_thread (inferior *inf); listed exactly once in the inferior list, so placing an inferior in the inferior list is an implicit, not counted strong reference. */ -class inferior : public refcounted_object +class inferior : public refcounted_object, + public intrusive_list_node<inferior> { public: explicit inferior (int pid); @@ -387,9 +389,6 @@ public: bool has_execution () { return target_has_execution (this); } - /* Pointer to next inferior in singly-linked list of inferiors. */ - struct inferior *next = NULL; - /* This inferior's thread list, sorted by creation order. */ intrusive_list<thread_info> thread_list; @@ -653,7 +652,7 @@ private: /* Traverse all inferiors. */ -extern struct inferior *inferior_list; +extern intrusive_list<inferior> inferior_list; /* Pull in the internals of the inferiors ranges and iterators. Must be done after struct inferior is defined. */ |