55 Py_ssize_t pp_list_size, list_index;
57 pp_list_size = PyList_Size (list);
58 for (list_index = 0; list_index < pp_list_size; list_index++)
60 PyObject *function = PyList_GetItem (list, list_index);
72 cmp = PyObject_IsTrue (attr.get ());
84 else if (printer != Py_None)
114 if (function == NULL)
117 if (function != Py_None)
118 return function.release ();
156 if (pp_list == NULL || ! PyList_Check (pp_list.get ()))
172 if (function == NULL || function != Py_None)
177 if (function == NULL || function != Py_None)
210 && result != Py_None)
213 if (PyErr_Occurred ())
220 catch (
const gdb_exception &except)
231gdb::unique_xmalloc_ptr<char>
234 gdb::unique_xmalloc_ptr<char> result;
264 gdb::unique_xmalloc_ptr<char> msg = fetched_error.
to_string ();
266 if (msg == NULL || *msg ==
'\0')
268 _(
"<error reading variable>"));
271 _(
"<error reading variable: %s>"), msg.get ());
282 struct ui_file *stream,
int recurse,
287 struct value *replacement = NULL;
293 if (py_str == Py_None)
300 gdb::unique_xmalloc_ptr<char> encoding;
308 stream, &local_opts);
320 output = PyBytes_AS_STRING (
string.
get ());
321 length = PyBytes_GET_SIZE (
string.
get ());
324 if (hint && !strcmp (hint,
"string"))
326 length, NULL, 0, options);
337 else if (replacement)
341 opts.addressprint = 0;
358 struct ui_file *stream,
int recurse,
363 int is_map, is_array, done_flag, pretty;
371 is_map = hint && ! strcmp (hint,
"map");
372 is_array = hint && ! strcmp (hint,
"array");
376 if (children == NULL)
382 gdbpy_ref<> iter (PyObject_GetIter (children.get ()));
410 if (PyErr_Occurred ())
419 if (! PyTuple_Check (item.get ()) || PyTuple_Size (item.get ()) != 2)
421 PyErr_SetString (PyExc_TypeError,
422 _(
"Result of children iterator not a tuple"
423 " of two elements."));
427 if (! PyArg_ParseTuple (item.get (),
"sO", &
name, &py_v))
433 _(
"Bad result from children iterator.\n"));
448 else if (! is_map || i % 2 == 0)
449 gdb_puts (pretty ?
"," :
", ", stream);
473 if (! is_map || i % 2 == 0)
484 if (is_map && i % 2 == 0)
504 gdb::unique_xmalloc_ptr<char> encoding;
515 gdb::unique_xmalloc_ptr<char> output;
530 error (_(
"Error while executing Python code."));
538 if (is_map && i % 2 == 0
546 if (is_map && i % 2 == 0)
573 struct ui_file *stream,
int recurse,
608 if (printer == Py_None)
621 print_children (printer.get (), hint.get (), stream, recurse, options,
624 if (PyErr_Occurred ())
641 struct value **replacement,
651 if (*replacement == NULL && py_str == NULL)
668 catch (
const gdb_exception &except)
690 if (! PyArg_ParseTuple (args,
"O", &val_obj))
695 PyErr_SetString (PyExc_TypeError,
696 _(
"Argument must be a gdb.Value."));
708 if (val_obj ==
nullptr)
710 return PyDict_SetItemString (dict,
name, val_obj.get ());
718 if (val_obj ==
nullptr)
720 return PyDict_SetItemString (dict,
name, val_obj.get ());
728 if (result ==
nullptr)
737 opts.prettyformat_arrays) < 0
739 opts.prettyformat_structs) < 0
741 opts.print_array_indexes) < 0
743 opts.symbol_print) < 0
747 opts.addressprint) < 0
751 opts.objectprint) < 0
753 opts.static_field_print) < 0
757 opts.nibblesprint) < 0
765 opts.repeat_count_threshold) < 0)
768 if (opts.format != 0)
770 char str[2] = { (char) opts.format, 0 };
772 if (fmtstr ==
nullptr)
774 if (PyDict_SetItemString (result.get (),
"format", fmtstr.get ()) < 0)
778 return result.release ();
constexpr string_view get()
ui_file_style style() const
gdb::unique_xmalloc_ptr< char > to_string() const
virtual void wrap_here(int indent)
cli_style_option metadata_style
struct program_space * current_program_space
void gdbpy_extract_lazy_string(PyObject *string, CORE_ADDR *addr, struct type **str_elt_type, long *length, gdb::unique_xmalloc_ptr< char > *encoding)
int gdbpy_is_lazy_string(PyObject *result)
gdbpy_ref objfile_to_objfile_object(struct objfile *objfile)
PyObject * objfpy_get_printers(PyObject *o, void *ignore)
static int set_boolean(PyObject *dict, const char *name, bool val)
static enum gdbpy_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)
gdbpy_ref apply_varobj_pretty_printer(PyObject *printer_obj, struct value **replacement, struct ui_file *stream, const value_print_options *opts)
static int set_unsigned(PyObject *dict, const char *name, unsigned int val)
static gdbpy_ref find_pretty_printer_from_gdb(PyObject *value)
gdb::unique_xmalloc_ptr< char > gdbpy_get_display_hint(PyObject *printer)
PyObject * gdbpy_default_visualizer(PyObject *self, PyObject *args)
static gdbpy_ref search_pp_list(PyObject *list, PyObject *value)
PyObject * gdbpy_print_options(PyObject *unused1, PyObject *unused2)
static void print_stack_unless_memory_error(struct ui_file *stream)
static gdbpy_ref find_pretty_printer(PyObject *value)
static gdbpy_ref find_pretty_printer_from_progspace(PyObject *value)
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_from_objfiles(PyObject *value)
gdbpy_ref gdbpy_get_varobj_pretty_printer(struct value *value)
const struct value_print_options * gdbpy_current_print_options
static gdbpy_ref pretty_print_one_value(PyObject *printer, struct value **out_value)
enum ext_lang_rc gdbpy_apply_val_pretty_printer(const struct extension_language_defn *extlang, struct value *value, struct ui_file *stream, int recurse, const struct value_print_options *options, const struct language_defn *language)
void gdbpy_get_print_options(value_print_options *opts)
gdbpy_ref pspace_to_pspace_object(struct program_space *pspace)
PyObject * pspy_get_printers(PyObject *o, void *ignore)
gdb::ref_ptr< T, gdbpy_ref_policy< T > > gdbpy_ref
gdbpy_ref host_string_to_python_string(const char *str)
gdb::unique_xmalloc_ptr< char > python_string_to_host_string(PyObject *obj)
gdbpy_ref python_string_to_target_python_string(PyObject *obj)
int gdbpy_is_string(PyObject *obj)
gdbpy_ref gdb_py_object_from_ulongest(ULONGEST l)
struct value * convert_value_from_python(PyObject *obj)
PyObject * value_to_value_object_no_release(struct value *val)
PyObject * value_to_value_object(struct value *val)
struct value * value_object_to_value(PyObject *self)
void gdbpy_print_stack(void)
int gdbpy_print_python_errors_p(void)
int gdb_python_initialized
PyObject * gdbpy_children_cst
PyObject * gdbpy_gdb_memory_error
PyObject * gdbpy_display_hint_cst
PyObject * gdbpy_enabled_cst
PyObject * gdbpy_to_string_cst
PyObject * gdb_python_module
#define GDB_PY_HANDLE_EXCEPTION(Exception)
struct type * builtin_char
objfiles_range objfiles()
enum val_prettyformat prettyformat
bool prettyformat_structs
void print_spaces(int n, struct ui_file *stream)
void fprintf_styled(struct ui_file *stream, const ui_file_style &style, const char *format,...)
void gdb_printf(struct ui_file *stream, const char *format,...)
void gdb_puts(const char *linebuffer, struct ui_file *stream)
bool val_print_check_max_depth(struct ui_file *stream, int recurse, const struct value_print_options *options, const struct language_defn *language)
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)
void get_user_print_options(struct value_print_options *opts)
void common_val_print(struct value *value, struct ui_file *stream, int recurse, const struct value_print_options *options, const struct language_defn *language)
int value_bytes_available(const struct value *value, LONGEST offset, LONGEST length)
struct type * value_type(const struct value *value)
int value_lazy(const struct value *value)
void value_fetch_lazy(struct value *val)
struct value * value_copy(const value *arg)