+2018-05-02 Tom Tromey <tom@tromey.com>
+
+ PR python/20084:
+ * python/python.c (gdbpy_parameter_value): Handle var_zuinteger
+ and var_zuinteger_unlimited.
+ * python/py-param.c (struct parm_constant): Add PARAM_ZUINTEGER
+ and PARAM_ZUINTEGER_UNLIMITED.
+ (set_parameter_value): Handle var_zuinteger and
+ var_zuinteger_unlimited.
+ (add_setshow_generic): Likewise.
+ (parmpy_init): Likewise.
+
2018-04-28 Dan Robertson <danlrobertson89@gmail.com>
PR rust/23124
+2018-05-02 Tom Tromey <tom@tromey.com>
+
+ PR python/20084:
+ * python.texi (Parameters In Python): Document PARAM_ZUINTEGER and
+ PARAM_ZUINTEGER_UNLIMITED.
+
2018-04-30 Tom Tromey <tom@tromey.com>
* python.texi (Types In Python): Document Type.align.
The value is an integer. This is like @code{PARAM_INTEGER}, except 0
is interpreted as itself.
+@findex PARAM_ZUINTEGER
+@findex gdb.PARAM_ZUINTEGER
+@item gdb.PARAM_ZUINTEGER
+The value is an unsigned integer. This is like @code{PARAM_INTEGER},
+except 0 is interpreted as itself, and the value cannot be negative.
+
+@findex PARAM_ZUINTEGER_UNLIMITED
+@findex gdb.PARAM_ZUINTEGER_UNLIMITED
+@item gdb.PARAM_ZUINTEGER_UNLIMITED
+The value is a signed integer. This is like @code{PARAM_ZUINTEGER},
+except the special value -1 should be interpreted to mean
+``unlimited''. Other negative values are not allowed.
+
@findex PARAM_ENUM
@findex gdb.PARAM_ENUM
@item gdb.PARAM_ENUM
{ "PARAM_OPTIONAL_FILENAME", var_optional_filename },
{ "PARAM_FILENAME", var_filename },
{ "PARAM_ZINTEGER", var_zinteger },
+ { "PARAM_ZUINTEGER", var_zuinteger },
+ { "PARAM_ZUINTEGER_UNLIMITED", var_zuinteger_unlimited },
{ "PARAM_ENUM", var_enum },
{ NULL, 0 }
};
case var_integer:
case var_zinteger:
case var_uinteger:
+ case var_zuinteger:
+ case var_zuinteger_unlimited:
{
long l;
int ok;
if (! gdb_py_int_as_long (value, &l))
return -1;
- if (self->type == var_uinteger)
+ switch (self->type)
{
- ok = (l >= 0 && l <= UINT_MAX);
+ case var_uinteger:
if (l == 0)
l = UINT_MAX;
- }
- else if (self->type == var_integer)
- {
+ /* Fall through. */
+ case var_zuinteger:
+ ok = (l >= 0 && l <= UINT_MAX);
+ break;
+
+ case var_zuinteger_unlimited:
+ ok = (l >= -1 && l <= INT_MAX);
+ break;
+
+ case var_integer:
ok = (l >= INT_MIN && l <= INT_MAX);
if (l == 0)
l = INT_MAX;
+ break;
+
+ case var_zinteger:
+ ok = (l >= INT_MIN && l <= INT_MAX);
+ break;
+
+ default:
+ gdb_assert_not_reached ("unknown var_ constant");
}
- else
- ok = (l >= INT_MIN && l <= INT_MAX);
if (! ok)
{
return -1;
}
- self->value.intval = (int) l;
+ if (self->type == var_uinteger || self->type == var_zuinteger)
+ self->value.uintval = (unsigned) l;
+ else
+ self->value.intval = (int) l;
break;
}
set_list, show_list);
break;
+ case var_zuinteger:
+ add_setshow_zuinteger_cmd (cmd_name, cmdclass,
+ &self->value.uintval, set_doc, show_doc,
+ help_doc, get_set_value, get_show_value,
+ set_list, show_list);
+ break;
+
+ case var_zuinteger_unlimited:
+ add_setshow_zuinteger_unlimited_cmd (cmd_name, cmdclass,
+ &self->value.intval, set_doc,
+ show_doc, help_doc, get_set_value,
+ get_show_value,
+ set_list, show_list);
+ break;
+
case var_enum:
add_setshow_enum_cmd (cmd_name, cmdclass, self->enumeration,
&self->value.cstringval, set_doc, show_doc,
&& parmclass != var_uinteger && parmclass != var_integer
&& parmclass != var_string && parmclass != var_string_noescape
&& parmclass != var_optional_filename && parmclass != var_filename
- && parmclass != var_zinteger && parmclass != var_enum)
+ && parmclass != var_zinteger && parmclass != var_zuinteger
+ && parmclass != var_zuinteger_unlimited && parmclass != var_enum)
{
PyErr_SetString (PyExc_RuntimeError,
_("Invalid parameter class argument."));
Py_RETURN_NONE;
/* Fall through. */
case var_zinteger:
+ case var_zuinteger_unlimited:
return PyLong_FromLong (* (int *) var);
case var_uinteger:
Py_RETURN_NONE;
return PyLong_FromUnsignedLong (val);
}
+
+ case var_zuinteger:
+ {
+ unsigned int val = * (unsigned int *) var;
+ return PyLong_FromUnsignedLong (val);
+ }
}
return PyErr_Format (PyExc_RuntimeError,
+2018-05-02 Tom Tromey <tom@tromey.com>
+
+ PR python/20084:
+ * gdb.python/py-parameter.exp: Add PARAM_ZUINTEGER and
+ PARAM_ZUINTEGER_UNLIMITED tests.
+
2018-04-28 Dan Robertson <danlrobertson89@gmail.com>
PR rust/23124
gdb_test "help show print test-param" "State of the Test Parameter.*" "test show help"
gdb_test "help set print test-param" "Set the state of the Test Parameter.*" "test set help"
gdb_test "help set print" "set print test-param -- Set the state of the Test Parameter.*" "test general help"
+
+foreach kind {PARAM_ZUINTEGER PARAM_ZUINTEGER_UNLIMITED} {
+ gdb_py_test_multiple "Simple gdb $kind" \
+ "python" "" \
+ "class TestNodocParam (gdb.Parameter):" "" \
+ " def __init__ (self, name):" "" \
+ " super (TestNodocParam, self).__init__ (name, gdb.COMMAND_DATA, gdb.$kind)" "" \
+ " self.value = 0" "" \
+ "test_param_$kind = TestNodocParam ('test-$kind')" "" \
+ "end"
+
+ gdb_test "python print(gdb.parameter('test-$kind'))" "0"
+
+ gdb_test "python test_param_$kind.value = -5" "RuntimeError: Range exceeded.*"
+
+ if {$kind == "PARAM_ZUINTEGER"} {
+ gdb_test "python test_param_$kind.value = -1" "RuntimeError: Range exceeded.*"
+ } else {
+ gdb_test_no_output "python test_param_$kind.value = -1" ""
+ gdb_test "python print(gdb.parameter('test-$kind'))" "-1" \
+ "check that PARAM_ZUINTEGER value is -1 after setting"
+ }
+}