From 33cc7d368f420326606695daafd6292e2779c6af Mon Sep 17 00:00:00 2001 From: Kevin Buettner Date: Tue, 27 Sep 2016 22:45:19 -0700 Subject: [PATCH] Make gdb.PendingFrame.read_register handle "user" registers. 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(). --- gdb/ChangeLog | 5 +++++ gdb/python/py-unwind.c | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index caad792..5b53dad 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,10 @@ 2016-11-16 Kevin Buettner + * python/py-unwind.c (pending_framepy_read_register): Use + value_of_register() instead of get_frame_register_value(). + +2016-11-16 Kevin Buettner + * value.h (VALUE_FRAME_ID): Rename to VALUE_NEXT_FRAME_ID. Update comment. Create new VALUE_FRAME_ID which is defined in terms of VALUE_NEXT_FRAME_ID. diff --git a/gdb/python/py-unwind.c b/gdb/python/py-unwind.c index 52184bd..65c705f 100644 --- a/gdb/python/py-unwind.c +++ b/gdb/python/py-unwind.c @@ -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.", -- 2.7.4