This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] zero-terminate result of target_read_alloc


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.

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.

-- 
Daniel Jacobowitz
CodeSourcery


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]