51 Py_ssize_t pp_list_size, list_index;
53 pp_list_size = PyList_Size (list);
54 for (list_index = 0; list_index < pp_list_size; list_index++)
56 PyObject *
function = PyList_GetItem (list, list_index);
68 cmp = PyObject_IsTrue (attr.
get ());
80 else if (printer != Py_None)
112 if (
function == NULL)
115 if (
function != Py_None)
154 if (pp_list == NULL || ! PyList_Check (pp_list.
get ()))
170 if (
function == NULL ||
function != Py_None)
175 if (
function == NULL ||
function != Py_None)
176 return function.release ();
204 && result != Py_None)
207 if (PyErr_Occurred ())
268 if (msg == NULL || *msg ==
'\0')
283 struct ui_file *stream,
int recurse,
288 struct value *replacement = NULL;
294 if (py_str == Py_None)
309 stream, &local_opts);
322 output = PyBytes_AS_STRING (
string.
get ());
323 length = PyBytes_GET_SIZE (
string.
get ());
325 output = PyString_AsString (
string.
get ());
326 length = PyString_Size (
string.
get ());
330 if (hint && !strcmp (hint,
"string"))
332 length, NULL, 0, options);
343 else if (replacement)
390 m_saved_frame (NULL),
394 PyFrameObject *frame;
396 gdbpy_ref<> empty_string (PyString_FromString (
""));
397 if (empty_string == NULL)
401 if (null_tuple == NULL)
404 code = PyCode_New (0,
412 #if PYTHON_API_VERSION >= 1010 446 struct ui_file *stream,
int recurse,
451 int is_map, is_array, done_flag, pretty;
459 is_map = hint && ! strcmp (hint,
"map");
460 is_array = hint && ! strcmp (hint,
"array");
464 if (children == NULL)
510 if (PyErr_Occurred ())
519 if (! PyTuple_Check (item.
get ()) || PyTuple_Size (item.
get ()) != 2)
521 PyErr_SetString (PyExc_TypeError,
522 _(
"Result of children iterator not a tuple" 523 " of two elements."));
527 if (! PyArg_ParseTuple (item.
get (),
"sO", &
name, &py_v))
533 _(
"Bad result from children iterator.\n"));
551 else if (! is_map || i % 2 == 0)
566 if (! is_map || i % 2 == 0)
577 if (is_map && i % 2 == 0)
623 error (
_(
"Error while executing Python code."));
629 if (is_map && i % 2 == 0)
657 struct ui_file *stream,
int recurse,
694 if (printer == Py_None)
707 if (PyErr_Occurred ())
724 struct value **replacement,
727 PyObject *py_str = NULL;
732 if (*replacement == NULL && py_str == NULL)
773 if (! PyArg_ParseTuple (args,
"O", &val_obj))
778 PyErr_SetString (PyExc_TypeError,
779 _(
"Argument must be a gdb.Value."));
static PyObject * find_pretty_printer_from_gdb(PyObject *value)
#define PyObject_GetAttrString(obj, attr)
PyObject * gdb_python_module
static void print_stack_unless_memory_error(struct ui_file *stream)
static PyObject * find_pretty_printer_from_progspace(PyObject *value)
int gdbpy_is_string(PyObject *obj)
const struct builtin_type * builtin_type(struct gdbarch *gdbarch)
void common_val_print(struct value *val, struct ui_file *stream, int recurse, const struct value_print_options *options, const struct language_defn *language)
PyObject * gdbpy_to_string_cst
PyObject * apply_varobj_pretty_printer(PyObject *printer_obj, struct value **replacement, struct ui_file *stream)
PyObject * python_string_to_target_python_string(PyObject *obj)
struct value * value_copy(struct value *arg)
const gdb_byte * value_contents_for_printing(struct value *value)
PyObject * gdbpy_display_hint_cst
int value_bytes_available(const struct value *value, LONGEST offset, LONGEST length)
enum val_prettyformat prettyformat
#define GDB_PY_HANDLE_EXCEPTION(Exception)
#define CATCH(EXCEPTION, MASK)
std::unique_ptr< T, xfree_deleter< T > > unique_xmalloc_ptr
PyObject * gdbpy_enabled_cst
void fprintf_filtered(struct ui_file *stream, const char *format,...)
void fprintf_unfiltered(struct ui_file *stream, const char *format,...)
void fputs_filtered(const char *linebuffer, struct ui_file *stream)
int gdbpy_print_python_errors_p(void)
PyObject * objfile_to_objfile_object(struct objfile *objfile)
struct gdbarch * get_type_arch(const struct type *type)
PyObject * value_to_value_object(struct value *val)
int gdb_python_initialized
gdb::unique_xmalloc_ptr< char > python_string_to_host_string(PyObject *obj)
PyFrameObject * m_saved_frame
void wrap_here(const char *indent)
struct value * value_ref(struct value *arg1, enum type_code refcode)
void print_spaces_filtered(int n, struct ui_file *stream)
void gdbpy_extract_lazy_string(PyObject *string, CORE_ADDR *addr, struct type **str_elt_type, long *length, gdb::unique_xmalloc_ptr< char > *encoding)
struct type * builtin_char
PyObject * gdbpy_children_cst
enum ext_lang_rc gdbpy_apply_val_pretty_printer(const struct extension_language_defn *extlang, struct type *type, LONGEST embedded_offset, CORE_ADDR address, struct ui_file *stream, int recurse, struct value *val, const struct value_print_options *options, const struct language_defn *language)
static void print_children(PyObject *printer, const char *hint, struct ui_file *stream, int recurse, const struct value_print_options *options, const struct language_defn *language, int is_py_none)
static PyObject * find_pretty_printer(PyObject *value)
PyObject * gdbpy_default_visualizer(PyObject *self, PyObject *args)
gdb::unique_xmalloc_ptr< char > gdbpy_get_display_hint(PyObject *printer)
static PyObject * pretty_print_one_value(PyObject *printer, struct value **out_value)
PyObject * objfpy_get_printers(PyObject *o, void *ignore)
void gdbpy_print_stack(void)
struct value * convert_value_from_python(PyObject *obj)
int gdbpy_is_lazy_string(PyObject *result)
PyObject * gdbpy_gdb_memory_error
struct program_space * current_program_space
static enum string_repr_result print_string_repr(PyObject *printer, const char *hint, struct ui_file *stream, int recurse, const struct value_print_options *options, const struct language_defn *language, struct gdbarch *gdbarch)
gdb::unique_xmalloc_ptr< char > gdbpy_exception_to_string(PyObject *ptype, PyObject *pvalue)
#define LA_PRINT_STRING(stream, elttype, string, length, encoding, force_ellipses, options)
struct value * value_object_to_value(PyObject *self)
static PyObject * search_pp_list(PyObject *list, PyObject *value)
#define TYPE_LENGTH(thistype)
int val_print_string(struct type *elttype, const char *encoding, CORE_ADDR addr, int len, struct ui_file *stream, const struct value_print_options *options)
#define ALL_OBJFILES(obj)
PyObject * gdbpy_get_varobj_pretty_printer(struct value *value)
struct value * value_from_component(struct value *whole, struct type *type, LONGEST offset)
static PyObject * find_pretty_printer_from_objfiles(PyObject *value)
void error(const char *fmt,...)
PyObject * pspace_to_pspace_object(struct program_space *pspace)
#define PyObject_HasAttrString(obj, attr)
PyObject * pspy_get_printers(PyObject *o, void *ignore)