From patchwork Tue Mar 11 12:42:10 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yao Qi X-Patchwork-Id: 35 Return-Path: X-Original-To: siddhesh@wilcox.dreamhost.com Delivered-To: siddhesh@wilcox.dreamhost.com Received: from homiemail-mx20.g.dreamhost.com (caibbdcaaahc.dreamhost.com [208.113.200.72]) by wilcox.dreamhost.com (Postfix) with ESMTP id D995B360115 for ; Tue, 11 Mar 2014 05:45:02 -0700 (PDT) Received: by homiemail-mx20.g.dreamhost.com (Postfix, from userid 14314964) id 898A340618634; Tue, 11 Mar 2014 05:45:02 -0700 (PDT) X-Original-To: gdb@patchwork.siddhesh.in Delivered-To: x14314964@homiemail-mx20.g.dreamhost.com Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by homiemail-mx20.g.dreamhost.com (Postfix) with ESMTPS id 5D57340618634 for ; Tue, 11 Mar 2014 05:45:02 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-type; q=dns; s=default; b=TlJ+y SmfgdBN5yO0csTOmvJbz9pYteYEV3T6pDJBhqnl52kMe5VPlj85vkrGVtwgvFFWu Yw+gksX8RruiyeqHdLJGben3ydM4QTZIxpDldskyYEhwZ4nKMm1z06LMM3SNx7H5 VJHOcPV2NSTUxnIQjR4cNJ9ttNJZk+Nt93FD2s= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-type; s=default; bh=KoaaCz2MpFh tJG7BkDNFOcVu0Kw=; b=rWIiwjrLNvmgMpTh8ap/4MsDvZvyLdeSN8mkVBWNBGA 7rOcXXM5qTYqKl+xVyBk4mZxfKmXzVA/G4hiGSLnB3sYP6AiExNxSU/4hQENAw5J lQIoPTTyzNjtBx6IR6WJ9zXR4EAdEmhFTM7P9qwNtce1FxZtG5GYDSjxxckHLFpQ = Received: (qmail 5251 invoked by alias); 11 Mar 2014 12:44:54 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 5225 invoked by uid 89); 11 Mar 2014 12:44:53 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.6 required=5.0 tests=AWL, BAYES_00 autolearn=ham version=3.3.2 X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 11 Mar 2014 12:44:52 +0000 Received: from svr-orw-fem-01.mgc.mentorg.com ([147.34.98.93]) by relay1.mentorg.com with esmtp id 1WNM37-0002qX-5x from Yao_Qi@mentor.com for gdb-patches@sourceware.org; Tue, 11 Mar 2014 05:44:49 -0700 Received: from SVR-ORW-FEM-04.mgc.mentorg.com ([147.34.97.41]) by svr-orw-fem-01.mgc.mentorg.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Tue, 11 Mar 2014 05:44:49 -0700 Received: from qiyao.dyndns.org.com (147.34.91.1) by svr-orw-fem-04.mgc.mentorg.com (147.34.97.41) with Microsoft SMTP Server id 14.2.247.3; Tue, 11 Mar 2014 05:44:48 -0700 From: Yao Qi To: Subject: [PATCH 2/3] Factor remote_read_bytes. Date: Tue, 11 Mar 2014 20:42:10 +0800 Message-ID: <1394541731-27486-2-git-send-email-yao@codesourcery.com> In-Reply-To: <1394541731-27486-1-git-send-email-yao@codesourcery.com> References: <1394541731-27486-1-git-send-email-yao@codesourcery.com> MIME-Version: 1.0 X-IsSubscribed: yes X-DH-Original-To: gdb@patchwork.siddhesh.in This patch moves code in remote_read_bytes on reading from the remote stub to a new function remote_read_bytes_1. gdb: 2014-03-11 Yao Qi * remote.c (remote_read_bytes): Move code on reading from the remote stub to ... (remote_read_bytes_1): ... here. New function. --- gdb/remote.c | 97 ++++++++++++++++++++++++++++++++------------------------- 1 files changed, 54 insertions(+), 43 deletions(-) diff --git a/gdb/remote.c b/gdb/remote.c index afe9d12..b5c6b4b 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -6824,6 +6824,56 @@ remote_write_bytes (CORE_ADDR memaddr, const gdb_byte *myaddr, ULONGEST len, packet_format[0], 1); } +/* Read memory data directly from the remote machine. + This does not use the data cache; the data cache uses this. + MEMADDR is the address in the remote memory space. + MYADDR is the address of the buffer in our space. + LEN is the number of bytes. + + Return the transferred status, error or OK (an + 'enum target_xfer_status' value). Save the number of bytes + transferred in *XFERED_LEN. */ + +static enum target_xfer_status +remote_read_bytes_1 (CORE_ADDR memaddr, gdb_byte *myaddr, ULONGEST len, + ULONGEST *xfered_len) +{ + struct remote_state *rs = get_remote_state (); + int max_buf_size; /* Max size of packet output buffer. */ + char *p; + int todo; + int i; + + max_buf_size = get_memory_read_packet_size (); + /* The packet buffer will be large enough for the payload; + get_memory_packet_size ensures this. */ + + /* Number if bytes that will fit. */ + todo = min (len, max_buf_size / 2); + + /* Construct "m"","". */ + memaddr = remote_address_masked (memaddr); + p = rs->buf; + *p++ = 'm'; + p += hexnumstr (p, (ULONGEST) memaddr); + *p++ = ','; + p += hexnumstr (p, (ULONGEST) todo); + *p = '\0'; + putpkt (rs->buf); + getpkt (&rs->buf, &rs->buf_size, 0); + if (rs->buf[0] == 'E' + && isxdigit (rs->buf[1]) && isxdigit (rs->buf[2]) + && rs->buf[3] == '\0') + return TARGET_XFER_E_IO; + /* Reply describes memory byte by byte, each byte encoded as two hex + characters. */ + p = rs->buf; + i = hex2bin (p, myaddr, todo); + /* Return what we have. Let higher layers handle partial reads. */ + *xfered_len = (ULONGEST) i; + return TARGET_XFER_OK; +} + /* Read memory from the live target, even if currently inspecting a traceframe. The return is the same as that of target_read. */ @@ -6905,26 +6955,14 @@ memory_xfer_live_readonly_partial (struct target_ops *ops, return TARGET_XFER_EOF; } -/* Read memory data directly from the remote machine. - This does not use the data cache; the data cache uses this. - MEMADDR is the address in the remote memory space. - MYADDR is the address of the buffer in our space. - LEN is the number of bytes. - - Return the transferred status, error or OK (an - 'enum target_xfer_status' value). Save the number of bytes - transferred in *XFERED_LEN. */ +/* Similar to remote_read_bytes_1, but it reads from the remote stub + first if the requested memory is unavailable in traceframe. + Otherwise, fall back to remote_read_bytes_1. */ static enum target_xfer_status remote_read_bytes (CORE_ADDR memaddr, gdb_byte *myaddr, ULONGEST len, ULONGEST *xfered_len) { - struct remote_state *rs = get_remote_state (); - int max_buf_size; /* Max size of packet output buffer. */ - char *p; - int todo; - int i; - if (len == 0) return 0; @@ -6985,34 +7023,7 @@ remote_read_bytes (CORE_ADDR memaddr, gdb_byte *myaddr, ULONGEST len, } } - max_buf_size = get_memory_read_packet_size (); - /* The packet buffer will be large enough for the payload; - get_memory_packet_size ensures this. */ - - /* Number if bytes that will fit. */ - todo = min (len, max_buf_size / 2); - - /* Construct "m"","". */ - memaddr = remote_address_masked (memaddr); - p = rs->buf; - *p++ = 'm'; - p += hexnumstr (p, (ULONGEST) memaddr); - *p++ = ','; - p += hexnumstr (p, (ULONGEST) todo); - *p = '\0'; - putpkt (rs->buf); - getpkt (&rs->buf, &rs->buf_size, 0); - if (rs->buf[0] == 'E' - && isxdigit (rs->buf[1]) && isxdigit (rs->buf[2]) - && rs->buf[3] == '\0') - return TARGET_XFER_E_IO; - /* Reply describes memory byte by byte, each byte encoded as two hex - characters. */ - p = rs->buf; - i = hex2bin (p, myaddr, todo); - /* Return what we have. Let higher layers handle partial reads. */ - *xfered_len = (ULONGEST) i; - return TARGET_XFER_OK; + return remote_read_bytes_1 (memaddr, myaddr, len, xfered_len); }