/* Python interface to blocks.
- Copyright (C) 2008-2013 Free Software Foundation, Inc.
+ Copyright (C) 2008-2016 Free Software Foundation, Inc.
This file is part of GDB.
} \
} while (0)
-static PyTypeObject block_syms_iterator_object_type
+extern PyTypeObject block_syms_iterator_object_type
CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("block_syms_iterator_object");
static const struct objfile_data *blpy_objfile_data_key;
if (objfile)
{
obj->objfile = objfile;
- obj->next = objfile_data (objfile, blpy_objfile_data_key);
+ obj->next = ((struct blpy_block_object *)
+ objfile_data (objfile, blpy_objfile_data_key));
if (obj->next)
obj->next->prev = obj;
set_objfile_data (objfile, blpy_objfile_data_key, obj);
gdbpy_block_for_pc (PyObject *self, PyObject *args)
{
gdb_py_ulongest pc;
- struct block *block = NULL;
- struct obj_section *section = NULL;
- struct symtab *symtab = NULL;
- volatile struct gdb_exception except;
+ const struct block *block = NULL;
+ struct compunit_symtab *cust = NULL;
if (!PyArg_ParseTuple (args, GDB_PY_LLU_ARG, &pc))
return NULL;
- TRY_CATCH (except, RETURN_MASK_ALL)
+ TRY
{
- section = find_pc_mapped_section (pc);
- symtab = find_pc_sect_symtab (pc, section);
+ cust = find_pc_compunit_symtab (pc);
- if (symtab != NULL && symtab->objfile != NULL)
+ if (cust != NULL && COMPUNIT_OBJFILE (cust) != NULL)
block = block_for_pc (pc);
}
- GDB_PY_HANDLE_EXCEPTION (except);
+ CATCH (except, RETURN_MASK_ALL)
+ {
+ GDB_PY_HANDLE_EXCEPTION (except);
+ }
+ END_CATCH
- if (!symtab || symtab->objfile == NULL)
+ if (cust == NULL || COMPUNIT_OBJFILE (cust) == NULL)
{
PyErr_SetString (PyExc_RuntimeError,
_("Cannot locate object file for block."));
}
if (block)
- return block_to_block_object (block, symtab->objfile);
+ return block_to_block_object (block, COMPUNIT_OBJFILE (cust));
Py_RETURN_NONE;
}
static void
del_objfile_blocks (struct objfile *objfile, void *datum)
{
- block_object *obj = datum;
+ block_object *obj = (block_object *) datum;
while (obj)
{
blpy_objfile_data_key
= register_objfile_data_with_cleanup (NULL, del_objfile_blocks);
- Py_INCREF (&block_object_type);
- if (PyModule_AddObject (gdb_module, "Block",
- (PyObject *) &block_object_type) < 0)
+ if (gdb_pymodule_addobject (gdb_module, "Block",
+ (PyObject *) &block_object_type) < 0)
return -1;
- Py_INCREF (&block_syms_iterator_object_type);
- return PyModule_AddObject (gdb_module, "BlockIterator",
- (PyObject *) &block_syms_iterator_object_type);
+ return gdb_pymodule_addobject (gdb_module, "BlockIterator",
+ (PyObject *) &block_syms_iterator_object_type);
}
\f
{NULL} /* Sentinel */
};
-static PyTypeObject block_syms_iterator_object_type = {
+PyTypeObject block_syms_iterator_object_type = {
PyVarObject_HEAD_INIT (NULL, 0)
"gdb.BlockIterator", /*tp_name*/
sizeof (block_syms_iterator_object), /*tp_basicsize*/