public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Simon Sobisch <simonsobisch@web.de>
To: gdb-patches@sourceware.org
Subject: Re: [PATCH v2] gdb: split array and string limiting options
Date: Thu, 6 Jan 2022 08:58:38 +0100	[thread overview]
Message-ID: <111e4bb6-d781-ff80-f64b-125ad665f502@web.de> (raw)

 > From: Andrew Burgess <andrew.burgess@embecosm.com>
 >
 > This commit splits the set/show print elements options into two.  We
 > retain set/show print elements for controlling how many elements of an
 > array we print, but a new set/show print characters is added which is
 > used for controlling how many characters of a string are printed.
 > [...]
Reference to the full patch:
https://sourceware.org/pipermail/gdb-patches/2021-December/184467.html


I really like the general idea and would like to see this added, but I
think the patch goes too far and will break both old and new usage.

In my opinion there should be only 1 new test for the new setting and
the other should be left unchanged while still working, because then
existing usages will still work, too.

To do so the new parameter cannot be directly used as it is in the patch
but must be fowarded to a new function or duplicated.

As an example this would mean instead of :

--- src.orig/gdb/c-valprint.c
+++ src/gdb/c-valprint.c
@@ -271,7 +271,7 @@ c_value_print_array (struct value *val,

     for (temp_len = 0;
  	   (temp_len < len
-	    && temp_len < options->print_max
+	    && temp_len < options->print_max_chars
  	    && extract_unsigned_integer (valaddr + temp_len * eltlen,
  					 eltlen, byte_order) != 0);
  		   ++temp_len)

have the following


+   const int print_max_chars = (options->print_max_chars != -1) ?
options->print_max_chars : options->print_max;
     for (temp_len = 0;
  	   (temp_len < len
-	    && temp_len < options->print_max
+	    && temp_len < print_max_chars
  	    && extract_unsigned_integer (valaddr + temp_len * eltlen,
  					 eltlen, byte_order) != 0);
  		   ++temp_len)


This effectively means that until you explicit set the new "print
characters" the existing "print elements" setting will be used, and if
you "set print characters off" (or similar, that would internally
resolve to -1) you get the length depending on "print elements" again.

The parameter type in python for "print elements" is (guessed)
gdb.PARAM_UINTEGER, the type for "print characters" would be
gdb.PARAM_INTEGER with -1 meaning "take the other parameter".


If those changes are done there is no breakage whatever which could also
speedup the inclusion s it hopefully lands in GDB 11.2.

Simon


             reply	other threads:[~2022-01-06  7:58 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-06  7:58 Simon Sobisch [this message]
2022-01-06  9:33 ` Andrew Burgess
2022-01-06 13:32   ` Simon Sobisch
2022-01-06 14:18     ` Andrew Burgess
2022-01-26 15:48     ` Maciej W. Rozycki
2022-01-26 16:52       ` Simon Sobisch
2022-01-26 18:18         ` Maciej W. Rozycki
  -- strict thread matches above, loose matches on Subject: below --
2021-12-14 16:38 Maciej W. Rozycki
2021-12-14 17:24 ` Eli Zaretskii
2021-12-15 18:01 ` Andrew Burgess
2022-01-04 23:15   ` Maciej W. Rozycki

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=111e4bb6-d781-ff80-f64b-125ad665f502@web.de \
    --to=simonsobisch@web.de \
    --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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).