From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 70919 invoked by alias); 11 Mar 2015 13:39:58 -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 70889 invoked by uid 89); 11 Mar 2015 13:39:58 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS,T_RP_MATCHES_RCVD 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 (AES256-GCM-SHA384 encrypted) ESMTPS; Wed, 11 Mar 2015 13:39:57 +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 t2BDdsFj012393 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 11 Mar 2015 09:39:54 -0400 Received: from blade.nx (ovpn-116-20.ams2.redhat.com [10.36.116.20]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t2BDdr0u012717; Wed, 11 Mar 2015 09:39:54 -0400 Received: from blade.nx (localhost [127.0.0.1]) by blade.nx (Postfix) with ESMTP id 5189B265075; Wed, 11 Mar 2015 13:39:53 +0000 (GMT) From: Gary Benson To: gdb-patches@sourceware.org Cc: Pedro Alves , Eli Zaretskii Subject: [PATCH 3/3 v3] Implement vFile:fstat: packet in gdbserver Date: Wed, 11 Mar 2015 13:40:00 -0000 Message-Id: <1426081190-9381-4-git-send-email-gbenson@redhat.com> In-Reply-To: <20150311131601.GA5952@blade.nx> References: <20150311131601.GA5952@blade.nx> X-IsSubscribed: yes X-SW-Source: 2015-03/txt/msg00288.txt.bz2 This patch adds a new packet "vFile:fstat:" to gdbserver. This can be used by clients to retrieve information about open files. This was patch 2/3 in the original series, but it's been moved to the end. Also, all documentation has been moved into what is now patch 2/3, the patch that adds the GDB side. handle_fstat has been updated to fail with E01 if the response doesn't fit in a single packet. gdb/gdbserver/ChangeLog: * hostio.c (sys/types.h): New include. (sys/stat.h): Likewise. (common-remote-fileio.h): Likewise. (handle_fstat): New function. (handle_vFile): Handle vFile:fstat packets. * server.c (handle_query): Report vFile:fstat as supported. --- gdb/gdbserver/ChangeLog | 9 +++++++++ gdb/gdbserver/hostio.c | 41 +++++++++++++++++++++++++++++++++++++++++ gdb/gdbserver/server.c | 2 ++ 3 files changed, 52 insertions(+), 0 deletions(-) diff --git a/gdb/gdbserver/hostio.c b/gdb/gdbserver/hostio.c index ec29eb9..df43e27 100644 --- a/gdb/gdbserver/hostio.c +++ b/gdb/gdbserver/hostio.c @@ -25,6 +25,9 @@ #include #include #include +#include +#include +#include "common-remote-fileio.h" extern int remote_debug; @@ -412,6 +415,42 @@ handle_pwrite (char *own_buf, int packet_len) } static void +handle_fstat (char *own_buf, int *new_packet_len) +{ + int fd, bytes_sent; + char *p; + struct stat st; + struct fio_stat fst; + + p = own_buf + strlen ("vFile:fstat:"); + + if (require_int (&p, &fd) + || require_valid_fd (fd) + || require_end (p)) + { + hostio_packet_error (own_buf); + return; + } + + if (fstat (fd, &st) == -1) + { + hostio_error (own_buf); + return; + } + + remote_fileio_to_fio_stat (&st, &fst); + + bytes_sent = hostio_reply_with_data (own_buf, + (char *) &fst, sizeof (fst), + new_packet_len); + + /* If the response does not fit into a single packet, do not attempt + to return a partial response, but simply fail. */ + if (bytes_sent < sizeof (fst)) + strcpy (own_buf, "E01"); +} + +static void handle_close (char *own_buf) { int fd, ret; @@ -517,6 +556,8 @@ handle_vFile (char *own_buf, int packet_len, int *new_packet_len) handle_pread (own_buf, new_packet_len); else if (startswith (own_buf, "vFile:pwrite:")) handle_pwrite (own_buf, packet_len); + else if (startswith (own_buf, "vFile:fstat:")) + handle_fstat (own_buf, new_packet_len); else if (startswith (own_buf, "vFile:close:")) handle_close (own_buf); else if (startswith (own_buf, "vFile:unlink:")) diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c index 4189877..4d8faa3 100644 --- a/gdb/gdbserver/server.c +++ b/gdb/gdbserver/server.c @@ -2082,6 +2082,8 @@ handle_query (char *own_buf, int packet_len, int *new_packet_len_p) if (target_supports_stopped_by_hw_breakpoint ()) strcat (own_buf, ";hwbreak+"); + strcat (own_buf, ";vFile:fstat+"); + return; } -- 1.7.1