public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: "Maciej W. Rozycki" <macro@embecosm.com>
To: Simon Marchi <simon.marchi@polymtl.ca>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH] gdb: split array and string limiting options
Date: Tue, 14 Dec 2021 16:35:11 +0000 (GMT)	[thread overview]
Message-ID: <alpine.DEB.2.20.2112140020220.10183@tpp.orcam.me.uk> (raw)
In-Reply-To: <79a90d9f-15a7-c1e9-cc2b-5c7bfa0fc470@polymtl.ca>

On Wed, 8 Dec 2021, Simon Marchi wrote:

> > diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
> > index a6f207a41a7..a92727bb3f1 100644
> > --- a/gdb/doc/gdb.texinfo
> > +++ b/gdb/doc/gdb.texinfo
> > @@ -9994,10 +9994,15 @@
> >  Set printing of array indexes.
> >  Related setting: @ref{set print array-indexes}.
> >  
> > +@item -characters @var{number-of-characters}|@code{unlimited}
> > +Set limit on string character to print.  The value @code{unlimited}
> 
> character -> characters?

 Sure!

> > diff --git a/gdb/python/py-value.c b/gdb/python/py-value.c
> > index d45df5fd113..98b5cceed3f 100644
> > --- a/gdb/python/py-value.c
> > +++ b/gdb/python/py-value.c
> > @@ -623,6 +623,7 @@ valpy_format_string (PyObject *self, PyObject *args, PyObject *kw)
> >        "actual_objects",		/* See set print object on|off.  */
> >        "static_members",		/* See set print static-members on|off.  */
> >        /* C non-bool options.  */
> > +      "max_characters", 	/* See set print elements N.  */
> 
> I guess the comment should say "see set print characters N".

 Fixed, obvious.

> We would need a corresponding doc update for this, in python.texi.

 Right, completed in the obvious way.

> > diff --git a/gdb/valprint.h b/gdb/valprint.h
> > index e1dae2cc8fc..f58d6ba7b0e 100644
> > --- a/gdb/valprint.h
> > +++ b/gdb/valprint.h
> > @@ -54,6 +54,9 @@ struct value_print_options
> >       "unlimited".  */
> >    unsigned int print_max;
> >  
> > +  /* Maxiumum number of string chars to print */
> 
> Maxiumum -> Maximum.  End with a period + 2 spaces.

 Fixed, and actually expanded, taking from the preceding comment which has 
had to be adjusted accordingly.

> > +  unsigned int print_smax;
> 
> I would suggest using a clearer name, like print_max_chars.

 Suggestion accepted as obvious and applied throughout.  This has resulted 
in some code and comment reformatting as needed, fixing preexisting style 
issues in the adjacent lines where appropriate too.

> Although Eli raised a good question, do we limit the number bytes of
> characters?  What would happen if we print a wide char or UTF-8 string?

 AFAICT the intent is to count actual characters however they are 
represented rather than bytes, e.g. `printstr' in ada-valprint.c has:

  for (i = 0; i < length && things_printed < options->print_max_chars; i += 1)
    {
[...]
	  ada_emit_char (char_at (string, i, type_len, byte_order),
			 elttype, stream, '"', type_len);

and `char_at' does interpret multibyte characters correctly:

/* Character #I of STRING, given that TYPE_LEN is the size in bytes
   of a character.  */

and similarly `generic_printstr' in valprint.c has:

  int width = TYPE_LENGTH (type);
[...]
  /* Arrange to iterate over the characters, in wchar_t form.  */
  wchar_iterator iter (string, length * width, encoding, width);

etc.  I guess there may be bugs somewhere, but this change does not affect 
them and is not supposed to, as it only splits a preexisting setting into 
two while retaining the original interpretation.  So for all intents and 
purposes I think it is appropriate to refer to string characters rather 
string bytes here.  Does this investigation clear your concerns?

 Thank you for your review.  Posting v2 separately.

  Maciej

  reply	other threads:[~2021-12-14 16:35 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-07 13:14 Andrew Burgess
2021-10-07 13:38 ` Eli Zaretskii
2021-11-02 10:04 ` [PING][PATCH] " Maciej W. Rozycki
2021-11-09 16:45 ` [PING^2][PATCH] " Maciej W. Rozycki
2021-11-16 12:40 ` [PING^3][PATCH] " Maciej W. Rozycki
2021-11-23 21:37 ` [PING^4][PATCH] " Maciej W. Rozycki
2021-11-30 13:15 ` [PING^5][PATCH] " Maciej W. Rozycki
2021-12-08 23:19 ` [PING^6][PATCH] " Maciej W. Rozycki
2021-12-09  3:01 ` [PATCH] " Simon Marchi
2021-12-14 16:35   ` Maciej W. Rozycki [this message]
2022-01-14 19:52 ` Tom Tromey

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=alpine.DEB.2.20.2112140020220.10183@tpp.orcam.me.uk \
    --to=macro@embecosm.com \
    --cc=gdb-patches@sourceware.org \
    --cc=simon.marchi@polymtl.ca \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).