From: Daniel Jacobowitz <drow@false.org>
To: Thiago Jung Bauermann <bauerman@br.ibm.com>
Cc: gdb-patches ml <gdb-patches@sourceware.org>
Subject: Re: [RFA] Add la_getstr member to language_defn
Date: Mon, 24 Nov 2008 13:32:00 -0000 [thread overview]
Message-ID: <20081123161013.GA15069@caradoc.them.org> (raw)
In-Reply-To: <1227417278.28256.183.camel@localhost.localdomain>
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
next prev parent reply other threads:[~2008-11-23 16:11 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-24 13:24 Thiago Jung Bauermann
2008-11-24 13:32 ` Daniel Jacobowitz [this message]
2008-11-24 14:59 ` Thiago Jung Bauermann
2008-11-24 16:19 ` Daniel Jacobowitz
2008-11-24 20:22 ` Thiago Jung Bauermann
2008-11-25 2:16 ` Daniel Jacobowitz
2008-11-25 8:53 ` Thiago Jung Bauermann
2009-01-03 2:27 ` Thiago Jung Bauermann
2009-02-02 18:42 ` Tom Tromey
2009-02-03 12:51 ` Thiago Jung Bauermann
2009-02-03 17:44 ` Tom Tromey
2009-02-04 12:37 ` Thiago Jung Bauermann
2009-02-04 19:19 ` Tom Tromey
2009-02-04 22:26 ` Thiago Jung Bauermann
2009-02-05 0:55 ` Tom Tromey
2009-02-05 12:21 ` Thiago Jung Bauermann
2009-02-05 16:01 ` Pierre Muller
2009-02-05 16:30 ` Thiago Jung Bauermann
2009-02-05 16:46 ` Tom Tromey
2009-02-05 15:55 ` Tom Tromey
2009-02-05 16:07 ` Pierre Muller
2009-02-05 16:33 ` Thiago Jung Bauermann
2009-02-05 16:46 ` Tom Tromey
2009-02-03 0:23 ` Joel Brobecker
2009-02-03 13:02 ` Thiago Jung Bauermann
2009-02-03 17:01 ` Joel Brobecker
2009-02-03 17:40 ` Tom Tromey
2009-02-05 17:01 ` Thiago Jung Bauermann
2009-02-05 23:51 ` Joel Brobecker
2008-11-24 20:03 ` Tom Tromey
2008-11-24 21:19 ` Thiago Jung Bauermann
2008-11-25 0:55 ` Tom Tromey
2008-11-25 11:27 ` Thiago Jung Bauermann
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=20081123161013.GA15069@caradoc.them.org \
--to=drow@false.org \
--cc=bauerman@br.ibm.com \
--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