gdb: change value_of_register and value_of_register_lazy to take the next frame

Some functions related to the handling of registers in frames accept
"this frame", for which we want to read or write the register values,
while other functions accept "the next frame", which is the frame next
to that.  The later is needed because we sometimes need to read register
values for a frame that does not exist yet (usually when trying to
unwind that frame-to-be).

value_of_register and value_of_register_lazy both take "this frame",
even if what they ultimately want internally is "the next frame".  This
is annoying if you are in a spot that currently has "the next frame" and
need to call one of these functions (which happens later in this
series).  You need to get the previous frame only for those functions to
get the next frame again.  This is more manipulations, more chances of
mistake.

I propose to change these functions (and a few more functions in the
subsequent patches) to operate on "the next frame".  Things become a bit
less awkward when all these functions agree on which frame they take.

So, in this patch, change value_of_register_lazy and value_of_register
to take "the next frame" instead of "this frame".  This adds a lot of
get_next_frame_sentinel_okay, but if we convert the user registers API
to also use "the next frame" instead of "this frame", it will get simple
again.

Change-Id: Iaa24815e648fbe5ae3c214c738758890a91819cd
Reviewed-By: John Baldwin <jhb@FreeBSD.org>
This commit is contained in:
Simon Marchi
2023-12-01 11:27:21 -05:00
parent f6e3d5577d
commit a7952927db
17 changed files with 53 additions and 49 deletions

View File

@@ -467,8 +467,8 @@ pending_framepy_read_register (PyObject *self, PyObject *args, PyObject *kw)
which maps to a real register. In the past,
get_frame_register_value() was used here, which did not
handle the user register case. */
struct value *val = value_of_register (regnum,
pending_frame->frame_info);
value *val = value_of_register
(regnum, get_next_frame_sentinel_okay (pending_frame->frame_info));
if (val == NULL)
PyErr_Format (PyExc_ValueError,
"Cannot read register %d from frame.",