mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-12-27 04:52:05 +08:00
5a0c4a06eb
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 replicates the situation described above. See comments in the test for more details. Change-Id: Ibe33c1716c3602e847be6c2093120696f2286fbf
56 lines
1.2 KiB
C
56 lines
1.2 KiB
C
/* This testcase is part of GDB, the GNU debugger.
|
|
|
|
Copyright 2022 Free Software Foundation, Inc.
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
|
|
#include <unistd.h>
|
|
#include <sys/wait.h>
|
|
#include <assert.h>
|
|
|
|
static void
|
|
should_break_here (void)
|
|
{
|
|
}
|
|
|
|
int
|
|
main (void)
|
|
{
|
|
int i;
|
|
|
|
for (i = 0; i < NR_LOOPS; i++)
|
|
{
|
|
int pid = vfork ();
|
|
|
|
if (pid != 0)
|
|
{
|
|
/* Parent */
|
|
int stat;
|
|
int ret = waitpid (pid, &stat, 0);
|
|
assert (ret == pid);
|
|
assert (WIFEXITED (stat));
|
|
assert (WEXITSTATUS (stat) == 12);
|
|
|
|
should_break_here ();
|
|
}
|
|
else
|
|
{
|
|
/* Child */
|
|
_exit (12);
|
|
}
|
|
}
|
|
|
|
return 0;
|
|
}
|