From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10081 invoked by alias); 9 Jul 2010 18:59:17 -0000 Received: (qmail 10072 invoked by uid 22791); 9 Jul 2010 18:59:16 -0000 X-SWARE-Spam-Status: No, hits=-2.2 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 09 Jul 2010 18:59:10 +0000 Received: (qmail 30004 invoked from network); 9 Jul 2010 18:59:09 -0000 Received: from unknown (HELO caradoc.them.org) (dan@127.0.0.2) by mail.codesourcery.com with ESMTPA; 9 Jul 2010 18:59:09 -0000 Date: Fri, 09 Jul 2010 18:59:00 -0000 From: Daniel Jacobowitz To: Vladimir Prus Cc: gdb-patches@sources.redhat.com Subject: Re: Better MI memory commands Message-ID: <20100709185905.GB8410@caradoc.them.org> References: <201006251232.55281.vladimir@codesourcery.com> <20100707162952.GA6530@caradoc.them.org> <201007092254.07434.vladimir@codesourcery.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201007092254.07434.vladimir@codesourcery.com> User-Agent: Mutt/1.5.20 (2009-06-14) 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 X-SW-Source: 2010-07/txt/msg00187.txt.bz2 On Fri, Jul 09, 2010 at 10:54:07PM +0400, Vladimir Prus wrote: > On Wednesday 07 July 2010 20:29:55 Daniel Jacobowitz wrote: > > > > - if (xfer == 0) > > > - return xfered; > > > - if (xfer < 0) > > > - { > > > - remaining = half; > > > - } > > > - else > > > - { > > > - /* We have successfully read the first half. So, the > > > - error must be in the second half. Adjust start and > > > - remaining to point at the second half. */ > > > - xfered += xfer; > > > - start += xfer; > > > - remaining -= xfer; > > > - } > > > - half = remaining/2; > > > + xfree (buffer); > > > + xfered += to_read; > > > } > > > > Why do we skip to_read bytes if we succeed at reading zero bytes? > > For that matter, what does a return value of zero mean? It seems like > > this would mean the same as -1. > > I am not really sure. Per documentation of target_read: > > Return the number of bytes actually transfered, or -1 if the > transfer is not supported or otherwise fails. Return of a positive > value less than LEN indicates that no further transfer is possible. > > So, value of 0 seems to mean 'there are no more bytes that that, honest', > and that we probably don't need to try further. Documentation for > to_xfer_partial seem to give such meaning to return of 0. I'd suggest treating 0 and -1 the same, for memory. > On the > other hand, it's not clear what return value of and whether we should try to read remaining chunk. What would you suggest? A return of less than LEN from xfer_partial doesn't mean anything; you just retry. A return of less than LEN from target_read, though, is supposed to mean that there is no point in retrying; the next byte is inaccessible or does not exist. It doesn't look like memory reads (unlike other partial transfers) implement that; usually they just fail. But we can treat it that way anyway. So