Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Mark Kettenis <mark.kettenis@xs4all.nl>
To: drow@false.org
Cc: gdb-patches@sourceware.org
Subject: Re: [rfc] Correct semantics of target_read_partial, add target_read_whole
Date: Thu, 22 Jun 2006 18:25:00 -0000	[thread overview]
Message-ID: <200606221824.k5MIOsEO029253@elgar.sibelius.xs4all.nl> (raw)
In-Reply-To: <20060622032355.GA27566@nevyn.them.org> (message from Daniel 	Jacobowitz on Wed, 21 Jun 2006 23:23:55 -0400)

> Date: Wed, 21 Jun 2006 23:23:55 -0400
> From: Daniel Jacobowitz <drow@false.org>
> 
> 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


  reply	other threads:[~2006-06-22 18:25 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-06-22  3:24 Daniel Jacobowitz
2006-06-22 18:25 ` Mark Kettenis [this message]
2006-06-22 18:37   ` Daniel Jacobowitz
2006-06-29  9:35     ` Vladimir Prus
2006-06-24 10:06 ` Vladimir Prus
2006-06-26 13:38   ` Daniel Jacobowitz
2006-06-28  8:18 ` Vladimir Prus
2006-06-28 13:49   ` Daniel Jacobowitz
2006-07-05 19:06 ` Daniel Jacobowitz
2006-07-05 19:34   ` Mark Kettenis
2006-07-12 18:15     ` Daniel Jacobowitz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200606221824.k5MIOsEO029253@elgar.sibelius.xs4all.nl \
    --to=mark.kettenis@xs4all.nl \
    --cc=drow@false.org \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox