2011-10-20 Phil Muldoon <pmuldoon@redhat.com>
PR python/12656 * python/py-frame.c (frapy_read_var): Use const struct *block. * python/py-type.c (typy_lookup_typename): Likewise. (typy_lookup_type): Likewise. (typy_legacy_template_argument): Likewise. (typy_template_argument): Likewise. (gdbpy_lookup_type): Likewise. * python/py-symbol.c (gdbpy_lookup_symbol): Likewise. * python/py-block.c (blpy_block_object): Likewise. (blpy_iter): Likewise. (blpy_get_start): Likewise. (blpy_get_end): Likewise. (blpy_get_function): Likewise. (blpy_get_superblock): Likewise. (set_block): Likewise. (block_to_block_object): Likewise. (block_object_to_block): Likewise. (blpy_is_valid): Likewise. (blpy_get_global_block): New function. (blpy_get_static_block): New function. (blpy_is_global): New function. (blpy_is_static): New function. * blockframe.c (block_innermost_frame): Likewise. * valops.c (value_of_variable): Likewise. * frame.h: Update prototypes. * python/python-internal.h: Likewise. * value.h: Likewise. 2011-10-20 Phil Muldoon <pmuldoon@redhat.com> PR python/12656 * gdb.texinfo (Blocks In Python): Document is_static, is_global, global_block, static_block function. 2011-10-20 Phil Muldoon <pmuldoon@redhat.com> PR python/12656 * gdb.python/py-block.exp: Add is_global, is_static, static_block, global_block tests.
This commit is contained in:
parent
5468810dda
commit
9df2fbc4c1
15 changed files with 186 additions and 24 deletions
|
@ -28,7 +28,7 @@
|
|||
typedef struct blpy_block_object {
|
||||
PyObject_HEAD
|
||||
/* The GDB block structure that represents a frame's code block. */
|
||||
struct block *block;
|
||||
const struct block *block;
|
||||
/* The backing object file. There is no direct relationship in GDB
|
||||
between a block and an object file. When a block is created also
|
||||
store a pointer to the object file for later use. */
|
||||
|
@ -85,7 +85,7 @@ static PyObject *
|
|||
blpy_iter (PyObject *self)
|
||||
{
|
||||
block_syms_iterator_object *block_iter_obj;
|
||||
struct block *block = NULL;
|
||||
const struct block *block = NULL;
|
||||
|
||||
BLPY_REQUIRE_VALID (self, block);
|
||||
|
||||
|
@ -105,7 +105,7 @@ blpy_iter (PyObject *self)
|
|||
static PyObject *
|
||||
blpy_get_start (PyObject *self, void *closure)
|
||||
{
|
||||
struct block *block = NULL;
|
||||
const struct block *block = NULL;
|
||||
|
||||
BLPY_REQUIRE_VALID (self, block);
|
||||
|
||||
|
@ -115,7 +115,7 @@ blpy_get_start (PyObject *self, void *closure)
|
|||
static PyObject *
|
||||
blpy_get_end (PyObject *self, void *closure)
|
||||
{
|
||||
struct block *block = NULL;
|
||||
const struct block *block = NULL;
|
||||
|
||||
BLPY_REQUIRE_VALID (self, block);
|
||||
|
||||
|
@ -126,7 +126,7 @@ static PyObject *
|
|||
blpy_get_function (PyObject *self, void *closure)
|
||||
{
|
||||
struct symbol *sym;
|
||||
struct block *block = NULL;
|
||||
const struct block *block;
|
||||
|
||||
BLPY_REQUIRE_VALID (self, block);
|
||||
|
||||
|
@ -140,8 +140,8 @@ blpy_get_function (PyObject *self, void *closure)
|
|||
static PyObject *
|
||||
blpy_get_superblock (PyObject *self, void *closure)
|
||||
{
|
||||
struct block *block = NULL;
|
||||
struct block *super_block = NULL;
|
||||
const struct block *block;
|
||||
const struct block *super_block;
|
||||
block_object *self_obj = (block_object *) self;
|
||||
|
||||
BLPY_REQUIRE_VALID (self, block);
|
||||
|
@ -153,6 +153,77 @@ blpy_get_superblock (PyObject *self, void *closure)
|
|||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
/* Return the global block associated to this block. */
|
||||
|
||||
static PyObject *
|
||||
blpy_get_global_block (PyObject *self, void *closure)
|
||||
{
|
||||
const struct block *block;
|
||||
const struct block *global_block;
|
||||
block_object *self_obj = (block_object *) self;
|
||||
|
||||
BLPY_REQUIRE_VALID (self, block);
|
||||
|
||||
global_block = block_global_block (block);
|
||||
|
||||
return block_to_block_object (global_block,
|
||||
self_obj->objfile);
|
||||
|
||||
}
|
||||
|
||||
/* Return the static block associated to this block. Return None
|
||||
if we cannot get the static block (this is the global block). */
|
||||
|
||||
static PyObject *
|
||||
blpy_get_static_block (PyObject *self, void *closure)
|
||||
{
|
||||
const struct block *block;
|
||||
const struct block *static_block;
|
||||
block_object *self_obj = (block_object *) self;
|
||||
|
||||
BLPY_REQUIRE_VALID (self, block);
|
||||
|
||||
if (BLOCK_SUPERBLOCK (block) == NULL)
|
||||
Py_RETURN_NONE;
|
||||
|
||||
static_block = block_static_block (block);
|
||||
|
||||
return block_to_block_object (static_block, self_obj->objfile);
|
||||
}
|
||||
|
||||
/* Implementation of gdb.Block.is_global (self) -> Boolean.
|
||||
Returns True if this block object is a global block. */
|
||||
|
||||
static PyObject *
|
||||
blpy_is_global (PyObject *self, void *closure)
|
||||
{
|
||||
const struct block *block;
|
||||
|
||||
BLPY_REQUIRE_VALID (self, block);
|
||||
|
||||
if (BLOCK_SUPERBLOCK (block))
|
||||
Py_RETURN_FALSE;
|
||||
|
||||
Py_RETURN_TRUE;
|
||||
}
|
||||
|
||||
/* Implementation of gdb.Block.is_static (self) -> Boolean.
|
||||
Returns True if this block object is a static block. */
|
||||
|
||||
static PyObject *
|
||||
blpy_is_static (PyObject *self, void *closure)
|
||||
{
|
||||
const struct block *block;
|
||||
|
||||
BLPY_REQUIRE_VALID (self, block);
|
||||
|
||||
if (BLOCK_SUPERBLOCK (block) != NULL
|
||||
&& BLOCK_SUPERBLOCK (BLOCK_SUPERBLOCK (block)) == NULL)
|
||||
Py_RETURN_TRUE;
|
||||
|
||||
Py_RETURN_FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
blpy_dealloc (PyObject *obj)
|
||||
{
|
||||
|
@ -176,7 +247,7 @@ blpy_dealloc (PyObject *obj)
|
|||
with the life-cycle of the object file associated with this
|
||||
block, if needed. */
|
||||
static void
|
||||
set_block (block_object *obj, struct block *block,
|
||||
set_block (block_object *obj, const struct block *block,
|
||||
struct objfile *objfile)
|
||||
{
|
||||
obj->block = block;
|
||||
|
@ -196,7 +267,7 @@ set_block (block_object *obj, struct block *block,
|
|||
/* Create a new block object (gdb.Block) that encapsulates the struct
|
||||
block object from GDB. */
|
||||
PyObject *
|
||||
block_to_block_object (struct block *block, struct objfile *objfile)
|
||||
block_to_block_object (const struct block *block, struct objfile *objfile)
|
||||
{
|
||||
block_object *block_obj;
|
||||
|
||||
|
@ -208,7 +279,7 @@ block_to_block_object (struct block *block, struct objfile *objfile)
|
|||
}
|
||||
|
||||
/* Return struct block reference that is wrapped by this object. */
|
||||
struct block *
|
||||
const struct block *
|
||||
block_object_to_block (PyObject *obj)
|
||||
{
|
||||
if (! PyObject_TypeCheck (obj, &block_object_type))
|
||||
|
@ -269,7 +340,7 @@ blpy_block_syms_dealloc (PyObject *obj)
|
|||
static PyObject *
|
||||
blpy_is_valid (PyObject *self, PyObject *args)
|
||||
{
|
||||
struct block *block;
|
||||
const struct block *block;
|
||||
|
||||
block = block_object_to_block (self);
|
||||
if (block == NULL)
|
||||
|
@ -386,6 +457,14 @@ static PyGetSetDef block_object_getset[] = {
|
|||
"Symbol that names the block, or None.", NULL },
|
||||
{ "superblock", blpy_get_superblock, NULL,
|
||||
"Block containing the block, or None.", NULL },
|
||||
{ "global_block", blpy_get_global_block, NULL,
|
||||
"Block containing the global block.", NULL },
|
||||
{ "static_block", blpy_get_static_block, NULL,
|
||||
"Block containing the static block.", NULL },
|
||||
{ "is_static", blpy_is_static, NULL,
|
||||
"Whether this block is a static block.", NULL },
|
||||
{ "is_global", blpy_is_global, NULL,
|
||||
"Whether this block is a global block.", NULL },
|
||||
{ NULL } /* Sentinel */
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue