/* 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 * 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; }
static PyObject * find_pretty_printer_from_progspace (PyObject *value) { PyObject *obj = pspace_to_pspace_object (current_program_space); if (!obj) return NULL; gdbpy_ref<> pp_list (pspy_get_printers (obj, NULL)); return search_pp_list (pp_list.get (), value); }
static PyObject * find_pretty_printer_from_gdb (PyObject *value) { /* Fetch the global pretty printer list. */ if (gdb_python_module == NULL || ! PyObject_HasAttrString (gdb_python_module, "pretty_printers")) Py_RETURN_NONE; gdbpy_ref<> pp_list (PyObject_GetAttrString (gdb_python_module, "pretty_printers")); if (pp_list == NULL || ! PyList_Check (pp_list.get ())) Py_RETURN_NONE; return search_pp_list (pp_list.get (), value); }
static PyObject * find_pretty_printer_from_progspace (PyObject *value) { PyObject *pp_list; PyObject *function; PyObject *obj = pspace_to_pspace_object (current_program_space); if (!obj) return NULL; pp_list = pspy_get_printers (obj, NULL); function = search_pp_list (pp_list, value); Py_XDECREF (pp_list); return function; }
static PyObject * find_pretty_printer_from_gdb (PyObject *value) { PyObject *pp_list; PyObject *function; /* Fetch the global pretty printer list. */ if (gdb_python_module == NULL || ! PyObject_HasAttrString (gdb_python_module, "pretty_printers")) Py_RETURN_NONE; pp_list = PyObject_GetAttrString (gdb_python_module, "pretty_printers"); if (pp_list == NULL || ! PyList_Check (pp_list)) { Py_XDECREF (pp_list); Py_RETURN_NONE; } function = search_pp_list (pp_list, value); Py_XDECREF (pp_list); return function; }