gdb/python: have UnwindInfo.add_saved_register accept named args
Update gdb.UnwindInfo.add_saved_register to accept named keyword arguments. As part of this update we now use gdb_PyArg_ParseTupleAndKeywords instead of PyArg_UnpackTuple to parse the function arguments. By switching to gdb_PyArg_ParseTupleAndKeywords, we can now use 'O!' as the argument format for the function's value argument. This means that we can check the argument type (is gdb.Value) as part of the argument processing rather than manually performing the check later in the function. One result of this is that we now get a better error message (at least, I think so). Previously we would get something like: ValueError: Bad register value Now we get: TypeError: argument 2 must be gdb.Value, not XXXX It's unfortunate that the exception type changed, but I think the new exception type actually makes more sense. My preference for argument names is to use full words where that's not too excessive. As such, I've updated the name of the argument from 'reg' to 'register' in the documentation, which is the argument name I've made GDB look for here. For existing unwinder code that doesn't throw any exceptions nothing should change with this commit. It is possible that a user has some code that throws and catches the ValueError, and this code will break after this commit, but I think this is going to be sufficiently rare that we can take the risk here. Reviewed-By: Eli Zaretskii <eliz@gnu.org> Reviewed-By: Tom Tromey <tom@tromey.com>
This commit is contained in:
parent
cf141dd8cc
commit
d2d62da62e
4 changed files with 75 additions and 56 deletions
|
@ -2882,8 +2882,8 @@ Use @code{PendingFrame.create_unwind_info} method described above to
|
|||
create a @code{gdb.UnwindInfo} instance. Use the following method to
|
||||
specify caller registers that have been saved in this frame:
|
||||
|
||||
@defun gdb.UnwindInfo.add_saved_register (reg, value)
|
||||
@var{reg} identifies the register, for a description of the acceptable
|
||||
@defun gdb.UnwindInfo.add_saved_register (register, value)
|
||||
@var{register} identifies the register, for a description of the acceptable
|
||||
values see @ref{gdbpy_frame_read_register,,Frame.read_register}.
|
||||
@var{value} is a register value (a @code{gdb.Value} object).
|
||||
@end defun
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue