Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions gdb/python/py-block.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,7 @@ PyObject* DictIter_iternext(PyObject *self)
}

static PyTypeObject DictIterType = {
PyObject_HEAD_INIT(NULL)
0, /*ob_size*/
PyVarObject_HEAD_INIT (NULL, 0)
"gdb._DictIter", /*tp_name*/
sizeof(DictIter), /*tp_basicsize*/
0, /*tp_itemsize*/
Expand All @@ -174,8 +173,7 @@ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_ITER,
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
DictIter_iter, /* tp_iter: __iter__() method */
DictIter_iternext /* tp_iternext: next() method */,
.tp_new = PyType_GenericNew
DictIter_iternext /* tp_iternext: next() method */
};

static PyObject *
Expand Down Expand Up @@ -538,6 +536,7 @@ gdbpy_initialize_blocks (void)
if (PyType_Ready (&block_syms_iterator_object_type) < 0)
return -1;

DictIterType.tp_new = PyType_GenericNew;
if (PyType_Ready(&DictIterType) < 0) return -1;
/* Register an objfile "free" callback so we can properly
invalidate blocks when an object file is about to be
Expand Down
34 changes: 29 additions & 5 deletions gdb/python/py-minsymbol.c
Original file line number Diff line number Diff line change
Expand Up @@ -319,23 +319,43 @@ gdbpy_lookup_minimal_symbol (PyObject *self, PyObject *args, PyObject *kw)
static char *keywords[] = { "name", "sfile", "objfile", NULL };
struct bound_minimal_symbol bound_minsym = {};
PyObject *msym_obj = NULL, *sfile_obj = NULL, *objfile_obj = NULL;
#if PY_MAJOR_VERSION >= 3
PyObject *temp = NULL;
#endif

if (!PyArg_ParseTupleAndKeywords (args, kw, "s|OO", keywords, &name,
&sfile_obj, &objfile_obj))
return NULL;

if (sfile_obj && sfile_obj != Py_None)
{
sfile = PyString_AsString (sfile_obj);
if (!sfile)
return NULL;
#if PY_MAJOR_VERSION >= 3
temp = PyUnicode_AsASCIIString(sfile_obj);
if (!temp)
return NULL;

sfile = PyBytes_AsString(temp);
#else
sfile = PyString_AsString(sfile_obj);
#endif

if (!sfile) {
#if PY_MAJOR_VERSION >= 3
Py_DECREF(temp);
#endif
return NULL;
}
}

if (objfile_obj && objfile_obj != Py_None)
{
objfile = objfpy_object_to_objfile (objfile_obj);
if (!objfile)
return NULL;
if (!objfile) {
#if PY_MAJOR_VERSION >= 3
Py_DECREF(temp);
#endif
return NULL;
}
}

TRY
Expand All @@ -348,6 +368,10 @@ gdbpy_lookup_minimal_symbol (PyObject *self, PyObject *args, PyObject *kw)
}
END_CATCH

#if PY_MAJOR_VERSION >= 3
Py_XDECREF(temp);
#endif

if (bound_minsym.minsym)
msym_obj = bound_minsym_to_minsym_object (&bound_minsym);

Expand Down
2 changes: 2 additions & 0 deletions gdb/python/py-register.c
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ register_set_value(PyObject *self, PyObject *value_obj, void *closure)
ret = write_register (regcache, obj->regnum, &ul_value);
}
}
#if PY_MAJOR_VERSION < 3
else if (PyInt_Check (value_obj))
{
ul_value = PyInt_AsUnsignedLongMask (value_obj);
Expand All @@ -216,6 +217,7 @@ register_set_value(PyObject *self, PyObject *value_obj, void *closure)
ret = write_register (regcache, obj->regnum, &ul_value);
}
}
#endif
else
{
value = value_object_to_value(value_obj);
Expand Down
5 changes: 3 additions & 2 deletions gdb/python/py-target.c
Original file line number Diff line number Diff line change
Expand Up @@ -748,10 +748,11 @@ enum target_names {
static PyObject *
tgt_py_get_name (PyObject *self, void * arg)
{
enum target_names target_string = (enum target_names) (unsigned long)arg;
enum target_names target_string = (enum target_names) (intptr_t)arg;
pytarget_object *target_obj = (pytarget_object *) self;
struct target_ops *ops = target_obj->ops;


PyObject *name;

const char *shortname;
Expand Down Expand Up @@ -789,7 +790,7 @@ tgt_py_get_name (PyObject *self, void * arg)
static int
tgt_py_set_name (PyObject *self, PyObject *newvalue, void * arg)
{
enum target_names target_string = (enum target_names)(unsigned long) arg;
enum target_names target_string = (enum target_names) (intptr_t)arg;
pytarget_object *target_obj = (pytarget_object *) self;
struct target_ops *ops = target_obj->ops;
char *name = NULL;
Expand Down