mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-05-25 11:16:56 +08:00
Add Inferior.architecture method
I've written a couple of gdb unwinders in Python, and while doing so, I wanted to find the architecture of the inferior. (In an unwinder in particular, one can't use the frame's architecture, because there is no frame.) This patch adds Inferior.architecture to allow this. Normally I think I would have chosen an attribute and not a method here, but seeing that Frame.architecture is a method, I chose a method as well, for consistency. gdb/ChangeLog 2018-10-06 Tom Tromey <tom@tromey.com> PR python/19399: * python/py-inferior.c: Add "architecture" entry. (infpy_architecture): New function. gdb/doc/ChangeLog 2018-10-06 Tom Tromey <tom@tromey.com> PR python/19399: * python.texi (Inferiors In Python): Document Inferior.Architecture. gdb/testsuite/ChangeLog 2018-10-06 Tom Tromey <tom@tromey.com> PR python/19399: * gdb.python/py-inferior.exp: Add architecture test.
This commit is contained in:
@ -855,6 +855,18 @@ infpy_thread_from_thread_handle (PyObject *self, PyObject *args, PyObject *kw)
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
/* Implementation of gdb.Inferior.architecture. */
|
||||
|
||||
static PyObject *
|
||||
infpy_architecture (PyObject *self, PyObject *args)
|
||||
{
|
||||
inferior_object *inf = (inferior_object *) self;
|
||||
|
||||
INFPY_REQUIRE_VALID (inf);
|
||||
|
||||
return gdbarch_to_arch_object (inf->inferior->gdbarch);
|
||||
}
|
||||
|
||||
/* Implement repr() for gdb.Inferior. */
|
||||
|
||||
static PyObject *
|
||||
@ -988,6 +1000,9 @@ Return a long with the address of a match, or None." },
|
||||
METH_VARARGS | METH_KEYWORDS,
|
||||
"thread_from_thread_handle (handle) -> gdb.InferiorThread.\n\
|
||||
Return thread object corresponding to thread handle." },
|
||||
{ "architecture", (PyCFunction) infpy_architecture, METH_NOARGS,
|
||||
"architecture () -> gdb.Architecture\n\
|
||||
Return architecture of this inferior." },
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user