From: Mark Kettenis <mark.kettenis@xs4all.nl>
To: drow@false.org
Cc: vladimir@codesourcery.com, gdb-patches@sources.redhat.com
Subject: Re: [PATCH] zero-terminate result of target_read_alloc
Date: Mon, 24 Jul 2006 21:41:00 -0000 [thread overview]
Message-ID: <200607242138.k6OLcP7h023940@elgar.sibelius.xs4all.nl> (raw)
In-Reply-To: <20060724040937.GA24339@nevyn.them.org> (message from Daniel Jacobowitz on Mon, 24 Jul 2006 00:09:37 -0400)
> Date: Mon, 24 Jul 2006 00:09:37 -0400
> From: Daniel Jacobowitz <drow@false.org>
>
> On Tue, Jul 18, 2006 at 01:25:22PM +0200, Mark Kettenis wrote:
> > >
> > > This patch makes result of target_read_alloc zero-terminated.
> > > The point is that often the object is not allowed to contain embedded
> > > zeros,
> > > and working with zero-terminated strings is much easier.
> > >
> > > OK?
> >
> > This is wrong. Either the terminating nul is part of the object you're
> > reading or it is not. GDB shouldn't at its own.
>
> Hi Mark,
>
> There was some followup discussion on this, and we didn't hear back
> from you. My own explanation of the current behavior is that this is
> an interface for reading binary data from the target, much like reading
> it from files, so it shouldn't be NUL terminated - but the client may
> expect the data to not contain embedded NULs and we have the
> opportunity to be helpful here, so we should be helpful.
Sorry, yes. I didn't manage to reply yet. I don't find the arguments
very convincing. You try to justify the interface by giving examples
of interfaces that are very different from target_read_alloc() (and
much more similar to target_read()).
> Do you find that convincing? If not, would you be happier if there
> were two functions to do this, one which added the NUL and one which
> did not? I'm thinking target_read_alloc and target_read_stralloc,
> indicating that we allocate the result as if it were a string.
That seems a reasonably compromise to me. It makes things much more
explicit. I think you should go one step further, and make
target_read_stralloc() return "char *" instead of "LONGEST" (and do
away with the "gdb_byte **" argument). That'd solve the issue whether
the length returned includes the terminating NUL or not. The function
would return a NULL pointer upon failure and an empty string on (the
equivalent of) EOF.
Mark
next prev parent reply other threads:[~2006-07-24 21:41 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-07-18 9:56 Vladimir Prus
2006-07-18 11:25 ` Mark Kettenis
2006-07-18 11:33 ` Vladimir Prus
2006-07-18 12:34 ` Daniel Jacobowitz
2006-07-18 13:15 ` Mark Kettenis
2006-07-18 13:39 ` Daniel Jacobowitz
2006-07-18 13:51 ` Vladimir Prus
2006-07-18 19:51 ` Jim Blandy
2006-07-24 4:09 ` Daniel Jacobowitz
2006-07-24 21:41 ` Mark Kettenis [this message]
2006-07-24 22:00 ` Daniel Jacobowitz
2006-07-26 21:53 ` Mark Kettenis
2006-07-26 22:25 ` Daniel Jacobowitz
2006-07-26 22:36 ` Mark Kettenis
2006-07-27 21:25 ` 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=200607242138.k6OLcP7h023940@elgar.sibelius.xs4all.nl \
--to=mark.kettenis@xs4all.nl \
--cc=drow@false.org \
--cc=gdb-patches@sources.redhat.com \
--cc=vladimir@codesourcery.com \
/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