aboutsummaryrefslogtreecommitdiff
path: root/gdbsupport
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@polymtl.ca>2021-07-14 12:31:36 -0400
committerSimon Marchi <simon.marchi@polymtl.ca>2021-07-17 08:54:40 -0400
commit12be796ca8a107f91b23e393fc228960ea52c6cc (patch)
tree27f8eed9418c3e438a94850f203b0f7589206c2a /gdbsupport
parent1c7682f9f23f47ec47235a6dd97b0f6e8716ebd3 (diff)
downloadgdb-12be796ca8a107f91b23e393fc228960ea52c6cc.zip
gdb-12be796ca8a107f91b23e393fc228960ea52c6cc.tar.gz
gdb-12be796ca8a107f91b23e393fc228960ea52c6cc.tar.bz2
gdb: make all_inferiors_safe actually work
The test gdb.threads/fork-plus-threads.exp fails since 08bdefb58b78 ("gdb: make inferior_list use intrusive_list"): FAIL: gdb.threads/fork-plus-threads.exp: detach-on-fork=off: only inferior 1 left Looking at the log, we see that we are left with a bunch of inferiors in the detach-on-fork=off case: info inferiors^M Num Description Connection Executable ^M * 1 <null> <snip>/fork-plus-threads ^M 2 <null> <snip>/fork-plus-threads ^M 3 <null> <snip>/fork-plus-threads ^M 4 <null> <snip>/fork-plus-threads ^M 5 <null> <snip>/fork-plus-threads ^M 6 <null> <snip>/fork-plus-threads ^M 7 <null> <snip>/fork-plus-threads ^M 8 <null> <snip>/fork-plus-threads ^M 9 <null> <snip>/fork-plus-threads ^M 10 <null> <snip>/fork-plus-threads ^M 11 <null> <snip>/fork-plus-threads ^M (gdb) FAIL: gdb.threads/fork-plus-threads.exp: detach-on-fork=off: only inferior 1 left when we expect to have just one. The problem is prune_inferiors not pruning inferiors. And this is caused by all_inferiors_safe not actually iterating on inferiors. The current implementation: inline all_inferiors_safe_range all_inferiors_safe () { return {}; } default-constructs an all_inferiors_safe_range, which default-constructs an all_inferiors_safe_iterator as its m_begin field, which default-constructs a all_inferiors_iterator. A default-constructed all_inferiors_iterator is an end iterator, which means we have constructed an (end,end) all_inferiors_safe_range. We actually need to pass down the list on which we want to iterator (that is the inferior_list global), so that all_inferiors_iterator's first constructor is chosen. We also pass nullptr as the proc_target filter. In this case, we don't do any filtering, but if in the future all_inferiors_safe needed to allow filtering on process target (like all_inferiors does), we could pass down a process target pointer. basic_safe_iterator's constructor needs to be changed to allow constructing the wrapped iterator with multiple arguments, not just one. With this, gdb.threads/fork-plus-threads.exp is passing once again for me. Change-Id: I650552ede596e3590c4b7606ce403690a0278a01
Diffstat (limited to 'gdbsupport')
-rw-r--r--gdbsupport/safe-iterator.h10
1 files changed, 5 insertions, 5 deletions
diff --git a/gdbsupport/safe-iterator.h b/gdbsupport/safe-iterator.h
index 5cfc5b6..53868d3 100644
--- a/gdbsupport/safe-iterator.h
+++ b/gdbsupport/safe-iterator.h
@@ -48,11 +48,11 @@ public:
typedef typename Iterator::iterator_category iterator_category;
typedef typename Iterator::difference_type difference_type;
- /* Construct using the given argument; the end iterator is default
- constructed. */
- template<typename Arg>
- explicit basic_safe_iterator (Arg &&arg)
- : m_it (std::forward<Arg> (arg)),
+ /* Construct the begin iterator using the given arguments; the end iterator is
+ default constructed. */
+ template<typename... Args>
+ explicit basic_safe_iterator (Args &&...args)
+ : m_it (std::forward<Args> (args)...),
m_next (m_it)
{
if (m_it != m_end)