gdb/hurd: handle inferiors exiting

While testing on GNU/Hurd (i386) I noticed that GDB crashes when an
inferior exits, with this error:

  inferior.c:293: internal-error: inferior* find_inferior_pid(process_stratum_target*, int): Assertion `pid != 0' failed.

The problem appears to be in gnu_nat_target::wait.

We always set inferior_ptid to null_ptid before calling target_wait,
this has been the case since the multi-target changes were made to GDB
in commit:

  commit 5b6d1e4fa4
  Date:   Fri Jan 10 20:06:08 2020 +0000

      Multi-target support

With follow up changes in commit:

  commit 24ed6739b6
  Date:   Thu Jan 30 14:35:40 2020 +0000

      gdb/remote: Restore support for 'S' stop reply packet

Unfortunately, the GNU/Hurd target is still relying on the value of
inferior_ptid in the case where an inferior exits - we return the
value of inferior_ptid as the pid of the process that exited.  This
was fine in the single target world, where inferior_ptid identified
the one running inferior, but this is no longer good enough.

Instead, we should return a ptid containing the pid of the process
that exited, as obtained from the wait event, and this is what this
commit does.

I've not run the full testsuite on GNU/Hurd as there appear to be lots
of other issues with this target that makes running the full testsuite
very painful, but I think this looks like a small easy improvement.
This commit is contained in:
Andrew Burgess 2022-01-06 15:32:55 +00:00
parent 249f1cf8e6
commit 038d8b4635

View file

@ -1603,7 +1603,10 @@ rewait:
available
thread. */
else
ptid = inferior_ptid; /* let wait_for_inferior handle exit case */
{
/* The process exited. */
ptid = ptid_t (inf->pid);
}
}
if (thread