From: Pedro Alves <palves@redhat.com>
To: gdb-patches@sourceware.org
Cc: teawater@gmail.com, luis_gustavo@mentor.com
Subject: [PATCH 2/5] Move status_to_str to nat/linux-waitpid.c.
Date: Thu, 23 Jan 2014 14:10:00 -0000 [thread overview]
Message-ID: <1390486209-8167-2-git-send-email-palves@redhat.com> (raw)
In-Reply-To: <1390486209-8167-1-git-send-email-palves@redhat.com>
So that gdbserver's backend can use it too.
---
gdb/linux-nat.c | 25 -------------------------
gdb/nat/linux-waitpid.c | 28 ++++++++++++++++++++++++++++
gdb/nat/linux-waitpid.h | 4 ++++
3 files changed, 32 insertions(+), 25 deletions(-)
diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
index d144c77..5961867 100644
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -849,31 +849,6 @@ static int linux_thread_alive (ptid_t ptid);
static char *linux_child_pid_to_exec_file (int pid);
\f
-/* Convert wait status STATUS to a string. Used for printing debug
- messages only. */
-
-static char *
-status_to_str (int status)
-{
- static char buf[64];
-
- if (WIFSTOPPED (status))
- {
- if (WSTOPSIG (status) == SYSCALL_SIGTRAP)
- snprintf (buf, sizeof (buf), "%s (stopped at syscall)",
- strsignal (SIGTRAP));
- else
- snprintf (buf, sizeof (buf), "%s (stopped)",
- strsignal (WSTOPSIG (status)));
- }
- else if (WIFSIGNALED (status))
- snprintf (buf, sizeof (buf), "%s (terminated)",
- strsignal (WTERMSIG (status)));
- else
- snprintf (buf, sizeof (buf), "%d (exited)", WEXITSTATUS (status));
-
- return buf;
-}
/* Destroy and free LP. */
diff --git a/gdb/nat/linux-waitpid.c b/gdb/nat/linux-waitpid.c
index 433efe7..e9e69db 100644
--- a/gdb/nat/linux-waitpid.c
+++ b/gdb/nat/linux-waitpid.c
@@ -28,6 +28,8 @@
#include "nat/linux-waitpid.h"
#include "gdb_wait.h"
+#include <string.h>
+
/* Print debugging output based on the format string FORMAT and
its parameters. */
@@ -47,6 +49,32 @@ linux_debug (const char *format, ...)
#endif
}
+/* Convert wait status STATUS to a string. Used for printing debug
+ messages only. */
+
+char *
+status_to_str (int status)
+{
+ static char buf[64];
+
+ if (WIFSTOPPED (status))
+ {
+ if (WSTOPSIG (status) == SYSCALL_SIGTRAP)
+ snprintf (buf, sizeof (buf), "%s (stopped at syscall)",
+ strsignal (SIGTRAP));
+ else
+ snprintf (buf, sizeof (buf), "%s (stopped)",
+ strsignal (WSTOPSIG (status)));
+ }
+ else if (WIFSIGNALED (status))
+ snprintf (buf, sizeof (buf), "%s (terminated)",
+ strsignal (WTERMSIG (status)));
+ else
+ snprintf (buf, sizeof (buf), "%d (exited)", WEXITSTATUS (status));
+
+ return buf;
+}
+
/* Wrapper function for waitpid which handles EINTR, and emulates
__WALL for systems where that is not available. */
diff --git a/gdb/nat/linux-waitpid.h b/gdb/nat/linux-waitpid.h
index ae90e50..cac38db 100644
--- a/gdb/nat/linux-waitpid.h
+++ b/gdb/nat/linux-waitpid.h
@@ -24,4 +24,8 @@
__WALL for systems where that is not available. */
extern int my_waitpid (int pid, int *status, int flags);
+/* Convert wait status STATUS to a string. Used for printing debug
+ messages only. */
+extern char *status_to_str (int status);
+
#endif /* LINUX_WAITPID_H */
--
1.7.11.7
next prev parent reply other threads:[~2014-01-23 14:10 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-20 10:00 [PATCH] Fix PR 12702 - gdb can hang waiting for thread group leader (gdbserver) Hui Zhu
2013-07-24 18:25 ` Pedro Alves
2013-11-19 6:19 ` Hui Zhu
2014-01-23 14:51 ` Pedro Alves
2014-01-23 14:10 ` [PATCH 1/5] Move ptid_match to common/ptid.c Pedro Alves
2014-01-23 14:10 ` Pedro Alves [this message]
2014-01-23 14:10 ` [PATCH 3/5] Linux waitpid/__WALL emulation wrapper: If WNOHANG is set, don't touch sigprocmask Pedro Alves
2014-02-27 14:47 ` Pedro Alves
2014-01-23 14:10 ` [PATCH 4/5] Teach gdbserver's linux backend about no unwaited-for children (TARGET_WAITDKIND_NO_RESUMED) Pedro Alves
2014-01-23 14:10 ` [PATCH 5/5] Add TARGET_WAITKIND_NO_RESUMED support to the RSP Pedro Alves
2014-02-27 14:38 ` [PATCH] Fix PR 12702 - gdb can hang waiting for thread group leader (gdbserver) Pedro Alves
2014-02-27 14:54 ` Luis Machado
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=1390486209-8167-2-git-send-email-palves@redhat.com \
--to=palves@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=luis_gustavo@mentor.com \
--cc=teawater@gmail.com \
/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