static PyObject * find_pretty_printer_from_objfiles (PyObject *value) { struct objfile *obj; ALL_OBJFILES (obj) { PyObject *objf = objfile_to_objfile_object (obj); if (!objf) { /* Ignore the error and continue. */ PyErr_Clear (); continue; } gdbpy_ref<> pp_list (objfpy_get_printers (objf, NULL)); 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 (function == NULL) return NULL; if (function != Py_None) return function.release (); } Py_RETURN_NONE; }
static PyObject * find_pretty_printer_from_objfiles (PyObject *value) { PyObject *pp_list; PyObject *function; struct objfile *obj; ALL_OBJFILES (obj) { PyObject *objf = objfile_to_objfile_object (obj); if (!objf) { /* Ignore the error and continue. */ PyErr_Clear (); continue; } pp_list = objfpy_get_printers (objf, NULL); function = search_pp_list (pp_list, value); Py_XDECREF (pp_list); /* If there is an error in any objfile list, abort the search and exit. */ if (! function) return NULL; if (function != Py_None) return function; Py_DECREF (function); } Py_RETURN_NONE; }
/* Find the pretty-printing constructor function for VALUE. If no pretty-printer exists, return None. If one exists, return a new reference. On error, set the Python error and return NULL. */ static PyObject * find_pretty_printer (PyObject *value) { PyObject *pp_list = NULL; PyObject *function = NULL; struct objfile *obj; volatile struct gdb_exception except; /* Look at the pretty-printer dictionary for each objfile. */ ALL_OBJFILES (obj) { PyObject *objf = objfile_to_objfile_object (obj); if (!objf) { /* Ignore the error and continue. */ PyErr_Clear (); continue; } pp_list = objfpy_get_printers (objf, NULL); function = search_pp_list (pp_list, value); /* If there is an error in any objfile list, abort the search and exit. */ if (! function) { Py_XDECREF (pp_list); return NULL; } if (function != Py_None) goto done; Py_DECREF (function); Py_XDECREF (pp_list); } pp_list = NULL; /* Fetch the global pretty printer dictionary. */ if (! PyObject_HasAttrString (gdb_module, "pretty_printers")) { function = Py_None; Py_INCREF (function); goto done; } pp_list = PyObject_GetAttrString (gdb_module, "pretty_printers"); if (! pp_list) goto done; if (! PyList_Check (pp_list)) goto done; function = search_pp_list (pp_list, value); done: Py_XDECREF (pp_list); return function; }
static PyObject * stpy_get_objfile (PyObject *self, void *closure) { struct symtab *symtab = NULL; PyObject *result; STPY_REQUIRE_VALID (self, symtab); result = objfile_to_objfile_object (SYMTAB_OBJFILE (symtab)); Py_XINCREF (result); return result; }
static gdbpy_ref<> create_new_objfile_event_object (struct objfile *objfile) { gdbpy_ref<> objfile_event = create_event_object (&new_objfile_event_object_type); if (objfile_event == NULL) return NULL; gdbpy_ref<> py_objfile = objfile_to_objfile_object (objfile); if (py_objfile == NULL || evpy_add_attribute (objfile_event.get (), "new_objfile", py_objfile.get ()) < 0) return NULL; return objfile_event; }
static PyObject * objfpy_get_owner (PyObject *self, void *closure) { objfile_object *obj = (objfile_object *) self; struct objfile *objfile = obj->objfile; struct objfile *owner; OBJFPY_REQUIRE_VALID (obj); owner = objfile->separate_debug_objfile_backlink; if (owner != NULL) { PyObject *result = objfile_to_objfile_object (owner); Py_XINCREF (result); return result; } Py_RETURN_NONE; }
static PyObject * create_new_objfile_event_object (struct objfile *objfile) { PyObject *objfile_event; PyObject *py_objfile; objfile_event = create_event_object (&new_objfile_event_object_type); if (!objfile_event) goto fail; /* Note that objfile_to_objfile_object returns a borrowed reference, so we don't need a decref here. */ py_objfile = objfile_to_objfile_object (objfile); if (!py_objfile || evpy_add_attribute (objfile_event, "new_objfile", py_objfile) < 0) goto fail; return objfile_event; fail: Py_XDECREF (objfile_event); return NULL; }