Allow setting a parameter to raise gdb.GdbError

A convention in the Python layer is that raising a gdb.GdbError will
not print the Python stack -- instead the exception is treated as any
other gdb exception.

PR python/18852 asks that this treatment be extended the the
get_set_value method of gdb.Parameter.  This makes sense, because it
lets Python-created parameters act like gdb parameters.

2018-09-23  Tom Tromey  <tom@tromey.com>

	PR python/18852:
	* python/py-param.c (get_set_value): Use gdbpy_handle_exception.

gdb/doc/ChangeLog
2018-09-23  Tom Tromey  <tom@tromey.com>

	PR python/18852:
	* python.texi (Parameters In Python): Document exception behavior
	of get_set_string.

gdb/testsuite/ChangeLog
2018-09-23  Tom Tromey  <tom@tromey.com>

	PR python/18852:
	* gdb.python/py-parameter.exp: Add test for parameter that throws
	on "set".
This commit is contained in:
Tom Tromey 2018-09-15 01:09:22 -06:00
parent 2b4ad2fe43
commit ae778caf09
6 changed files with 57 additions and 4 deletions

View file

@ -203,3 +203,18 @@ foreach kind {PARAM_ZUINTEGER PARAM_ZUINTEGER_UNLIMITED} {
"check that PARAM_ZUINTEGER value is -1 after setting"
}
}
gdb_py_test_multiple "Throwing gdb parameter" \
"python" "" \
"class TestThrowParam (gdb.Parameter):" "" \
" def __init__ (self, name):" "" \
" super (TestThrowParam, self).__init__ (name, gdb.COMMAND_DATA, gdb.PARAM_STRING)" "" \
" self.value = True" "" \
" def get_set_string (self):" "" \
" raise gdb.GdbError('Ordinary gdb error')" "" \
"test_throw_param = TestThrowParam ('print test-throw-param')" ""\
"end"
gdb_test "set print test-throw-param whoops" \
"Ordinary gdb error" \
"gdb.GdbError does not show Python stack"