From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19344 invoked by alias); 24 Jul 2006 04:09:43 -0000 Received: (qmail 19334 invoked by uid 22791); 24 Jul 2006 04:09:42 -0000 X-Spam-Check-By: sourceware.org Received: from nevyn.them.org (HELO nevyn.them.org) (66.93.172.17) by sourceware.org (qpsmtpd/0.31.1) with ESMTP; Mon, 24 Jul 2006 04:09:40 +0000 Received: from drow by nevyn.them.org with local (Exim 4.54) id 1G4rlB-0006Lw-FR; Mon, 24 Jul 2006 00:09:37 -0400 Date: Mon, 24 Jul 2006 04:09:00 -0000 From: Daniel Jacobowitz To: Mark Kettenis Cc: Vladimir Prus , gdb-patches@sources.redhat.com Subject: Re: [PATCH] zero-terminate result of target_read_alloc Message-ID: <20060724040937.GA24339@nevyn.them.org> Mail-Followup-To: Mark Kettenis , Vladimir Prus , gdb-patches@sources.redhat.com References: <200607181356.16071.vladimir@codesourcery.com> <24758.192.87.1.22.1153221922.squirrel@webmail.xs4all.nl> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <24758.192.87.1.22.1153221922.squirrel@webmail.xs4all.nl> User-Agent: Mutt/1.5.11+cvs20060403 X-IsSubscribed: yes 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-07/txt/msg00329.txt.bz2 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