From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21392 invoked by alias); 23 Nov 2008 16:11:12 -0000 Received: (qmail 21238 invoked by uid 22791); 23 Nov 2008 16:11:10 -0000 X-Spam-Check-By: sourceware.org Received: from NaN.false.org (HELO nan.false.org) (208.75.86.248) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 23 Nov 2008 16:10:25 +0000 Received: from nan.false.org (localhost [127.0.0.1]) by nan.false.org (Postfix) with ESMTP id 0A2F51059A; Sun, 23 Nov 2008 16:10:15 +0000 (GMT) Received: from caradoc.them.org (209.195.188.212.nauticom.net [209.195.188.212]) by nan.false.org (Postfix) with ESMTP id DB31C104A1; Sun, 23 Nov 2008 16:10:14 +0000 (GMT) Received: from drow by caradoc.them.org with local (Exim 4.69) (envelope-from ) id 1L4HXJ-0004AT-OC; Sun, 23 Nov 2008 11:10:13 -0500 Date: Mon, 24 Nov 2008 13:32:00 -0000 From: Daniel Jacobowitz To: Thiago Jung Bauermann Cc: gdb-patches ml Subject: Re: [RFA] Add la_getstr member to language_defn Message-ID: <20081123161013.GA15069@caradoc.them.org> Mail-Followup-To: Thiago Jung Bauermann , gdb-patches ml References: <1227417278.28256.183.camel@localhost.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1227417278.28256.183.camel@localhost.localdomain> User-Agent: Mutt/1.5.17 (2008-05-11) X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2008-11/txt/msg00625.txt.bz2 On Sun, Nov 23, 2008 at 03:14:37AM -0200, Thiago Jung Bauermann wrote: > One improvement which is easy to make but I left for later (this patch > is big enough already) is to nuke target_read_string and make its > callers use read_string instead (the former implements just a subset of > what the latter provides). It would be a simple modification, but would > affect code specific to targets to which I don't have access to > (target_read_string is almost exclusively used in solib-*.c). I can work > on a subsequent patch to do that if you think it's safe enough to not > require my testing on all affected targets. What's the difference between them? > +/* Obtain a C string from the inferior, storing it in a newly allocated > + buffer in BUFFER, which should be freed by the caller. If VALUE is an > + array with known length, the function will copy all of its contents to > + the buffer. If the length is not known, read until a null byte is found. > + LENGTH will contain the size of the string (not counting the NULL > + character). This is the right behavior for gdb's "print VAR". But I'm not sure it's the right behavior for a method named la_getstr - in fact I think it isn't. Suppose (to pick a random example with no relation to anything - no, wait, it's from the Linux kernel...): struct task_struct { volatile long state; ... char comm[16]; ... }; If I ask for the contents of the array, I should get sixteen bytes. But if I ask for a string I ought to get, in my opinion, up to sixteen bytes. Characters up to but not including the first zero, or sixteen at most. A ps implementation which prints "comm\0er command" is not very helpful :-) BTW, it's not a NULL character; it's NUL, the null character. NULL in uppercase is the pointer. -- Daniel Jacobowitz CodeSourcery