public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: "Maciej W. Rozycki" <macro@embecosm.com>
To: gdb-patches@sourceware.org
Cc: Andrew Burgess <aburgess@redhat.com>,
	 Simon Marchi <simon.marchi@polymtl.ca>,
	Tom Tromey <tom@tromey.com>,  Simon Sobisch <simonsobisch@web.de>
Subject: [PATCH v4 2/8] GDB/Python: Use None for `var_zuinteger_unlimited' value set to `unlimited'
Date: Wed, 9 Mar 2022 19:18:00 +0000 (GMT)	[thread overview]
Message-ID: <alpine.DEB.2.20.2203082344230.11552@tpp.orcam.me.uk> (raw)
In-Reply-To: <alpine.DEB.2.20.2203031442040.11552@tpp.orcam.me.uk>

Consistently with the `var_integer' and `var_uinteger' parameters return 
the special value of None for a `var_zuinteger_unlimited' parameter set 
to `unlimited' by using the Py_RETURN_NONE macro in this case, fixing 
commit 0489430a0e1a ("Handle var_zuinteger and var_zuinteger_unlimited 
from Python"); cf. PR python/20084.  Adjust the testsuite accordingly. 
---
New change in v4.
---
 gdb/python/python.c                       |   10 +++++++++-
 gdb/testsuite/gdb.python/py-parameter.exp |    4 ++--
 2 files changed, 11 insertions(+), 3 deletions(-)

gdb-python-var-zuinteger-unlimited-none.diff
Index: src/gdb/python/python.c
===================================================================
--- src.orig/gdb/python/python.c
+++ src/gdb/python/python.c
@@ -512,9 +512,17 @@ gdbpy_parameter_value (const setting &va
 	Py_RETURN_NONE;
       /* Fall through.  */
     case var_zinteger:
-    case var_zuinteger_unlimited:
       return gdb_py_object_from_longest (var.get<int> ()).release ();
 
+    case var_zuinteger_unlimited:
+      {
+	int val = var.get<int> ();
+
+	if (val == -1)
+	  Py_RETURN_NONE;
+	return gdb_py_object_from_longest (val).release ();
+      }
+
     case var_uinteger:
       {
 	unsigned int val = var.get<unsigned int> ();
Index: src/gdb/testsuite/gdb.python/py-parameter.exp
===================================================================
--- src.orig/gdb/testsuite/gdb.python/py-parameter.exp
+++ src/gdb/testsuite/gdb.python/py-parameter.exp
@@ -343,8 +343,8 @@ proc_with_prefix test_integer_parameter
 	} elseif {$kind == "PARAM_ZUINTEGER_UNLIMITED"} {
 	    gdb_test_no_output "python test_param_$kind.value = -1" \
 		"check that PARAM_ZUINTEGER value can be set to -1"
-	    gdb_test "python print(gdb.parameter('test-$kind'))" "-1" \
-		"check that PARAM_ZUINTEGER value is -1 after setting"
+	    gdb_test "python print(gdb.parameter('test-$kind'))" "None" \
+		"check that PARAM_ZUINTEGER value is None after setting"
 	} else {
 	    error "invalid kind: $kind"
 	}

  parent reply	other threads:[~2022-03-09 19:18 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-09 19:17 [PATCH v4 0/8] gdb: split array and string limiting options Maciej W. Rozycki
2022-03-09 19:17 ` [PATCH v4 1/8] GDB: Remove extraneous full stops from `set' command error messages Maciej W. Rozycki
2022-03-09 19:18 ` Maciej W. Rozycki [this message]
2022-03-09 19:18 ` [PATCH v4 3/8] GDB: Add `NUMBER' completion to `set' integer commands Maciej W. Rozycki
2022-03-09 19:18 ` [PATCH v4 4/8] GDB/testsuite: Tighten `set print elements' error check Maciej W. Rozycki
2022-03-09 19:18 ` [PATCH v4 5/8] GDB/testsuite: Add coverage for `print -elements' command Maciej W. Rozycki
2022-03-09 19:18 ` [PATCH v4 6/8] GDB: Allow arbitrary keywords in integer set commands Maciej W. Rozycki
2022-03-09 19:18 ` [PATCH v4 7/8] GDB: Add a character string limiting option Maciej W. Rozycki
2022-03-09 19:51   ` Eli Zaretskii
2022-03-09 20:40     ` Maciej W. Rozycki
2022-03-10  0:03       ` Maciej W. Rozycki
2022-03-10  6:35         ` Eli Zaretskii
2022-03-10  6:28       ` Eli Zaretskii
2022-03-10 10:08         ` Maciej W. Rozycki
2022-03-10 11:55           ` Eli Zaretskii
2022-03-10 12:25             ` Maciej W. Rozycki
2022-03-10 17:15           ` Tom Tromey
2022-03-30 10:38             ` Maciej W. Rozycki
2022-03-30 13:15               ` Pedro Alves
2022-03-30 14:17                 ` Maciej W. Rozycki
2022-03-09 19:18 ` [PATCH v4 8/8] GDB/testsuite: Expand for character string limiting options Maciej W. Rozycki
2022-03-09 19:47 ` [PATCH v4 0/8] gdb: split array and " Simon Sobisch

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.2203082344230.11552@tpp.orcam.me.uk \
    --to=macro@embecosm.com \
    --cc=aburgess@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=simon.marchi@polymtl.ca \
    --cc=simonsobisch@web.de \
    --cc=tom@tromey.com \
    /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).