Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Thiago Jung Bauermann <bauerman@br.ibm.com>
To: Daniel Jacobowitz <drow@false.org>
Cc: gdb-patches ml <gdb-patches@sourceware.org>
Subject: Re: [RFA] Add la_getstr member to language_defn
Date: Mon, 24 Nov 2008 20:22:00 -0000	[thread overview]
Message-ID: <1227551659.28256.225.camel@localhost.localdomain> (raw)
In-Reply-To: <20081124022858.GA19331@caradoc.them.org>

El dom, 23-11-2008 a las 21:28 -0500, Daniel Jacobowitz escribió:
> On Sun, Nov 23, 2008 at 11:40:21PM -0200, Thiago Jung Bauermann wrote:
> > The comment is wrong. c_getstr actually reads until a null character is
> > found, but doesn't read past the end of an array with known length. I
> > updated the comment to reflect that.
> > 
> > Except that there was a bug for GDB-hosted strings, in which case the
> > function behaved as described by the comment. I fixed it now.
> 
> Are you sure?  I took a look at read_string and its comments and it
> seemed to do what I described - but I might be wrong.
> 
> +   If LEN is -1, stops at the first null character (not necessarily the first
> +   null byte) up to a maximum of FETCHLIMIT characters, otherwise reading
> +   proceeds (including null characters) until LEN characters have been read.
> +   Set FETCHLIMIT to UINT_MAX to read as many characters as possible from the
> +   string.

c_getstr allways passes -1 as the LEN argument, and if the length of the
array is known, it passes the length as FETCHLIMIT. If it is not known,
FETCHLIMIT will be UINT_MAX (actually, the code currently passes -1,
I'll change it to pass UINT_MAX explicitly).

Would the comment above be clearer if it read as follows?

  If LEN > 0, reads exactly LEN characters (including eventual NULs in
  the middle or end of the string).  If LEN is -1, stops at the first
  null character (not necessarily the first null byte) up to a maximum
  of FETCHLIMIT characters.  Set FETCHLIMIT to UINT_MAX to read as many
  characters as possible from the string.

By the way, I just realised that if LEN is 0, BUFFER is not allocated,
contradicting the property I mention in the comment that "unless an
exception is thrown, BUFFER will always be allocated, even on failure".
I'll change it to allocate a 1 byte buffer in this case, to keep the
caller's life simple.
-- 
[]'s
Thiago Jung Bauermann
IBM Linux Technology Center


  reply	other threads:[~2008-11-24 18:35 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
2008-11-24 14:59   ` Thiago Jung Bauermann
2008-11-24 16:19     ` Daniel Jacobowitz
2008-11-24 20:22       ` Thiago Jung Bauermann [this message]
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=1227551659.28256.225.camel@localhost.localdomain \
    --to=bauerman@br.ibm.com \
    --cc=drow@false.org \
    --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