Handle var_zuinteger and var_zuinteger_unlimited from Python

PR python/20084 points out that the Python API doesn't handle the
var_zuinteger and var_zuinteger_unlimited parameter types.

This patch adds support for these types.

Regression tested on x86-64 Fedora 26.

ChangeLog
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.

doc/ChangeLog
2018-05-02  Tom Tromey  <tom@tromey.com>

	PR python/20084:
	* python.texi (Parameters In Python): Document PARAM_ZUINTEGER and
	PARAM_ZUINTEGER_UNLIMITED.

testsuite/ChangeLog
2018-05-02  Tom Tromey  <tom@tromey.com>

	PR python/20084:
	* gdb.python/py-parameter.exp: Add PARAM_ZUINTEGER and
	PARAM_ZUINTEGER_UNLIMITED tests.
This commit is contained in:
Tom Tromey
2018-04-26 16:18:07 -06:00
parent d966ab2dc5
commit 0489430a0e
7 changed files with 112 additions and 9 deletions

View File

@ -179,3 +179,26 @@ gdb_test "python print (test_param.value)" "False" "test parameter value"
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"
}
}