From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25970 invoked by alias); 23 Jan 2014 14:10:24 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 25911 invoked by uid 89); 23 Jan 2014 14:10:23 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 23 Jan 2014 14:10:20 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s0NEAD7V006975 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 23 Jan 2014 09:10:14 -0500 Received: from brno.lan (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s0NEA9qN026851; Thu, 23 Jan 2014 09:10:11 -0500 From: Pedro Alves 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 Message-Id: <1390486209-8167-2-git-send-email-palves@redhat.com> In-Reply-To: <1390486209-8167-1-git-send-email-palves@redhat.com> References: <52E12075.3040601@redhat.com> <1390486209-8167-1-git-send-email-palves@redhat.com> X-SW-Source: 2014-01/txt/msg00896.txt.bz2 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); -/* 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 + /* 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