summaryrefslogtreecommitdiff
path: root/gdb/python
diff options
context:
space:
mode:
authorSiva Chandra Reddy <sivachandra@sourceware.org>2012-05-03 07:07:26 +0000
committerSiva Chandra Reddy <sivachandra@sourceware.org>2012-05-03 07:07:26 +0000
commita20ee7a4a9d43404d9c566453ba6c9578adc3596 (patch)
treead28669e5464e65e747e23099c0c793830d9b9ab /gdb/python
parentbf2f0858b16a808a504f519e22b8f14aaa76cc10 (diff)
downloadbinutils-gdb-a20ee7a4a9d43404d9c566453ba6c9578adc3596.tar.gz
2012-05-03 Siva Chandra Reddy <sivachandra@google.com>
Add two new methods global_block and static_block to gdb.Symtab objects. * NEWS (Python scripting): Add entry about the new methods. * python/py-symtab.c (stpy_global_block): New function which implements the gdb.Symtab.global_block() method. (stpy_static_block): New function which implements the gdb.Symtab.static_block() method. (symtab_object_methods): Add entries for the two new methods. * testsuite/gdb.python/py-symbol.exp: Add tests to test the new methods gdb.Symtab.global_block() and gdb.Symtab.static_block(). * tessuite/gdb.python/py-symbol.c: Add new struct to help test gdb.Symtab.static_block(). * doc/gdb.texinfo (Symbol Tables In Python): Add documentation about the new methods global_block and static_block on gdb.Symtab objects.
Diffstat (limited to 'gdb/python')
-rw-r--r--gdb/python/py-symtab.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/gdb/python/py-symtab.c b/gdb/python/py-symtab.c
index 09b760fc4df..e9e38b2f3c7 100644
--- a/gdb/python/py-symtab.c
+++ b/gdb/python/py-symtab.c
@@ -23,6 +23,7 @@
#include "source.h"
#include "python-internal.h"
#include "objfiles.h"
+#include "block.h"
typedef struct stpy_symtab_object {
PyObject_HEAD
@@ -153,6 +154,38 @@ stpy_is_valid (PyObject *self, PyObject *args)
Py_RETURN_TRUE;
}
+/* Return the GLOBAL_BLOCK of the underlying symtab. */
+
+static PyObject *
+stpy_global_block (PyObject *self, PyObject *args)
+{
+ struct symtab *symtab = NULL;
+ struct block *block = NULL;
+ struct blockvector *blockvector;
+
+ STPY_REQUIRE_VALID (self, symtab);
+
+ blockvector = BLOCKVECTOR (symtab);
+ block = BLOCKVECTOR_BLOCK (blockvector, GLOBAL_BLOCK);
+ return block_to_block_object (block, symtab->objfile);
+}
+
+/* Return the STATIC_BLOCK of the underlying symtab. */
+
+static PyObject *
+stpy_static_block (PyObject *self, PyObject *args)
+{
+ struct symtab *symtab = NULL;
+ struct block *block = NULL;
+ struct blockvector *blockvector;
+
+ STPY_REQUIRE_VALID (self, symtab);
+
+ blockvector = BLOCKVECTOR (symtab);
+ block = BLOCKVECTOR_BLOCK (blockvector, STATIC_BLOCK);
+ return block_to_block_object (block, symtab->objfile);
+}
+
static PyObject *
salpy_str (PyObject *self)
{
@@ -477,6 +510,12 @@ Return true if this symbol table is valid, false if not." },
{ "fullname", stpy_fullname, METH_NOARGS,
"fullname () -> String.\n\
Return the symtab's full source filename." },
+ { "global_block", stpy_global_block, METH_NOARGS,
+ "global_block () -> gdb.Block.\n\
+Return the global block of the symbol table." },
+ { "static_block", stpy_static_block, METH_NOARGS,
+ "static_block () -> gdb.Block.\n\
+Return the static block of the symbol table." },
{NULL} /* Sentinel */
};