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:
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)
"listsize" {
set param_get_zero None
set param_get_minus_one -1
+ set param_get_none None
set param_get_unlimited None
set param_set_minus_one ""
}
"print elements" {
set param_get_zero None
set param_get_minus_one None
+ set param_get_none None
set param_get_unlimited None
set param_set_minus_one $param_range_error
}
"max-completions" {
set param_get_zero 0
set param_get_minus_one -1
+ set param_get_none -1
set param_get_unlimited -1
set param_set_minus_one ""
}
gdb_test "python print(gdb.parameter('$param'))" \
$param_get_minus_one "test value of -1"
+ gdb_test_no_output "python gdb.set_parameter('$param', None)" \
+ "test set to None"
+
+ gdb_test "python print(gdb.parameter('$param'))" \
+ $param_get_none "test value of None"
+
gdb_test_no_output "python gdb.set_parameter('$param', 'unlimited')" \
"test set to 'unlimited'"
set param_get_zero None
set param_get_minus_one None
set param_get_minus_five 1
- set param_get_none 5
+ set param_get_none None
set param_set_minus_one $param_range_error
set param_set_minus_five $param_range_error
- set param_set_none $param_integer_error
+ set param_set_none ""
}
PARAM_INTEGER {
set param_get_zero None
set param_get_minus_one -1
set param_get_minus_five -5
- set param_get_none 5
+ set param_get_none None
set param_set_minus_one -1
set param_set_minus_five -5
- set param_set_none $param_integer_error
+ set param_set_none ""
}
PARAM_ZINTEGER {
set param_get_zero 0
set param_get_zero 0
set param_get_minus_one -1
set param_get_minus_five 1
- set param_get_none 5
+ set param_get_none -1
set param_set_minus_one ""
set param_set_minus_five $param_range_error
- set param_set_none $param_integer_error
+ set param_set_none ""
}
default {
error "invalid kind: $kind"