Skip to content

Commit

Permalink
Make gdb.PendingFrame.read_register handle "user" registers.
Browse files Browse the repository at this point in the history
The C function, pending_framepy_read_register(), which implements
the python interface gdb.PendingFrame.read_register does not handle
the so called "user" registers like "pc".  An assertion error is
triggered due to the user registers having numbers larger than or
equal to gdbarch_num_regs(gdbarch).

With the VALUE_FRAME_ID tweak in place, the call to
get_frame_register_value() can simply be replaced by a call to
value_of_register(), which handles both real registers as well as the
user registers.

gdb/ChangeLog:

	* python/py-unwind.c (pending_framepy_read_register): Use
	value_of_register() instead of get_frame_register_value().
  • Loading branch information
KevinBuettner committed Nov 16, 2016
1 parent 41b56fe commit 33cc7d3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
5 changes: 5 additions & 0 deletions gdb/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2016-11-16 Kevin Buettner <[email protected]>

* python/py-unwind.c (pending_framepy_read_register): Use
value_of_register() instead of get_frame_register_value().

2016-11-16 Kevin Buettner <[email protected]>

* value.h (VALUE_FRAME_ID): Rename to VALUE_NEXT_FRAME_ID. Update
Expand Down
7 changes: 6 additions & 1 deletion gdb/python/py-unwind.c
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,12 @@ pending_framepy_read_register (PyObject *self, PyObject *args)

TRY
{
val = get_frame_register_value (pending_frame->frame_info, regnum);
/* Fetch the value associated with a register, whether it's
a real register or a so called "user" register, like "pc",
which maps to a real register. In the past,
get_frame_register_value() was used here, which did not
handle the user register case. */
val = value_of_register (regnum, pending_frame->frame_info);
if (val == NULL)
PyErr_Format (PyExc_ValueError,
"Cannot read register %d from frame.",
Expand Down

0 comments on commit 33cc7d3

Please sign in to comment.