From d632a0971cf9c8044e2b59da45ba6bbc27714c84 Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Thu, 27 Feb 2014 14:30:08 +0000 Subject: Move linux-nat.c:status_to_str to nat/linux-waitpid.c. So that gdbserver's Linux backend can use it too. gdb/ 2014-02-27 Pedro Alves PR 12702 * linux-nat.c (status_to_str): Moved to nat/linux-waitpid.c. * nat/linux-waitpid.c: Include string.h. (status_to_str): Moved here and made extern. * nat/linux-waitpid.h (status_to_str): New declaration. --- gdb/nat/linux-waitpid.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'gdb/nat/linux-waitpid.c') 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 + /* 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. */ -- cgit v1.1