diff options
author | Andrew Burgess <aburgess@redhat.com> | 2023-03-14 11:43:14 +0000 |
---|---|---|
committer | Andrew Burgess <aburgess@redhat.com> | 2023-04-06 15:01:43 +0100 |
commit | 56fcb715a9f6abddd51f981e15a14d88ae766fc5 (patch) | |
tree | 30dce3b3c70c1b6f88a54e450ab92cfdb50657a6 /gdb/python | |
parent | d2d62da62ec9c5486b19d8ffc7b4ef4070e8df7a (diff) | |
download | gdb-56fcb715a9f6abddd51f981e15a14d88ae766fc5.zip gdb-56fcb715a9f6abddd51f981e15a14d88ae766fc5.tar.gz gdb-56fcb715a9f6abddd51f981e15a14d88ae766fc5.tar.bz2 |
gdb/python: have PendingFrame methods accept keyword arguments
Update the two gdb.PendingFrame methods gdb.PendingFrame.read_register
and gdb.PendingFrame.create_unwind_info to accept keyword arguments.
There's no huge benefit for making this change, both of these methods
only take a single argument, so it is (maybe) less likely that a user
will take advantage of the keyword arguments in these cases, but I
think it's nice to be consistent, and I don't see any particular draw
backs to making this change.
For PendingFrame.read_register I've changed the argument name from
'reg' to 'register' in the documentation and used 'register' as the
argument name in GDB. My preference for APIs is to use full words
where possible, and given we didn't support named arguments before
this change should not break any existing code.
There should be no user visible changes (for existing code) after this
commit.
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Reviewed-By: Tom Tromey <tom@tromey.com>
Diffstat (limited to 'gdb/python')
-rw-r--r-- | gdb/python/py-unwind.c | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/gdb/python/py-unwind.c b/gdb/python/py-unwind.c index 2e13b84..d83979b 100644 --- a/gdb/python/py-unwind.c +++ b/gdb/python/py-unwind.c @@ -443,16 +443,17 @@ pending_framepy_repr (PyObject *self) Returns the value of register REG as gdb.Value instance. */ static PyObject * -pending_framepy_read_register (PyObject *self, PyObject *args) +pending_framepy_read_register (PyObject *self, PyObject *args, PyObject *kw) { pending_frame_object *pending_frame = (pending_frame_object *) self; PENDING_FRAMEPY_REQUIRE_VALID (pending_frame); - int regnum; PyObject *pyo_reg_id; + static const char *keywords[] = { "register", nullptr }; + if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "O", keywords, &pyo_reg_id)) + return nullptr; - if (!PyArg_UnpackTuple (args, "read_register", 1, 1, &pyo_reg_id)) - return NULL; + int regnum; if (!gdbpy_parse_register_id (pending_frame->gdbarch, pyo_reg_id, ®num)) return nullptr; @@ -681,7 +682,8 @@ pending_framepy_function (PyObject *self, PyObject *args) PendingFrame.create_unwind_info (self, frameId) -> UnwindInfo. */ static PyObject * -pending_framepy_create_unwind_info (PyObject *self, PyObject *args) +pending_framepy_create_unwind_info (PyObject *self, PyObject *args, + PyObject *kw) { PyObject *pyo_frame_id; CORE_ADDR sp; @@ -690,7 +692,9 @@ pending_framepy_create_unwind_info (PyObject *self, PyObject *args) PENDING_FRAMEPY_REQUIRE_VALID ((pending_frame_object *) self); - if (!PyArg_ParseTuple (args, "O:create_unwind_info", &pyo_frame_id)) + static const char *keywords[] = { "frame_id", nullptr }; + if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "O", keywords, + &pyo_frame_id)) return nullptr; pyuw_get_attr_code code @@ -1002,11 +1006,12 @@ gdbpy_initialize_unwind (void) static PyMethodDef pending_frame_object_methods[] = { - { "read_register", pending_framepy_read_register, METH_VARARGS, + { "read_register", (PyCFunction) pending_framepy_read_register, + METH_VARARGS | METH_KEYWORDS, "read_register (REG) -> gdb.Value\n" "Return the value of the REG in the frame." }, - { "create_unwind_info", - pending_framepy_create_unwind_info, METH_VARARGS, + { "create_unwind_info", (PyCFunction) pending_framepy_create_unwind_info, + METH_VARARGS | METH_KEYWORDS, "create_unwind_info (FRAME_ID) -> gdb.UnwindInfo\n" "Construct UnwindInfo for this PendingFrame, using FRAME_ID\n" "to identify it." }, |