From bea883fd928f283b41d10b02f2b92f28bfb634cf Mon Sep 17 00:00:00 2001 From: Siva Chandra Reddy Date: Wed, 23 Jan 2013 19:59:13 +0000 Subject: Add a new class gdb.Architecture which exposes GDB's internal representation of architecture via GDB Python API. * Makefile.in: Add entries corresponding to the new file python/py-arch.c. * NEWS (Python Scripting): Add entries for the new class gdb.Architecture and the new method gdb.Frame.architecture. * python/py-arch.c: Implement gdb.Architecture class. * python/py-frame.c (frapy_arch): Implement the method gdb.Frame.architecture(). (frame_object_methods): Add 'architecture' to the method table. * python/python-internal.h: Add declarations of new utility functions. * python/python.c (_initialize_python): Initialize gdb.Architecture class. * doc/gdb.texinfo (Architectures In Python): New sub-sub-section describing the gdb.Architecture class. (Frames In Python): Add description about the new method gdb.Frame.architecture(). * testsuite/gdb.python/frame.exp: Add a test for gdb.Frame.architecture() method. --- gdb/python/py-frame.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'gdb/python/py-frame.c') diff --git a/gdb/python/py-frame.c b/gdb/python/py-frame.c index 4b025db..e2eb9c5 100644 --- a/gdb/python/py-frame.c +++ b/gdb/python/py-frame.c @@ -167,6 +167,25 @@ frapy_type (PyObject *self, PyObject *args) return PyInt_FromLong (type); } +/* Implementation of gdb.Frame.architecture (self) -> gdb.Architecture. + Returns the frame's architecture as a gdb.Architecture object. */ + +static PyObject * +frapy_arch (PyObject *self, PyObject *args) +{ + struct frame_info *frame = NULL; /* Initialize to appease gcc warning. */ + frame_object *obj = (frame_object *) self; + volatile struct gdb_exception except; + + TRY_CATCH (except, RETURN_MASK_ALL) + { + FRAPY_REQUIRE_VALID (self, frame); + } + GDB_PY_HANDLE_EXCEPTION (except); + + return gdbarch_to_arch_object (obj->gdbarch); +} + /* Implementation of gdb.Frame.unwind_stop_reason (self) -> Integer. Returns one of the gdb.FRAME_UNWIND_* constants. */ @@ -632,6 +651,9 @@ Return the function name of the frame, or None if it can't be determined." }, { "type", frapy_type, METH_NOARGS, "type () -> Integer.\n\ Return the type of the frame." }, + { "architecture", frapy_arch, METH_NOARGS, + "architecture () -> gdb.Architecture.\n\ +Return the architecture of the frame." }, { "unwind_stop_reason", frapy_unwind_stop_reason, METH_NOARGS, "unwind_stop_reason () -> Integer.\n\ Return the reason why it's not possible to find frames older than this." }, -- cgit v1.1