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/scoped-mock-context.h | |
parent | bf8093108164a7ed7fdf4c6dc751e0b2043caf7b (diff) | |
download | binutils-08bdefb58b78621f50b30f64170e2cdc31c1b2cf.zip binutils-08bdefb58b78621f50b30f64170e2cdc31c1b2cf.tar.gz binutils-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/scoped-mock-context.h')
-rw-r--r-- | gdb/scoped-mock-context.h | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/gdb/scoped-mock-context.h b/gdb/scoped-mock-context.h index 37ffe51..ba3b81e 100644 --- a/gdb/scoped-mock-context.h +++ b/gdb/scoped-mock-context.h @@ -44,13 +44,12 @@ struct scoped_mock_context scoped_restore_current_pspace_and_thread restore_pspace_thread; - /* Add the mock inferior to the inferior list so that look ups by - target+ptid can find it. */ - scoped_restore_tmpl<inferior *> restore_inferior_list - {&inferior_list, &mock_inferior}; - explicit scoped_mock_context (gdbarch *gdbarch) { + /* Add the mock inferior to the inferior list so that look ups by + target+ptid can find it. */ + inferior_list.push_back (mock_inferior); + mock_inferior.thread_list.push_back (mock_thread); mock_inferior.gdbarch = gdbarch; mock_inferior.aspace = mock_pspace.aspace; @@ -70,6 +69,7 @@ struct scoped_mock_context ~scoped_mock_context () { + inferior_list.erase (inferior_list.iterator_to (mock_inferior)); pop_all_targets_at_and_above (process_stratum); } }; |