diff options
author | Phil Muldoon <pmuldoon@redhat.com> | 2011-03-17 09:36:17 +0000 |
---|---|---|
committer | Phil Muldoon <pmuldoon@redhat.com> | 2011-03-17 09:36:17 +0000 |
commit | 29703da4b1a5b80034c3f33b0c8f34ce6e1f08d5 (patch) | |
tree | c0999d1a168f21196c3c8ba5b1401f05b00236d3 /gdb/python/py-block.c | |
parent | a6363bfc3832f13436cb744783aa96eaec972006 (diff) | |
download | gdb-29703da4b1a5b80034c3f33b0c8f34ce6e1f08d5.zip gdb-29703da4b1a5b80034c3f33b0c8f34ce6e1f08d5.tar.gz gdb-29703da4b1a5b80034c3f33b0c8f34ce6e1f08d5.tar.bz2 |
2011-03-17 Phil Muldoon <pmuldoon@redhat.com>
* python/py-symtab.c: Populate symtab_object_methods,
sal_object_methods.
(stpy_is_valid): New function.
(salpy_is_valid): Ditto.
* python/py-symbol.c: Declare symbol_object_methods.
Populate.
(sympy_is_valid): New function.
* python/py-objfile.c: Declare objfile_object_methods.
Populate.
(objfpy_is_valid): New function.
* python/py-inferior.c: Populate inferior_object_methods.
(infpy_is_valid): New function.
* python/py-infthread.c: Populate thread_object_methods.
(thpy_is_valid): New function.
* python/py-block.c: Declare block_object_methods.
Populate. Declare
block_iterator_object_methods. Populate.
(blpy_is_valid): New function.
(blpy_iter_is_valid): Ditto.
2010-03-17 Phil Muldoon <pmuldoon@redhat.com>
* gdb.python/Makefile.in: Add py-objfile.
* gdb.python/py-objfile.exp: New file.
* gdb.python/py-objfile.c: New file.
* gdb.python/py-block.exp: Add is_valid tests.
* gdb.python/py-inferior.exp: Ditto.
* gdb.python/py-infthread.exp: Ditto.
* gdb.python/py-symbol.exp: Ditto.
* gdb.python/py-symtab.exp: Ditto.
2011-03-17 Phil Muldoon <pmuldoon@redhat.com>
* gdb.texinfo (Blocks In Python): Add is_valid method
description.
(Inferiors In Python): Likewise.
(Threads In Python): Likewise.
(Symbols In Python): Likewise.
(Objfiles In Python): Likewise.
(Symbol Tables In Python): Likewise.
Diffstat (limited to 'gdb/python/py-block.c')
-rw-r--r-- | gdb/python/py-block.c | 48 |
1 files changed, 46 insertions, 2 deletions
diff --git a/gdb/python/py-block.c b/gdb/python/py-block.c index 9d0d6cc..08d4455 100644 --- a/gdb/python/py-block.c +++ b/gdb/python/py-block.c @@ -263,6 +263,36 @@ blpy_block_syms_dealloc (PyObject *obj) Py_XDECREF (iter_obj->source); } +/* Implementation of gdb.Block.is_valid (self) -> Boolean. + Returns True if this block object still exists in GDB. */ + +static PyObject * +blpy_is_valid (PyObject *self, PyObject *args) +{ + struct block *block; + + block = block_object_to_block (self); + if (block == NULL) + Py_RETURN_FALSE; + + Py_RETURN_TRUE; +} + +/* Implementation of gdb.BlockIterator.is_valid (self) -> Boolean. + Returns True if this block iterator object still exists in GDB */ + +static PyObject * +blpy_iter_is_valid (PyObject *self, PyObject *args) +{ + block_syms_iterator_object *iter_obj = + (block_syms_iterator_object *) self; + + if (iter_obj->source->block == NULL) + Py_RETURN_FALSE; + + Py_RETURN_TRUE; +} + /* Return the innermost lexical block containing the specified pc value, or 0 if there is none. */ PyObject * @@ -342,6 +372,13 @@ gdbpy_initialize_blocks (void) +static PyMethodDef block_object_methods[] = { + { "is_valid", blpy_is_valid, METH_NOARGS, + "is_valid () -> Boolean.\n\ +Return true if this block is valid, false if not." }, + {NULL} /* Sentinel */ +}; + static PyGetSetDef block_object_getset[] = { { "start", blpy_get_start, NULL, "Start address of the block.", NULL }, { "end", blpy_get_end, NULL, "End address of the block.", NULL }, @@ -381,11 +418,18 @@ PyTypeObject block_object_type = { 0, /* tp_weaklistoffset */ blpy_iter, /* tp_iter */ 0, /* tp_iternext */ - 0, /* tp_methods */ + block_object_methods, /* tp_methods */ 0, /* tp_members */ block_object_getset /* tp_getset */ }; +static PyMethodDef block_iterator_object_methods[] = { + { "is_valid", blpy_iter_is_valid, METH_NOARGS, + "is_valid () -> Boolean.\n\ +Return true if this block iterator is valid, false if not." }, + {NULL} /* Sentinel */ +}; + static PyTypeObject block_syms_iterator_object_type = { PyObject_HEAD_INIT (NULL) 0, /*ob_size*/ @@ -415,5 +459,5 @@ static PyTypeObject block_syms_iterator_object_type = { 0, /*tp_weaklistoffset */ blpy_block_syms_iter, /*tp_iter */ blpy_block_syms_iternext, /*tp_iternext */ - 0 /*tp_methods */ + block_iterator_object_methods /*tp_methods */ }; |