Skip to content

Commit 57c28d4

Browse files
committed
fbsd-nat: Fix thread_alive against a running thread.
FreeBSD's ptrace fails requests with EBUSY against a running process. Report that the thread is alive instead of dead if ptrace fails with EBUSY. This fixes an internal error in the gdb.threads/detach-step-over.exp test where one process was detached while a thread in a second process was being stepped. The core incorrectly assumed the stepping thread had vanished and discarded the pending stepping state. When the thread later reported a SIGTRAP from completing the step, this triggered an assertion.
1 parent e1d94b3 commit 57c28d4

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

gdb/fbsd-nat.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -843,7 +843,13 @@ fbsd_nat_target::thread_alive (ptid_t ptid)
843843

844844
if (ptrace (PT_LWPINFO, ptid.lwp (), (caddr_t) &pl, sizeof pl)
845845
== -1)
846-
return false;
846+
{
847+
/* EBUSY means the associated process is running which means
848+
the LWP does exist and belongs to a running process. */
849+
if (errno == EBUSY)
850+
return true;
851+
return false;
852+
}
847853
#ifdef PL_FLAG_EXITED
848854
if (pl.pl_flags & PL_FLAG_EXITED)
849855
return false;

0 commit comments

Comments
 (0)