GDB/Python: Make None' stand for
unlimited' in setting integer parameters
Similarly to booleans and following the fix for PR python/29217 make `gdb.parameter' accept `None' for `unlimited' with parameters of the PARAM_UINTEGER, PARAM_INTEGER, and PARAM_ZUINTEGER_UNLIMITED types, as `None' is already returned by parameters of the two former types, so one might expect to be able to feed it back. It also makes it possible to avoid the need to know what the internal integer representation is for the special setting of `unlimited'. Expand the testsuite accordingly. Approved-By: Simon Marchi <simon.marchi@polymtl.ca>
This commit is contained in:
parent
e7e1f20345
commit
c506be7d9b
3 changed files with 28 additions and 12 deletions
|
@ -235,9 +235,12 @@ def find_pc_line(pc):
|
|||
|
||||
def set_parameter(name, value):
|
||||
"""Set the GDB parameter NAME to VALUE."""
|
||||
# Handle the specific case of booleans here, because gdb.parameter
|
||||
# can return them, but they can't be passed to 'set' this way.
|
||||
if isinstance(value, bool):
|
||||
# Handle the specific cases of None and booleans here, because
|
||||
# gdb.parameter can return them, but they can't be passed to 'set'
|
||||
# this way.
|
||||
if value is None:
|
||||
value = "unlimited"
|
||||
elif isinstance(value, bool):
|
||||
if value:
|
||||
value = "on"
|
||||
else:
|
||||
|
|
|
@ -243,14 +243,18 @@ set_parameter_value (parmpy_object *self, PyObject *value)
|
|||
long l;
|
||||
int ok;
|
||||
|
||||
if (!PyLong_Check (value))
|
||||
if (value == Py_None
|
||||
&& (self->type == var_uinteger || self->type == var_integer))
|
||||
l = 0;
|
||||
else if (value == Py_None && self->type == var_zuinteger_unlimited)
|
||||
l = -1;
|
||||
else if (!PyLong_Check (value))
|
||||
{
|
||||
PyErr_SetString (PyExc_RuntimeError,
|
||||
_("The value must be integer."));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (! gdb_py_int_as_long (value, &l))
|
||||
else if (! gdb_py_int_as_long (value, &l))
|
||||
return -1;
|
||||
|
||||
switch (self->type)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue