[RFC,7/7] fbsd nat: Return NULL rather than failing thread_alive.

Message ID 20210607170932.3954-8-jhb@FreeBSD.org
State New
Headers show
  • FreeBSD target async mode and related refactoring
Related show

Commit Message

John Baldwin June 7, 2021, 5:09 p.m.
ptrace on FreeBSD cannot be used against running processes and instead
fails with EBUSY.  This meant that 'info threads' would fail if any of
the threads were running (for example when using schedule-multiple=on
in gdb.base/fork-running-state.exp).  Instead of throwing errors, just
return NULL as no thread name is better than causing info threads to
fail completely.


	* fbsd-nat.c (fbsd_nat_target::thread_alive): Return NULL if
	fbsd_fetch_kinfo_proc or ptrace fail.
 gdb/ChangeLog  | 5 +++++
 gdb/fbsd-nat.c | 4 ++--
 2 files changed, 7 insertions(+), 2 deletions(-)



diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 675cc0aaf6..1f5c939a4d 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@ 
+2021-06-04  John Baldwin  <jhb@FreeBSD.org>
+	* fbsd-nat.c (fbsd_nat_target::thread_alive): Return NULL if
+	fbsd_fetch_kinfo_proc or ptrace fail.
 2021-06-04  John Baldwin  <jhb@FreeBSD.org>
 	* fbsd-nat.c (fbsd_nat_target::resume): Adjust debug message.
diff --git a/gdb/fbsd-nat.c b/gdb/fbsd-nat.c
index 92bd81ea33..d88add7b56 100644
--- a/gdb/fbsd-nat.c
+++ b/gdb/fbsd-nat.c
@@ -815,9 +815,9 @@  fbsd_nat_target::thread_name (struct thread_info *thr)
      if a name has not been set explicitly.  Return a NULL name in
      that case.  */
   if (!fbsd_fetch_kinfo_proc (pid, &kp))
-    perror_with_name (_("Failed to fetch process information"));
+    return NULL;
   if (ptrace (PT_LWPINFO, lwp, (caddr_t) &pl, sizeof pl) == -1)
-    perror_with_name (_("ptrace (PT_LWPINFO)"));
+    return NULL;
   if (strcmp (kp.ki_comm, pl.pl_tdname) == 0)
     return NULL;
   xsnprintf (buf, sizeof buf, "%s", pl.pl_tdname);