Newer
Older
minerva / Ports / gdb / patches / 0006-minerva-Implement-mourn_inferior-override-for-the-s.patch
@minerva minerva on 13 Jul 1 KB Initial commit
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Brian Gianforcaro <b.gianfo@gmail.com>
Date: Sun, 20 Feb 2022 00:44:08 -0800
Subject: [PATCH] minerva: Implement mourn_inferior override for the
 minerva_nat_target

We need to pass `WNOHANG` to our `waitpid(..)` call on Minerva,
otherwise we will wait forever.
---
 gdb/minerva-nat.c | 14 ++++++++++++++
 gdb/minerva-nat.h |  2 ++
 2 files changed, 16 insertions(+)

diff --git a/gdb/minerva-nat.c b/gdb/minerva-nat.c
index b1d39d4..7789950 100644
--- a/gdb/minerva-nat.c
+++ b/gdb/minerva-nat.c
@@ -71,3 +71,17 @@ ptid_t minerva_nat_target::wait (ptid_t ptid, struct target_waitstatus* ourstat
 
     return ptid_t (pid);
 }
+
+void minerva_nat_target::mourn_inferior ()
+{
+    int status;
+
+    /* Wait just one more time to collect the inferior's exit status.
+     * Do not check whether this succeeds though, since we may be
+     * dealing with a process that we attached to. Such a process will
+     * only report its exit status to its original parent.
+     */
+    waitpid (inferior_ptid.pid (), &status, WNOHANG);
+
+    inf_child_target::mourn_inferior ();
+}
diff --git a/gdb/minerva-nat.h b/gdb/minerva-nat.h
index 9ae3b87..35d7ffc 100644
--- a/gdb/minerva-nat.h
+++ b/gdb/minerva-nat.h
@@ -13,6 +13,8 @@ class minerva_nat_target : public inf_ptrace_target
 {
   ptid_t wait (ptid_t, struct target_waitstatus *, target_wait_flags) override;
 
+  void mourn_inferior ();
+
 private:
   bool m_attach_before_continue_called { false };
 };