Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: Move store_waitstatus to inf-child.c (was: Re: MIPS Linux signals)
Date: Tue, 22 May 2012 15:10:00 -0000	[thread overview]
Message-ID: <4FBBAC3F.4070504@redhat.com> (raw)
In-Reply-To: <4FBB67AE.5090807@redhat.com>

On 05/22/2012 11:17 AM, Pedro Alves wrote:

> =====================
> target.c
> 
> Actually native code.  I think this could move to inf-child.c.
> 
> /* Helper function for child_wait and the derivatives of child_wait.
>    HOSTSTATUS is the waitstatus from wait() or the equivalent; store our
>    translation of that in OURSTATUS.  */
> void
> store_waitstatus (struct target_waitstatus *ourstatus, int hoststatus)


This patch moves it.

This is a function only used by (UNIX-ish) native targets, so inf-child.c
is a better place.  Interestingly, inf-child.o is always linked in through
COMMON_OBS, instead of being picked up by .mh fragments...

Build tested on X86_64 Fedora 16 as well as cross built for mingw.  The amount
of grepping I did makes me reasonably confident I haven't broken any
target, but you never know...

2012-05-22  Pedro Alves  <palves@redhat.com>

	* target.h (store_waitstatus): Move declaration ...
	* inf-child.h (store_waitstatus): ... here.
	* target.c: Move inclusion of gdb_wait.h, and ...
	(store_waitstatus): ... this ...
	* inf-child.c: ... here.
	* linux-nat.c: Include inf-child.h.
	* rs6000-nat.c: Include inf-child.h.
	* spu-linux-nat.c: Include inf-child.h.
---
 gdb/inf-child.c     |   24 ++++++++++++++++++++++++
 gdb/inf-child.h     |    5 +++++
 gdb/linux-nat.c     |    1 +
 gdb/rs6000-nat.c    |    1 +
 gdb/spu-linux-nat.c |    1 +
 gdb/target.c        |   24 ------------------------
 gdb/target.h        |    4 ----
 7 files changed, 32 insertions(+), 28 deletions(-)

diff --git a/gdb/inf-child.c b/gdb/inf-child.c
index 5531102..08955ea 100644
--- a/gdb/inf-child.c
+++ b/gdb/inf-child.c
@@ -30,6 +30,7 @@
 #include "inf-child.h"
 #include "gdb/fileio.h"
 #include "agent.h"
+#include "gdb_wait.h"

 #ifdef HAVE_SYS_PARAM_H
 #include <sys/param.h>		/* for MAXPATHLEN */
@@ -38,6 +39,29 @@
 #include <fcntl.h>
 #include <unistd.h>

+/* Helper function for child_wait and the derivatives of child_wait.
+   HOSTSTATUS is the waitstatus from wait() or the equivalent; store our
+   translation of that in OURSTATUS.  */
+void
+store_waitstatus (struct target_waitstatus *ourstatus, int hoststatus)
+{
+  if (WIFEXITED (hoststatus))
+    {
+      ourstatus->kind = TARGET_WAITKIND_EXITED;
+      ourstatus->value.integer = WEXITSTATUS (hoststatus);
+    }
+  else if (!WIFSTOPPED (hoststatus))
+    {
+      ourstatus->kind = TARGET_WAITKIND_SIGNALLED;
+      ourstatus->value.sig = target_signal_from_host (WTERMSIG (hoststatus));
+    }
+  else
+    {
+      ourstatus->kind = TARGET_WAITKIND_STOPPED;
+      ourstatus->value.sig = target_signal_from_host (WSTOPSIG (hoststatus));
+    }
+}
+
 /* Fetch register REGNUM from the inferior.  If REGNUM is -1, do this
    for all registers.  */

diff --git a/gdb/inf-child.h b/gdb/inf-child.h
index d32c8cb..c394d5a 100644
--- a/gdb/inf-child.h
+++ b/gdb/inf-child.h
@@ -25,4 +25,9 @@

 extern struct target_ops *inf_child_target (void);

+/* Functions for helping to write a native target.  */
+
+/* This is for native targets which use a unix/POSIX-style waitstatus.  */
+extern void store_waitstatus (struct target_waitstatus *, int);
+
 #endif
diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
index ac1a0ea..86b3c7d 100644
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -36,6 +36,7 @@
 #include "gdbcmd.h"
 #include "regcache.h"
 #include "regset.h"
+#include "inf-child.h"
 #include "inf-ptrace.h"
 #include "auxv.h"
 #include <sys/param.h>		/* for MAXPATHLEN */
diff --git a/gdb/rs6000-nat.c b/gdb/rs6000-nat.c
index 117ca01..b2b3e7e 100644
--- a/gdb/rs6000-nat.c
+++ b/gdb/rs6000-nat.c
@@ -31,6 +31,7 @@
 #include "gdb-stabs.h"
 #include "regcache.h"
 #include "arch-utils.h"
+#include "inf-child.h"
 #include "inf-ptrace.h"
 #include "ppc-tdep.h"
 #include "rs6000-tdep.h"
diff --git a/gdb/spu-linux-nat.c b/gdb/spu-linux-nat.c
index 7ddfc7a..235458e 100644
--- a/gdb/spu-linux-nat.c
+++ b/gdb/spu-linux-nat.c
@@ -23,6 +23,7 @@
 #include "gdb_string.h"
 #include "target.h"
 #include "inferior.h"
+#include "inf-child.h"
 #include "inf-ptrace.h"
 #include "regcache.h"
 #include "symfile.h"
diff --git a/gdb/target.c b/gdb/target.c
index 5361dbc..6dba936 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -29,7 +29,6 @@
 #include "bfd.h"
 #include "symfile.h"
 #include "objfiles.h"
-#include "gdb_wait.h"
 #include "dcache.h"
 #include <signal.h>
 #include "regcache.h"
@@ -3650,29 +3649,6 @@ generic_mourn_inferior (void)
     deprecated_detach_hook ();
 }
 \f
-/* Helper function for child_wait and the derivatives of child_wait.
-   HOSTSTATUS is the waitstatus from wait() or the equivalent; store our
-   translation of that in OURSTATUS.  */
-void
-store_waitstatus (struct target_waitstatus *ourstatus, int hoststatus)
-{
-  if (WIFEXITED (hoststatus))
-    {
-      ourstatus->kind = TARGET_WAITKIND_EXITED;
-      ourstatus->value.integer = WEXITSTATUS (hoststatus);
-    }
-  else if (!WIFSTOPPED (hoststatus))
-    {
-      ourstatus->kind = TARGET_WAITKIND_SIGNALLED;
-      ourstatus->value.sig = target_signal_from_host (WTERMSIG (hoststatus));
-    }
-  else
-    {
-      ourstatus->kind = TARGET_WAITKIND_STOPPED;
-      ourstatus->value.sig = target_signal_from_host (WSTOPSIG (hoststatus));
-    }
-}
-\f
 /* Convert a normal process ID to a string.  Returns the string in a
    static buffer.  */

diff --git a/gdb/target.h b/gdb/target.h
index 50a0ea6..84b462a 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -1857,10 +1857,6 @@ extern int baud_rate;
 extern int remote_timeout;

 \f
-/* Functions for helping to write a native target.  */
-
-/* This is for native targets which use a unix/POSIX-style waitstatus.  */
-extern void store_waitstatus (struct target_waitstatus *, int);

 /* Set the show memory breakpoints mode to show, and installs a cleanup
    to restore it back to the current value.  */


  parent reply	other threads:[~2012-05-22 15:10 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-20  2:03 MIPS Linux signals Michael Eager
2012-05-21 11:04 ` Pedro Alves
2012-05-21 14:51   ` Michael Eager
2012-05-21 17:37     ` Pedro Alves
2012-05-21 18:06       ` Michael Eager
2012-05-21 18:19 ` Maciej W. Rozycki
     [not found] ` <alpine.DEB.1.10.1205211232260.11227@tp.orcam.me.uk>
2012-05-21 18:21   ` Michael Eager
2012-05-21 22:34     ` Maciej W. Rozycki
2012-05-22  9:38       ` Pedro Alves
2012-05-21 21:35 ` Pedro Alves
2012-05-21 21:53   ` Michael Eager
2012-05-21 22:48     ` Maciej W. Rozycki
2012-05-22  0:16       ` Michael Eager
2012-05-22 10:17       ` Pedro Alves
2012-05-22 13:16         ` Maciej W. Rozycki
2012-05-22 13:32           ` Pedro Alves
2012-05-22 15:10         ` Pedro Alves [this message]
2012-05-22 15:40         ` Michael Eager
2012-05-22 16:02           ` Pedro Alves
2012-05-22 18:14             ` Michael Eager
2012-05-22 18:31               ` Pedro Alves
2012-05-22 19:32                 ` Michael Eager
2012-05-22 22:06                   ` Pedro Alves
2012-05-22 16:26         ` Pedro Alves
2012-05-22 10:58       ` Pedro Alves
2012-05-22 19:31         ` Aleksandar Ristovski
2012-05-22 21:55           ` Pedro Alves
2012-05-22 23:29             ` Aleksandar Ristovski
2012-05-23 11:39               ` Pedro Alves

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=4FBBAC3F.4070504@redhat.com \
    --to=palves@redhat.com \
    --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