From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3788 invoked by alias); 22 Jun 2006 18:25:33 -0000 Received: (qmail 3759 invoked by uid 22791); 22 Jun 2006 18:25:32 -0000 X-Spam-Check-By: sourceware.org Received: from sibelius.xs4all.nl (HELO sibelius.xs4all.nl) (82.92.89.47) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 22 Jun 2006 18:25:30 +0000 Received: from elgar.sibelius.xs4all.nl (root@elgar.sibelius.xs4all.nl [192.168.0.2]) by sibelius.xs4all.nl (8.13.4/8.13.4) with ESMTP id k5MIOtRo024792; Thu, 22 Jun 2006 20:24:55 +0200 (CEST) Received: from elgar.sibelius.xs4all.nl (kettenis@localhost.sibelius.xs4all.nl [127.0.0.1]) by elgar.sibelius.xs4all.nl (8.13.6/8.13.6) with ESMTP id k5MIOt4e014220; Thu, 22 Jun 2006 20:24:55 +0200 (CEST) Received: (from kettenis@localhost) by elgar.sibelius.xs4all.nl (8.13.6/8.13.6/Submit) id k5MIOsEO029253; Thu, 22 Jun 2006 20:24:54 +0200 (CEST) Date: Thu, 22 Jun 2006 18:25:00 -0000 Message-Id: <200606221824.k5MIOsEO029253@elgar.sibelius.xs4all.nl> From: Mark Kettenis To: drow@false.org CC: gdb-patches@sourceware.org In-reply-to: <20060622032355.GA27566@nevyn.them.org> (message from Daniel Jacobowitz on Wed, 21 Jun 2006 23:23:55 -0400) Subject: Re: [rfc] Correct semantics of target_read_partial, add target_read_whole References: <20060622032355.GA27566@nevyn.them.org> Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2006-06/txt/msg00328.txt.bz2 > Date: Wed, 21 Jun 2006 23:23:55 -0400 > From: Daniel Jacobowitz > > Originally, target_read_partial was supposed to read "however much it could > manage to" and then higher level functions were supposed to handle the rest. > But every existing implementation always reads enough data in its first > call; the one remote protocol implementation did so by issuing as many > packets as necessary, which defeated the point of the original design. Ah, it all makes sense to me now. I'm wondering whether we should "export" target_read_partial() (and target_write_partial()) at all. It's never right to use them except for implementing higher-level target read/write functions isn't it? > This patch adjusts the remote protocol layer not to do that. It also > promotes a useful function from auxv.c to target.c: > > +/* Wrappers to perform a full read of unknown size. OBJECT/ANNEX will > + be read using OPS. The return value will be -1 if the transfer > + fails or is not supported; 0 if the object is empty; and the length > + of the object otherwise. If a positive value is returned, a > + sufficiently large buffer will be allocated using xmalloc and > + returned in *BUF_P containing the contents of the object. > + > + This method should be used for objects sufficiently small to store > + in a single xmalloced buffer, when no fixed bound on the object's > + size is known in advance. Don't try to read TARGET_OBJECT_MEMORY > + through this function. */ > + > +extern LONGEST target_read_whole (struct target_ops *ops, > + enum target_object object, > + const char *annex, gdb_byte **buf_p); > > When you use to_xfer_partial to get at memory, obviously you don't want "the > whole object". But for other objects, such as auxv vectors or XML > description files, usually you do. This provides a central interface > to handle short reads correctly, instead of letting that code circulate > (buggily in many cases) through other files. Agreed. I have a (small) concern that the introduction of target_read_whole() will cause confusion with target_read(). Perhaps a better name would be target_read_alloc? You might consider commiting the sparc-tdep.c change seperately; it's "obvious". Mark