gdb/linux-nat: remove check based on current_inferior in linux_handle_extended_wait
authorSimon Marchi <simon.marchi@polymtl.ca>
Thu, 13 Jan 2022 17:42:39 +0000 (12:42 -0500)
committerSimon Marchi <simon.marchi@efficios.com>
Tue, 18 Jan 2022 18:14:21 +0000 (13:14 -0500)
commit83e7a0ecee4a9eb27ac75651b37870463c625733
treef43f3b43db42e4f34d93952fb85527f2d90a2fa9
parent2bf06f969a2894e8563bd6ada0ce28218e2b7bde
gdb/linux-nat: remove check based on current_inferior in linux_handle_extended_wait

The check removed by this patch, using current_inferior, looks wrong.
When debugging multiple inferiors with the Linux native target and
linux_handle_extended_wait is called, there's no guarantee about which
is the current inferior.  The vfork-done event we receive could be for
any inferior.  If the vfork-done event is for a non-current inferior, we
end up wrongfully ignoring it.  As a result, the core never processes a
TARGET_WAITKIND_VFORK_DONE event, program_space::breakpoints_not_allowed
is never cleared, and breakpoints are never reinserted.  However,
because the Linux native target decided to ignore the event, it resumed
the thread - while breakpoints out.  And that's bad.

The proposed fix is to remove this check.  Always report vfork-done
events and let infrun's logic decide if it should be ignored.  We don't
save much cycles by filtering the event here.

Add a test that sets replicates the situation described above.  See
comments in the test for more details.

Change-Id: Ibe33c1716c3602e847be6c2093120696f2286fbf
gdb/linux-nat.c
gdb/testsuite/gdb.threads/vfork-multi-inferior-sleep.c [new file with mode: 0644]
gdb/testsuite/gdb.threads/vfork-multi-inferior.c [new file with mode: 0644]
gdb/testsuite/gdb.threads/vfork-multi-inferior.exp [new file with mode: 0644]
This page took 0.025042 seconds and 4 git commands to generate.