[PATCH v4 06/13] inf-ptrace: Raise an error if waitpid() fails.

John Baldwin jhb@FreeBSD.org
Mon Dec 6 19:32:02 GMT 2021


Previously this returned a TARGET_WAITKIND_SIGNALLED event for
inferior_ptid.  However, inferior_ptid is invalid during ::wait()
methods after the multi-target changes, so this was triggering an
assertion further up the stack.
---
 gdb/inf-ptrace.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/gdb/inf-ptrace.c b/gdb/inf-ptrace.c
index 2e7a03c63f5..1b009247251 100644
--- a/gdb/inf-ptrace.c
+++ b/gdb/inf-ptrace.c
@@ -319,13 +319,8 @@ inf_ptrace_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus,
 
       if (pid == -1)
 	{
-	  fprintf_unfiltered (gdb_stderr,
-			      _("Child process unexpectedly missing: %s.\n"),
-			      safe_strerror (save_errno));
-
-	  /* Claim it exited with unknown signal.  */
-	  ourstatus->set_signalled (GDB_SIGNAL_UNKNOWN);
-	  return inferior_ptid;
+	  errno = save_errno;
+	  perror_with_name (_("Child process unexpectedly missing"));
 	}
 
       /* Ignore terminated detached child processes.  */
-- 
2.32.0



More information about the Gdb-patches mailing list