From: John Baldwin <jhb@FreeBSD.org>
To: gdb-patches@sourceware.org
Subject: [PATCH v2 5/8] fbsd-nat: Fix thread_alive against a running thread.
Date: Mon, 17 Jul 2023 12:20:36 -0700 [thread overview]
Message-ID: <20230717192039.13976-6-jhb@FreeBSD.org> (raw)
In-Reply-To: <20230717192039.13976-1-jhb@FreeBSD.org>
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.
---
gdb/fbsd-nat.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/gdb/fbsd-nat.c b/gdb/fbsd-nat.c
index ed69cb33e93..6ce77c5cd16 100644
--- a/gdb/fbsd-nat.c
+++ b/gdb/fbsd-nat.c
@@ -839,7 +839,13 @@ fbsd_nat_target::thread_alive (ptid_t ptid)
if (ptrace (PT_LWPINFO, ptid.lwp (), (caddr_t) &pl, sizeof pl)
== -1)
- return false;
+ {
+ /* EBUSY means the associated process is running which means
+ the LWP does exist and belongs to a running process. */
+ if (errno == EBUSY)
+ return true;
+ return false;
+ }
#ifdef PL_FLAG_EXITED
if (pl.pl_flags & PL_FLAG_EXITED)
return false;
--
2.40.0
next prev parent reply other threads:[~2023-07-17 19:21 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-17 19:20 [PATCH v2 0/8] Fixes for multiprocess for FreeBSD's native target John Baldwin
2023-07-17 19:20 ` [PATCH v2 1/8] fbsd-nat: Add a list of pending events John Baldwin
2023-07-17 19:20 ` [PATCH v2 2/8] fbsd-nat: Defer any ineligible events reported by wait John Baldwin
2023-07-17 19:20 ` [PATCH v2 3/8] fbsd-nat: Fix resuming and waiting with multiple processes John Baldwin
2023-08-04 16:30 ` Tom Tromey
2023-08-04 21:30 ` John Baldwin
2023-07-17 19:20 ` [PATCH v2 4/8] fbsd-nat: Fix several issues with detaching John Baldwin
2023-07-17 19:20 ` John Baldwin [this message]
2023-07-17 19:20 ` [PATCH v2 6/8] fbsd-nat: Stop a process if it is running before killing it John Baldwin
2023-07-17 19:20 ` [PATCH v2 7/8] fbsd-nat: Defer resume of inferiors John Baldwin
2023-07-17 19:20 ` [PATCH v2 8/8] fbsd-nat: Implement the target stop method John Baldwin
2023-08-04 16:45 ` [PATCH v2 0/8] Fixes for multiprocess for FreeBSD's native target Tom Tromey
2023-08-14 17:51 ` John Baldwin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230717192039.13976-6-jhb@FreeBSD.org \
--to=jhb@freebsd.org \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).