[PATCH v4 2/8] GDB/Python: Use None for `var_zuinteger_unlimited' value set to `unlimited'
Maciej W. Rozycki
macro@embecosm.com
Wed Mar 9 19:18:00 GMT 2022
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"
}
More information about the Gdb-patches
mailing list