aboutsummaryrefslogtreecommitdiff
path: root/gdb/python/py-frame.c
diff options
context:
space:
mode:
authorSiva Chandra Reddy <sivachandra@sourceware.org>2013-01-23 19:59:13 +0000
committerSiva Chandra Reddy <sivachandra@sourceware.org>2013-01-23 19:59:13 +0000
commitbea883fd928f283b41d10b02f2b92f28bfb634cf (patch)
tree5ce9b05bc33513798f72a321846ef1da66bb2586 /gdb/python/py-frame.c
parent796a7ff8234cfaa8ad1ab884c1c8dafe29b18d42 (diff)
downloadgdb-bea883fd928f283b41d10b02f2b92f28bfb634cf.zip
gdb-bea883fd928f283b41d10b02f2b92f28bfb634cf.tar.gz
gdb-bea883fd928f283b41d10b02f2b92f28bfb634cf.tar.bz2
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.
Diffstat (limited to 'gdb/python/py-frame.c')
-rw-r--r--gdb/python/py-frame.c22
1 files changed, 22 insertions, 0 deletions
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." },