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;
266 if (PyObject_HasAttrString (filter,
func))
272 if (result == Py_None)
274 return result.release ();
278 return PyObject_GetIter (result.get ());
305 const char *sym_name,
310 int print_args_field,
317 if (fa->
val == NULL && fa->
error == NULL)
325 gdb::optional<ui_out_emit_tuple> maybe_tuple;
335 if (print_args_field || args_type !=
NO_VALUES)
336 maybe_tuple.emplace (out,
nullptr);
367 if (print_args_field)
391 gdb_assert (fa != NULL && fa->
error != NULL);
393 _(
"<error reading variable: %s>"),
417 int print_args_field,
430 opts.deref_ref =
true;
439 if (item == NULL && PyErr_Occurred ())
445 gdb::unique_xmalloc_ptr<char> sym_name;
447 const struct block *sym_block;
451 success =
extract_sym (item.get (), &sym_name, &sym, &sym_block,
474 PyErr_SetString (PyExc_RuntimeError,
475 _(
"No symbol or value provided."));
480 sym, frame, &arg, &entryarg);
504 args_type, print_args_field, NULL);
512 args_type, print_args_field,
519 item.reset (PyIter_Next (iter));
522 else if (PyErr_Occurred ())
548 int print_args_field,
554 opts.deref_ref =
true;
559 gdb::unique_xmalloc_ptr<char> sym_name;
563 const struct block *sym_block;
564 int local_indent = 8 + (8 * indent);
565 gdb::optional<ui_out_emit_tuple> tuple;
571 success =
extract_sym (item.get (), &sym_name, &sym, &sym_block,
593 if (print_args_field || args_type !=
NO_VALUES)
594 tuple.emplace (out,
nullptr);
598 out->
spaces (local_indent);
609 int val_indent = (indent + 1) * 4;
624 if (!PyErr_Occurred ())
640 if (args_iter == NULL)
644 if (locals_iter == NULL)
649 if (args_iter != Py_None
654 if (locals_iter != Py_None
674 if (locals_iter == NULL)
679 if (locals_iter != Py_None
699 if (args_iter == NULL)
710 if (args_iter != Py_None)
716 else if (PyErr_Occurred ())
720 else if (args_iter != Py_None
748 struct ui_out *out,
int indent, htab_t levels_printed)
751 CORE_ADDR address = 0;
765 gdb::unique_xmalloc_ptr<char> function_to_free;
776 gdb::optional<enum print_what> user_frame_info_print_what;
779 if (!out->
is_mi_like_p () && user_frame_info_print_what.has_value ())
791 if (py_inf_frame == NULL)
811 gdb::optional<ui_out_emit_tuple> tuple;
816 tuple.emplace (out,
"frame");
827 if (PyObject_HasAttrString (filter,
"address"))
834 if (paddr != Py_None)
861 slot = (
frame_info **) htab_find_slot (levels_printed,
862 frame.
get(), INSERT);
874 *slot = frame.
get ();
886 if (opts.addressprint && has_addr)
902 if (PyObject_HasAttrString (filter,
"function"))
905 const char *function = NULL;
914 if (function_to_free == NULL)
917 function = function_to_free.get ();
919 else if (PyLong_Check (py_func.get ()))
928 if (msymbol.
minsym != NULL)
931 else if (py_func != Py_None)
933 PyErr_SetString (PyExc_RuntimeError,
934 _(
"FrameDecorator.function: expecting a " \
935 "String, integer or None."));
940 if (function == NULL)
957 bool print_location_source
960 if (print_location_source)
964 if (PyObject_HasAttrString (filter,
"filename"))
971 if (py_fn != Py_None)
973 gdb::unique_xmalloc_ptr<char>
976 if (filename == NULL)
988 if (PyObject_HasAttrString (filter,
"line"))
996 if (py_line != Py_None)
998 line = PyLong_AsLong (py_line.get ());
999 if (PyErr_Occurred ())
1017 if (print_location_source)
1046 if (elided != Py_None)
1054 while ((item = PyIter_Next (elided.get ())))
1065 if (item == NULL && PyErr_Occurred ())
1078 int frame_low,
int frame_high)
1081 if (frame_obj == NULL)
1084 gdbpy_ref<> module (PyImport_ImportModule (
"gdb.frames"));
1088 gdbpy_ref<> sort_func (PyObject_GetAttrString (module.get (),
1089 "execute_frame_filters"));
1090 if (sort_func == NULL)
1094 if (py_frame_low == NULL)
1098 if (py_frame_high == NULL)
1101 gdbpy_ref<> iterable (PyObject_CallFunctionObjArgs (sort_func.get (),
1103 py_frame_low.get (),
1104 py_frame_high.get (),
1106 if (iterable == NULL)
1109 if (iterable != Py_None)
1110 return PyObject_GetIter (iterable.get ());
1112 return iterable.release ();
1134 struct ui_out *out,
int frame_low,
int frame_high)
1146 catch (
const gdb_exception_error &except)
1157 int frame_countdown = -1;
1163 frame_countdown = frame_high - frame_low + 1;
1169 if (iterable == NULL)
1191 if (iterable == Py_None)
1194 htab_up levels_printed (htab_create (20,
1205 if (PyErr_Occurred ())
1213 if (frame_countdown != -1)
1217 if (frame_countdown == 0)
1221 gdb_printf (_(
"(More stack frames follow...)\n"));
1229 levels_printed.get ());
1231 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
bool mi_simple_type_p(struct type *type)
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
struct type * type() 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)