35#include "gdbsupport/gdb_optional.h"
60 struct symbol **sym,
const struct block **sym_block,
98 PyErr_SetString (PyExc_RuntimeError,
99 _(
"Unexpected value. Expecting a "
100 "gdb.Symbol or a Python string."));
106 name->reset (xstrdup ((*sym)->print_name ()));
132 if (PyObject_HasAttrString (obj,
"value"))
142 if (vresult == Py_None)
230 int should_print = 0;
244 &&
type->
code () != TYPE_CODE_STRUCT
245 &&
type->
code () != TYPE_CODE_UNION)
270 if (PyObject_HasAttrString (filter,
func))
276 if (result == Py_None)
278 return result.release ();
282 return PyObject_GetIter (result.get ());
309 const char *sym_name,
314 int print_args_field,
321 if (fa->
val == NULL && fa->
error == NULL)
329 gdb::optional<ui_out_emit_tuple> maybe_tuple;
339 if (print_args_field || args_type !=
NO_VALUES)
340 maybe_tuple.emplace (out,
nullptr);
371 if (print_args_field)
395 gdb_assert (fa != NULL && fa->
error != NULL);
397 _(
"<error reading variable: %s>"),
421 int print_args_field,
443 if (item == NULL && PyErr_Occurred ())
449 gdb::unique_xmalloc_ptr<char> sym_name;
451 const struct block *sym_block;
455 success =
extract_sym (item.get (), &sym_name, &sym, &sym_block,
478 PyErr_SetString (PyExc_RuntimeError,
479 _(
"No symbol or value provided."));
484 sym, frame, &arg, &entryarg);
508 args_type, print_args_field, NULL);
516 args_type, print_args_field,
523 item.reset (PyIter_Next (iter));
526 else if (PyErr_Occurred ())
552 int print_args_field,
563 gdb::unique_xmalloc_ptr<char> sym_name;
567 const struct block *sym_block;
568 int local_indent = 8 + (8 * indent);
569 gdb::optional<ui_out_emit_tuple> tuple;
575 success =
extract_sym (item.get (), &sym_name, &sym, &sym_block,
597 if (print_args_field || args_type !=
NO_VALUES)
598 tuple.emplace (out,
nullptr);
602 out->
spaces (local_indent);
613 int val_indent = (indent + 1) * 4;
628 if (!PyErr_Occurred ())
644 if (args_iter == NULL)
648 if (locals_iter == NULL)
653 if (args_iter != Py_None
658 if (locals_iter != Py_None
678 if (locals_iter == NULL)
683 if (locals_iter != Py_None
703 if (args_iter == NULL)
714 if (args_iter != Py_None)
720 else if (PyErr_Occurred ())
724 else if (args_iter != Py_None
752 struct ui_out *out,
int indent, htab_t levels_printed)
755 CORE_ADDR address = 0;
769 gdb::unique_xmalloc_ptr<char> function_to_free;
780 gdb::optional<enum print_what> user_frame_info_print_what;
783 if (!out->
is_mi_like_p () && user_frame_info_print_what.has_value ())
795 if (py_inf_frame == NULL)
815 gdb::optional<ui_out_emit_tuple> tuple;
820 tuple.emplace (out,
"frame");
831 if (PyObject_HasAttrString (filter,
"address"))
838 if (paddr != Py_None)
865 slot = (
frame_info **) htab_find_slot (levels_printed,
866 frame.
get(), INSERT);
878 *slot = frame.
get ();
890 if (opts.addressprint && has_addr)
906 if (PyObject_HasAttrString (filter,
"function"))
909 const char *function = NULL;
918 if (function_to_free == NULL)
921 function = function_to_free.get ();
923 else if (PyLong_Check (py_func.get ()))
932 if (msymbol.
minsym != NULL)
935 else if (py_func != Py_None)
937 PyErr_SetString (PyExc_RuntimeError,
938 _(
"FrameDecorator.function: expecting a " \
939 "String, integer or None."));
944 if (function == NULL)
961 bool print_location_source
964 if (print_location_source)
968 if (PyObject_HasAttrString (filter,
"filename"))
975 if (py_fn != Py_None)
977 gdb::unique_xmalloc_ptr<char>
980 if (filename == NULL)
992 if (PyObject_HasAttrString (filter,
"line"))
1000 if (py_line != Py_None)
1002 line = PyLong_AsLong (py_line.get ());
1003 if (PyErr_Occurred ())
1021 if (print_location_source)
1050 if (elided != Py_None)
1058 while ((item = PyIter_Next (elided.get ())))
1069 if (item == NULL && PyErr_Occurred ())
1082 int frame_low,
int frame_high)
1085 if (frame_obj == NULL)
1088 gdbpy_ref<> module (PyImport_ImportModule (
"gdb.frames"));
1092 gdbpy_ref<> sort_func (PyObject_GetAttrString (module.get (),
1093 "execute_frame_filters"));
1094 if (sort_func == NULL)
1098 if (py_frame_low == NULL)
1102 if (py_frame_high == NULL)
1105 gdbpy_ref<> iterable (PyObject_CallFunctionObjArgs (sort_func.get (),
1107 py_frame_low.get (),
1108 py_frame_high.get (),
1110 if (iterable == NULL)
1113 if (iterable != Py_None)
1114 return PyObject_GetIter (iterable.get ());
1116 return iterable.release ();
1138 struct ui_out *out,
int frame_low,
int frame_high)
1150 catch (
const gdb_exception_error &except)
1161 int frame_countdown = -1;
1167 frame_countdown = frame_high - frame_low + 1;
1173 if (iterable == NULL)
1195 if (iterable == Py_None)
1198 htab_up levels_printed (htab_create (20,
1209 if (PyErr_Occurred ())
1217 if (frame_countdown != -1)
1221 if (frame_countdown == 0)
1225 gdb_printf (_(
"(More stack frames follow...)\n"));
1233 levels_printed.get ());
1235 catch (
const gdb_exception_error &except)
void annotate_frame_source_file_end(void)
void annotate_frame_function_name(void)
void annotate_frame_end(void)
void annotate_arg_end(void)
void annotate_frame_address_end(void)
void annotate_arg_begin(void)
void annotate_frame_address(void)
void annotate_frame_source_file(void)
void annotate_arg_name_end(void)
void annotate_frame_source_line(void)
void annotate_frame_source_begin(void)
void annotate_arg_value(struct type *type)
void annotate_frame_args(void)
void annotate_frame_begin(int level, struct gdbarch *gdbarch, CORE_ADDR pc)
ui_file_style style() const
virtual void puts(const char *str)
void field_fmt_signed(int width, ui_align align, const char *fldname, LONGEST value)
void void void spaces(int numspaces)
void field_core_addr(const char *fldname, struct gdbarch *gdbarch, CORE_ADDR address)
void field_string(const char *fldname, const char *string, const ui_file_style &style=ui_file_style())
void field_fmt(const char *fldname, const char *format,...) ATTRIBUTE_PRINTF(3
void field_signed(const char *fldname, LONGEST value)
void field_skip(const char *fldname)
void text(const char *string)
void field_stream(const char *fldname, string_file &stream, const ui_file_style &style=ui_file_style())
bool is_mi_like_p() const
void void void wrap_hint(int indent)
cli_style_option function_name_style
cli_style_option file_name_style
cli_style_option metadata_style
struct value * read_var_value(struct symbol *var, const struct block *var_block, frame_info_ptr frame)
int frame_relative_level(frame_info_ptr fi)
struct gdbarch * get_frame_arch(frame_info_ptr this_frame)
bool get_frame_pc_masked(frame_info_ptr frame)
symtab_and_line find_frame_sal(frame_info_ptr frame)
void print_frame_info(const frame_print_options &fp_opts, frame_info_ptr, int print_level, enum print_what print_what, int args, int set_current_sal)
const char print_entry_values_compact[]
void read_frame_arg(const frame_print_options &fp_opts, symbol *sym, frame_info_ptr frame, struct frame_arg *argp, struct frame_arg *entryargp)
const char print_entry_values_only[]
const char print_entry_values_no[]
frame_print_options user_frame_print_options
const struct bfd_arch_info * gdbarch_bfd_arch_info(struct gdbarch *gdbarch)
static void print_args(struct field *args, int nargs, int spaces)
struct type * check_typedef(struct type *type)
mach_port_t kern_return_t mach_port_t mach_msg_type_name_t msgportsPoly mach_port_t kern_return_t pid_t pid mach_port_t kern_return_t mach_port_t task mach_port_t kern_return_t int flags
const struct language_defn * language_def(enum language lang)
const struct language_defn * current_language
struct bound_minimal_symbol lookup_minimal_symbol_by_pc(CORE_ADDR pc)
PyObject * frame_info_to_frame_object(frame_info_ptr frame)
frame_info_ptr frame_object_to_frame_info(PyObject *obj)
static void py_print_value(struct ui_out *out, struct value *val, const struct value_print_options *opts, int indent, enum ext_lang_frame_args args_type, const struct language_defn *language)
static enum ext_lang_bt_status extract_sym(PyObject *obj, gdb::unique_xmalloc_ptr< char > *name, struct symbol **sym, const struct block **sym_block, const struct language_defn **language)
enum ext_lang_bt_status gdbpy_apply_frame_filter(const struct extension_language_defn *extlang, frame_info_ptr frame, frame_filter_flags flags, enum ext_lang_frame_args args_type, struct ui_out *out, int frame_low, int frame_high)
static enum ext_lang_bt_status enumerate_args(PyObject *iter, struct ui_out *out, enum ext_lang_frame_args args_type, int print_args_field, frame_info_ptr frame)
static enum ext_lang_bt_status extract_value(PyObject *obj, struct value **value)
static void py_print_type(struct ui_out *out, struct value *val)
static PyObject * get_py_iter_from_func(PyObject *filter, const char *func)
static int mi_should_print(struct symbol *sym, enum mi_print_types type)
static enum ext_lang_bt_status py_print_frame(PyObject *filter, frame_filter_flags flags, enum ext_lang_frame_args args_type, struct ui_out *out, int indent, htab_t levels_printed)
static enum ext_lang_bt_status py_mi_print_variables(PyObject *filter, struct ui_out *out, struct value_print_options *opts, enum ext_lang_frame_args args_type, frame_info_ptr frame)
static enum ext_lang_bt_status py_print_args(PyObject *filter, struct ui_out *out, enum ext_lang_frame_args args_type, frame_info_ptr frame)
static enum ext_lang_bt_status enumerate_locals(PyObject *iter, struct ui_out *out, int indent, enum ext_lang_frame_args args_type, int print_args_field, frame_info_ptr frame)
static PyObject * bootstrap_python_frame_filters(frame_info_ptr frame, int frame_low, int frame_high)
static void py_print_single_arg(struct ui_out *out, const char *sym_name, struct frame_arg *fa, struct value *fv, const struct value_print_options *opts, enum ext_lang_frame_args args_type, int print_args_field, const struct language_defn *language)
static enum ext_lang_bt_status py_print_locals(PyObject *filter, struct ui_out *out, enum ext_lang_frame_args args_type, int indent, frame_info_ptr frame)
gdb::ref_ptr< T, gdbpy_ref_policy< T > > gdbpy_ref
struct symbol * symbol_object_to_symbol(PyObject *obj)
gdbpy_ref gdb_py_object_from_longest(LONGEST l)
int get_addr_from_python(PyObject *obj, CORE_ADDR *addr)
void gdbpy_convert_exception(const struct gdb_exception &exception)
gdb::unique_xmalloc_ptr< char > python_string_to_host_string(PyObject *obj)
int gdbpy_is_string(PyObject *obj)
struct value * convert_value_from_python(PyObject *obj)
#define PyObject_CallMethod
int gdb_python_initialized
void gdbpy_print_stack_or_quit()
void(* func)(remote_target *remote, char *)
void print_source_lines(struct symtab *s, int line, int stopline, print_source_lines_flags flags)
bool frame_show_address(frame_info_ptr frame, struct symtab_and_line sal)
void get_user_print_what_frame_info(gdb::optional< enum print_what > *what)
struct minimal_symbol * minsym
gdb::unique_xmalloc_ptr< char > error
const char * print_name() const
enum language language() const
address_class aclass() const
void type_print(struct type *type, const char *varstring, struct ui_file *stream, int show)
void gdb_printf(struct ui_file *stream, const char *format,...)
void gdb_puts(const char *linebuffer, struct ui_file *stream)
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)
struct type * value_type(const struct value *value)