Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(160)

Unified Diff: gdb/python/py-block.c

Issue 124383005: GDB 7.6.50 (Closed) Base URL: http://git.chromium.org/native_client/nacl-gdb.git@upstream
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gdb/python/py-auto-load.c ('k') | gdb/python/py-bpevent.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gdb/python/py-block.c
diff --git a/gdb/python/py-block.c b/gdb/python/py-block.c
index 68d0a1595cb87a419f14ae88aa2a357b3e1c7819..c74ac2cf925e995f60d32964771c504b7b7c0adf 100644
--- a/gdb/python/py-block.c
+++ b/gdb/python/py-block.c
@@ -1,6 +1,6 @@
/* Python interface to blocks.
- Copyright (C) 2008-2012 Free Software Foundation, Inc.
+ Copyright (C) 2008-2013 Free Software Foundation, Inc.
This file is part of GDB.
@@ -78,7 +78,8 @@ typedef struct {
} \
} while (0)
-static PyTypeObject block_syms_iterator_object_type;
+static PyTypeObject block_syms_iterator_object_type
+ CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("block_syms_iterator_object");
static const struct objfile_data *blpy_objfile_data_key;
static PyObject *
@@ -370,7 +371,7 @@ PyObject *
gdbpy_block_for_pc (PyObject *self, PyObject *args)
{
gdb_py_ulongest pc;
- struct block *block;
+ struct block *block = NULL;
struct obj_section *section = NULL;
struct symtab *symtab = NULL;
volatile struct gdb_exception except;
@@ -382,6 +383,9 @@ gdbpy_block_for_pc (PyObject *self, PyObject *args)
{
section = find_pc_mapped_section (pc);
symtab = find_pc_sect_symtab (pc, section);
+
+ if (symtab != NULL && symtab->objfile != NULL)
+ block = block_for_pc (pc);
}
GDB_PY_HANDLE_EXCEPTION (except);
@@ -392,7 +396,6 @@ gdbpy_block_for_pc (PyObject *self, PyObject *args)
return NULL;
}
- block = block_for_pc (pc);
if (block)
return block_to_block_object (block, symtab->objfile);
@@ -422,16 +425,16 @@ del_objfile_blocks (struct objfile *objfile, void *datum)
}
}
-void
+int
gdbpy_initialize_blocks (void)
{
block_object_type.tp_new = PyType_GenericNew;
if (PyType_Ready (&block_object_type) < 0)
- return;
+ return -1;
block_syms_iterator_object_type.tp_new = PyType_GenericNew;
if (PyType_Ready (&block_syms_iterator_object_type) < 0)
- return;
+ return -1;
/* Register an objfile "free" callback so we can properly
invalidate blocks when an object file is about to be
@@ -439,12 +442,12 @@ gdbpy_initialize_blocks (void)
blpy_objfile_data_key
= register_objfile_data_with_cleanup (NULL, del_objfile_blocks);
- Py_INCREF (&block_object_type);
- PyModule_AddObject (gdb_module, "Block", (PyObject *) &block_object_type);
+ if (gdb_pymodule_addobject (gdb_module, "Block",
+ (PyObject *) &block_object_type) < 0)
+ return -1;
- Py_INCREF (&block_syms_iterator_object_type);
- PyModule_AddObject (gdb_module, "BlockIterator",
- (PyObject *) &block_syms_iterator_object_type);
+ return gdb_pymodule_addobject (gdb_module, "BlockIterator",
+ (PyObject *) &block_syms_iterator_object_type);
}
@@ -475,8 +478,7 @@ static PyGetSetDef block_object_getset[] = {
};
PyTypeObject block_object_type = {
- PyObject_HEAD_INIT (NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT (NULL, 0)
"gdb.Block", /*tp_name*/
sizeof (block_object), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -516,8 +518,7 @@ Return true if this block iterator is valid, false if not." },
};
static PyTypeObject block_syms_iterator_object_type = {
- PyObject_HEAD_INIT (NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT (NULL, 0)
"gdb.BlockIterator", /*tp_name*/
sizeof (block_syms_iterator_object), /*tp_basicsize*/
0, /*tp_itemsize*/
« no previous file with comments | « gdb/python/py-auto-load.c ('k') | gdb/python/py-bpevent.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698