Add support for reading frame registers to Python API.
The ability to read registers is needed to use Frame Filter API to display the frames created by JIT compilers. gdb/ChangeLog: 2014-08-29 Sasha Smundak <asmundak@google.com> * python/py-frame.c (frapy_read_register): New function. gdb/doc/ChangeLog: 2014-08-26 Sasha Smundak <asmundak@google.com> * python.texi (Frames in Python): Add read_register description. gdb/testsuite/ChangeLog: 2014-08-26 Sasha Smundak <asmundak@google.com> * gdb.python/py-frame.exp: Test Frame.read_register.
This commit is contained in:
parent
ac740bc7a9
commit
5f3b99cfed
7 changed files with 77 additions and 0 deletions
|
@ -28,6 +28,7 @@
|
|||
#include "python-internal.h"
|
||||
#include "symfile.h"
|
||||
#include "objfiles.h"
|
||||
#include "user-regs.h"
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
|
@ -235,6 +236,40 @@ frapy_pc (PyObject *self, PyObject *args)
|
|||
return gdb_py_long_from_ulongest (pc);
|
||||
}
|
||||
|
||||
/* Implementation of gdb.Frame.read_register (self, register) -> gdb.Value.
|
||||
Returns the value of a register in this frame. */
|
||||
|
||||
static PyObject *
|
||||
frapy_read_register (PyObject *self, PyObject *args)
|
||||
{
|
||||
volatile struct gdb_exception except;
|
||||
const char *regnum_str;
|
||||
struct value *val = NULL;
|
||||
|
||||
if (!PyArg_ParseTuple (args, "s", ®num_str))
|
||||
return NULL;
|
||||
|
||||
TRY_CATCH (except, RETURN_MASK_ALL)
|
||||
{
|
||||
struct frame_info *frame;
|
||||
int regnum;
|
||||
|
||||
FRAPY_REQUIRE_VALID (self, frame);
|
||||
|
||||
regnum = user_reg_map_name_to_regnum (get_frame_arch (frame),
|
||||
regnum_str,
|
||||
strlen (regnum_str));
|
||||
if (regnum >= 0)
|
||||
val = value_of_register (regnum, frame);
|
||||
|
||||
if (val == NULL)
|
||||
PyErr_SetString (PyExc_ValueError, _("Unknown register."));
|
||||
}
|
||||
GDB_PY_HANDLE_EXCEPTION (except);
|
||||
|
||||
return val == NULL ? NULL : value_to_value_object (val);
|
||||
}
|
||||
|
||||
/* Implementation of gdb.Frame.block (self) -> gdb.Block.
|
||||
Returns the frame's code block. */
|
||||
|
||||
|
@ -674,6 +709,9 @@ Return the reason why it's not possible to find frames older than this." },
|
|||
{ "pc", frapy_pc, METH_NOARGS,
|
||||
"pc () -> Long.\n\
|
||||
Return the frame's resume address." },
|
||||
{ "read_register", frapy_read_register, METH_VARARGS,
|
||||
"read_register (register_name) -> gdb.Value\n\
|
||||
Return the value of the register in the frame." },
|
||||
{ "block", frapy_block, METH_NOARGS,
|
||||
"block () -> gdb.Block.\n\
|
||||
Return the frame's code block." },
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue