Change objfile_to_objfile_object to return a new reference
This changes objfile_to_objfile_object to return a new references and fixes up all the uses. gdb/ChangeLog 2018-09-16 Tom Tromey <tom@tromey.com> * python/py-progspace.c (pspy_get_objfiles): Update. * python/python-internal.h (objfile_to_objfile_object): Change return type. * python/py-newobjfileevent.c (create_new_objfile_event_object): Update. * python/py-xmethods.c (gdbpy_get_matching_xmethod_workers): Update. * python/python.c (gdbpy_get_current_objfile): Update. (gdbpy_objfiles): Update. * python/py-objfile.c (objfpy_get_owner, gdbpy_lookup_objfile): Update. (objfile_to_objfile_object): Return a new reference. * python/py-symtab.c (stpy_get_objfile): Update. * python/py-prettyprint.c (find_pretty_printer_from_objfiles): Update.
This commit is contained in:
parent
3c7aa30778
commit
0a9db5ad8a
9 changed files with 51 additions and 51 deletions
|
@ -1,3 +1,21 @@
|
||||||
|
2018-09-16 Tom Tromey <tom@tromey.com>
|
||||||
|
|
||||||
|
* python/py-progspace.c (pspy_get_objfiles): Update.
|
||||||
|
* python/python-internal.h (objfile_to_objfile_object): Change
|
||||||
|
return type.
|
||||||
|
* python/py-newobjfileevent.c (create_new_objfile_event_object):
|
||||||
|
Update.
|
||||||
|
* python/py-xmethods.c (gdbpy_get_matching_xmethod_workers):
|
||||||
|
Update.
|
||||||
|
* python/python.c (gdbpy_get_current_objfile): Update.
|
||||||
|
(gdbpy_objfiles): Update.
|
||||||
|
* python/py-objfile.c (objfpy_get_owner, gdbpy_lookup_objfile):
|
||||||
|
Update.
|
||||||
|
(objfile_to_objfile_object): Return a new reference.
|
||||||
|
* python/py-symtab.c (stpy_get_objfile): Update.
|
||||||
|
* python/py-prettyprint.c (find_pretty_printer_from_objfiles):
|
||||||
|
Update.
|
||||||
|
|
||||||
2018-09-16 Tom Tromey <tom@tromey.com>
|
2018-09-16 Tom Tromey <tom@tromey.com>
|
||||||
|
|
||||||
* python/py-inferior.c (infpy_get_progspace): Update.
|
* python/py-inferior.c (infpy_get_progspace): Update.
|
||||||
|
|
|
@ -28,12 +28,10 @@ create_new_objfile_event_object (struct objfile *objfile)
|
||||||
if (objfile_event == NULL)
|
if (objfile_event == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
/* Note that objfile_to_objfile_object returns a borrowed reference,
|
gdbpy_ref<> py_objfile = objfile_to_objfile_object (objfile);
|
||||||
so we don't need a decref here. */
|
if (py_objfile == NULL || evpy_add_attribute (objfile_event.get (),
|
||||||
PyObject *py_objfile = objfile_to_objfile_object (objfile);
|
"new_objfile",
|
||||||
if (!py_objfile || evpy_add_attribute (objfile_event.get (),
|
py_objfile.get ()) < 0)
|
||||||
"new_objfile",
|
|
||||||
py_objfile) < 0)
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return objfile_event;
|
return objfile_event;
|
||||||
|
|
|
@ -115,12 +115,7 @@ objfpy_get_owner (PyObject *self, void *closure)
|
||||||
|
|
||||||
owner = objfile->separate_debug_objfile_backlink;
|
owner = objfile->separate_debug_objfile_backlink;
|
||||||
if (owner != NULL)
|
if (owner != NULL)
|
||||||
{
|
return objfile_to_objfile_object (owner).release ();
|
||||||
PyObject *result = objfile_to_objfile_object (owner);
|
|
||||||
|
|
||||||
Py_XINCREF (result);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -602,12 +597,7 @@ gdbpy_lookup_objfile (PyObject *self, PyObject *args, PyObject *kw)
|
||||||
objfile = objfpy_lookup_objfile_by_name (name);
|
objfile = objfpy_lookup_objfile_by_name (name);
|
||||||
|
|
||||||
if (objfile != NULL)
|
if (objfile != NULL)
|
||||||
{
|
return objfile_to_objfile_object (objfile).release ();
|
||||||
PyObject *result = objfile_to_objfile_object (objfile);
|
|
||||||
|
|
||||||
Py_XINCREF (result);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
PyErr_SetString (PyExc_ValueError, _("Objfile not found."));
|
PyErr_SetString (PyExc_ValueError, _("Objfile not found."));
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -625,30 +615,31 @@ py_free_objfile (struct objfile *objfile, void *datum)
|
||||||
object->objfile = NULL;
|
object->objfile = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return a borrowed reference to the Python object of type Objfile
|
/* Return a new reference to the Python object of type Objfile
|
||||||
representing OBJFILE. If the object has already been created,
|
representing OBJFILE. If the object has already been created,
|
||||||
return it. Otherwise, create it. Return NULL and set the Python
|
return it. Otherwise, create it. Return NULL and set the Python
|
||||||
error on failure. */
|
error on failure. */
|
||||||
|
|
||||||
PyObject *
|
gdbpy_ref<>
|
||||||
objfile_to_objfile_object (struct objfile *objfile)
|
objfile_to_objfile_object (struct objfile *objfile)
|
||||||
{
|
{
|
||||||
gdbpy_ref<objfile_object> object
|
PyObject *result
|
||||||
((objfile_object *) objfile_data (objfile, objfpy_objfile_data_key));
|
= ((PyObject *) objfile_data (objfile, objfpy_objfile_data_key));
|
||||||
if (object == NULL)
|
if (result == NULL)
|
||||||
{
|
{
|
||||||
object.reset (PyObject_New (objfile_object, &objfile_object_type));
|
gdbpy_ref<objfile_object> object
|
||||||
if (object != NULL)
|
((objfile_object *) PyObject_New (objfile_object, &objfile_object_type));
|
||||||
{
|
if (object == NULL)
|
||||||
if (!objfpy_initialize (object.get ()))
|
return NULL;
|
||||||
return NULL;
|
if (!objfpy_initialize (object.get ()))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
object->objfile = objfile;
|
object->objfile = objfile;
|
||||||
set_objfile_data (objfile, objfpy_objfile_data_key, object.get ());
|
set_objfile_data (objfile, objfpy_objfile_data_key, object.get ());
|
||||||
}
|
result = (PyObject *) object.release ();
|
||||||
}
|
}
|
||||||
|
|
||||||
return (PyObject *) object.release ();
|
return gdbpy_ref<>::new_reference (result);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|
|
@ -97,15 +97,15 @@ find_pretty_printer_from_objfiles (PyObject *value)
|
||||||
|
|
||||||
ALL_OBJFILES (obj)
|
ALL_OBJFILES (obj)
|
||||||
{
|
{
|
||||||
PyObject *objf = objfile_to_objfile_object (obj);
|
gdbpy_ref<> objf = objfile_to_objfile_object (obj);
|
||||||
if (!objf)
|
if (objf == NULL)
|
||||||
{
|
{
|
||||||
/* Ignore the error and continue. */
|
/* Ignore the error and continue. */
|
||||||
PyErr_Clear ();
|
PyErr_Clear ();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
gdbpy_ref<> pp_list (objfpy_get_printers (objf, NULL));
|
gdbpy_ref<> pp_list (objfpy_get_printers (objf.get (), NULL));
|
||||||
gdbpy_ref<> function (search_pp_list (pp_list.get (), value));
|
gdbpy_ref<> function (search_pp_list (pp_list.get (), value));
|
||||||
|
|
||||||
/* If there is an error in any objfile list, abort the search and exit. */
|
/* If there is an error in any objfile list, abort the search and exit. */
|
||||||
|
|
|
@ -344,9 +344,10 @@ pspy_get_objfiles (PyObject *self_, PyObject *args)
|
||||||
|
|
||||||
ALL_PSPACE_OBJFILES (self->pspace, objf)
|
ALL_PSPACE_OBJFILES (self->pspace, objf)
|
||||||
{
|
{
|
||||||
PyObject *item = objfile_to_objfile_object (objf);
|
gdbpy_ref<> item = objfile_to_objfile_object (objf);
|
||||||
|
|
||||||
if (!item || PyList_Append (list.get (), item) == -1)
|
if (item == nullptr
|
||||||
|
|| PyList_Append (list.get (), item.get ()) == -1)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,13 +117,10 @@ static PyObject *
|
||||||
stpy_get_objfile (PyObject *self, void *closure)
|
stpy_get_objfile (PyObject *self, void *closure)
|
||||||
{
|
{
|
||||||
struct symtab *symtab = NULL;
|
struct symtab *symtab = NULL;
|
||||||
PyObject *result;
|
|
||||||
|
|
||||||
STPY_REQUIRE_VALID (self, symtab);
|
STPY_REQUIRE_VALID (self, symtab);
|
||||||
|
|
||||||
result = objfile_to_objfile_object (SYMTAB_OBJFILE (symtab));
|
return objfile_to_objfile_object (SYMTAB_OBJFILE (symtab)).release ();
|
||||||
Py_XINCREF (result);
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Getter function for symtab.producer. */
|
/* Getter function for symtab.producer. */
|
||||||
|
|
|
@ -147,7 +147,7 @@ gdbpy_get_matching_xmethod_workers
|
||||||
list individually, but there's no data yet to show it's needed. */
|
list individually, but there's no data yet to show it's needed. */
|
||||||
ALL_OBJFILES (objfile)
|
ALL_OBJFILES (objfile)
|
||||||
{
|
{
|
||||||
PyObject *py_objfile = objfile_to_objfile_object (objfile);
|
gdbpy_ref<> py_objfile = objfile_to_objfile_object (objfile);
|
||||||
|
|
||||||
if (py_objfile == NULL)
|
if (py_objfile == NULL)
|
||||||
{
|
{
|
||||||
|
@ -155,7 +155,8 @@ gdbpy_get_matching_xmethod_workers
|
||||||
return EXT_LANG_RC_ERROR;
|
return EXT_LANG_RC_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
gdbpy_ref<> objfile_matchers (objfpy_get_xmethods (py_objfile, NULL));
|
gdbpy_ref<> objfile_matchers (objfpy_get_xmethods (py_objfile.get (),
|
||||||
|
NULL));
|
||||||
gdbpy_ref<> temp (PySequence_Concat (py_xmethod_matcher_list.get (),
|
gdbpy_ref<> temp (PySequence_Concat (py_xmethod_matcher_list.get (),
|
||||||
objfile_matchers.get ()));
|
objfile_matchers.get ()));
|
||||||
if (temp == NULL)
|
if (temp == NULL)
|
||||||
|
|
|
@ -522,8 +522,7 @@ PyObject *pspy_get_frame_filters (PyObject *, void *);
|
||||||
PyObject *pspy_get_frame_unwinders (PyObject *, void *);
|
PyObject *pspy_get_frame_unwinders (PyObject *, void *);
|
||||||
PyObject *pspy_get_xmethods (PyObject *, void *);
|
PyObject *pspy_get_xmethods (PyObject *, void *);
|
||||||
|
|
||||||
PyObject *objfile_to_objfile_object (struct objfile *)
|
gdbpy_ref<> objfile_to_objfile_object (struct objfile *);
|
||||||
CPYCHECKER_RETURNS_BORROWED_REF;
|
|
||||||
PyObject *objfpy_get_printers (PyObject *, void *);
|
PyObject *objfpy_get_printers (PyObject *, void *);
|
||||||
PyObject *objfpy_get_frame_filters (PyObject *, void *);
|
PyObject *objfpy_get_frame_filters (PyObject *, void *);
|
||||||
PyObject *objfpy_get_frame_unwinders (PyObject *, void *);
|
PyObject *objfpy_get_frame_unwinders (PyObject *, void *);
|
||||||
|
|
|
@ -1359,15 +1359,10 @@ gdbpy_execute_objfile_script (const struct extension_language_defn *extlang,
|
||||||
static PyObject *
|
static PyObject *
|
||||||
gdbpy_get_current_objfile (PyObject *unused1, PyObject *unused2)
|
gdbpy_get_current_objfile (PyObject *unused1, PyObject *unused2)
|
||||||
{
|
{
|
||||||
PyObject *result;
|
|
||||||
|
|
||||||
if (! gdbpy_current_objfile)
|
if (! gdbpy_current_objfile)
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
|
|
||||||
result = objfile_to_objfile_object (gdbpy_current_objfile);
|
return objfile_to_objfile_object (gdbpy_current_objfile).release ();
|
||||||
if (result)
|
|
||||||
Py_INCREF (result);
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Compute the list of active python type printers and store them in
|
/* Compute the list of active python type printers and store them in
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue