26#include "gdbsupport/gdb_regex.h"
56 {
"natural",
"binary",
"decimal",
"hexadecimal",
"octal",
"zero-hexadecimal" };
168 struct value *new_value);
231 if (frame_addr == (CORE_ADDR) 0)
245 if (addr_bit < (
sizeof (CORE_ADDR) * HOST_CHAR_BIT))
246 frame_base &= ((CORE_ADDR) 1 << addr_bit) - 1;
262 auto var = gdb::make_unique<varobj> (
new varobj_root);
321 catch (
const gdb_exception_error &except)
328 if (opcode == OP_TYPE
329 || opcode == OP_TYPEOF
330 || opcode == OP_DECLTYPE)
333 " as an expression.\n");
357 error (_(
"Failed to find the specified frame"));
372 catch (
const gdb_exception_error &except)
376 struct value *type_only_value = var->
root->
exp->evaluate_type ();
378 var->
type = type_only_value->
type ();
383 int real_type_found = 0;
406 if ((var != NULL) && (objname != NULL))
412 return var.release ();
424 return string_printf (
"var%d",
id);
434 htab_hash_string (objname));
437 error (_(
"Variable object not found"));
475 if (val_obj ==
nullptr)
478 return PyObject_CallFunctionObjArgs (constructor, val_obj.get (), NULL);
492 && var->
value !=
nullptr && !var->
value->lazy ())
507gdb::unique_xmalloc_ptr<char>
510 gdb::unique_xmalloc_ptr<char> result;
600 std::vector<varobj *> *changed,
601 std::vector<varobj *> *type_changed,
602 std::vector<varobj *> *newobj,
603 std::vector<varobj *> *unchanged,
615 newobj->push_back (child);
627 if (type_changed != NULL)
628 type_changed->push_back (existing);
632 if (!type_updated && changed != NULL)
633 changed->push_back (existing);
635 else if (!type_updated && unchanged != NULL)
636 unchanged->push_back (existing);
643static std::unique_ptr<varobj_iter>
655 gdb_assert_not_reached (
"requested an iterator from a non-dynamic varobj");
660 std::vector<varobj *> *changed,
661 std::vector<varobj *> *type_changed,
662 std::vector<varobj *> *newobj,
663 std::vector<varobj *> *unchanged,
665 bool update_children,
688 for (;
to < 0 || i <
to + 1; ++i)
690 std::unique_ptr<varobj_item> item;
705 if (
to < 0 || i <
to)
707 bool can_mention = from < 0 || i >=
from;
710 can_mention ? type_changed : NULL,
711 can_mention ? newobj : NULL,
712 can_mention ? unchanged : NULL,
713 can_mention ? cchanged : NULL, i,
729 for (
int j = i; j < var->
children.size (); ++j)
769const std::vector<varobj *> &
776 bool children_changed;
782 &children_changed,
false, 0, *
to);
836 return std::string ();
882 error (_(
"Invalid variable object (child of a dynamic varobj)"));
910 return var->
root->
exp->language_defn;
953 struct value *val = NULL;
963 auto save_input_radix = make_scoped_restore (&
input_radix, 10);
967 value = exp->evaluate ();
970 catch (
const gdb_exception_error &except)
980 gdb_assert (!var->
value->lazy ());
998 catch (
const gdb_exception_error &except)
1034install_default_visualizer (
struct varobj *var)
1044 if (var->
value !=
nullptr)
1047 if (pretty_printer ==
nullptr)
1050 error (_(
"Cannot instantiate printer for default visualizer"));
1054 if (pretty_printer == Py_None)
1055 pretty_printer.reset (
nullptr);
1057 install_visualizer (var->
dynamic, NULL, pretty_printer.release ());
1073 Py_INCREF (constructor);
1074 if (constructor == Py_None)
1075 pretty_printer = NULL;
1078 pretty_printer = instantiate_pretty_printer (constructor,
1080 if (! pretty_printer)
1083 Py_DECREF (constructor);
1084 constructor = Py_None;
1085 Py_INCREF (constructor);
1088 if (pretty_printer == Py_None)
1090 Py_DECREF (pretty_printer);
1091 pretty_printer = NULL;
1095 install_visualizer (var->
dynamic, constructor, pretty_printer);
1117 install_default_visualizer (var);
1139 if (opts.objectprint)
1146 if (curr_type_str != new_type_str)
1180 bool changed =
false;
1181 bool intentionally_not_fetched =
false;
1195 need_to_fetch = changeable;
1203 if (var->
type && var->
type->
code () == TYPE_CODE_UNION)
1213 need_to_fetch =
true;
1233 intentionally_not_fetched =
true;
1243 catch (
const gdb_exception_error &except)
1257 value_holder = value_ref_ptr::new_reference (
value);
1271 if (!initial && changeable)
1293 else if (var->
value == NULL &&
value == NULL)
1296 else if (var->
value == NULL ||
value == NULL)
1302 gdb_assert (!var->
value->lazy ());
1312 if (!initial && !changeable)
1318 changed = (var->
value != NULL) != (
value != NULL);
1322 var->
value = value_holder;
1342 gdb_assert (var->
value ==
nullptr || var->
value->type ());
1379 mainmod = PyImport_AddModule (
"__main__");
1382 gdbpy_ref<> constructor (PyRun_String (visualizer, Py_eval_input,
1383 globals.get (), globals.get ()));
1385 if (constructor == NULL)
1388 error (_(
"Could not evaluate visualizer expression: %s"), visualizer);
1391 construct_visualizer (var, constructor.get ());
1400 error (_(
"Python support required"));
1429 if (new_value != NULL)
1452std::vector<varobj_update_result>
1455 bool type_changed =
false;
1456 struct value *newobj;
1457 std::vector<varobj_update_result>
stack;
1458 std::vector<varobj_update_result> result;
1465 if (!is_explicit && (*varp)->frozen)
1468 if (!(*varp)->root->is_valid)
1474 if ((*varp)->root->rootvar == *varp)
1485 type_changed =
true;
1498 result.push_back (std::move (r));
1503 stack.push_back (std::move (r));
1506 stack.emplace_back (*varp);
1509 while (!
stack.empty ())
1552 std::vector<varobj *> changed, type_changed_vec, unchanged, newobj_vec;
1553 bool children_changed =
false;
1571 &
dummy,
false, 0, 0);
1577 result.push_back (std::move (r));
1586 &unchanged, &children_changed,
1589 if (children_changed || !newobj_vec.empty ())
1592 r.
newobj = std::move (newobj_vec);
1598 for (
int i = type_changed_vec.size () - 1; i >= 0; --i)
1607 stack.push_back (std::move (item));
1609 for (
int i = changed.size () - 1; i >= 0; --i)
1616 stack.push_back (std::move (item));
1618 for (
int i = unchanged.size () - 1; i >= 0; --i)
1620 if (!unchanged[i]->frozen)
1626 stack.push_back (std::move (item));
1630 result.push_back (std::move (r));
1640 for (
int i = v->
children.size () - 1; i >= 0; --i)
1645 if (c != NULL && !c->
frozen)
1646 stack.emplace_back (c);
1650 result.push_back (std::move (r));
1679 bool remove_from_parent_p)
1687 if (!remove_from_parent_p)
1688 child->parent = NULL;
1695 if (only_children_p)
1703 *delcountp = *delcountp + 1;
1711 if ((remove_from_parent_p) && (var->
parent != NULL))
1725 hashval_t hash = htab_hash_string (var->
obj_name.c_str ());
1729 if (*slot !=
nullptr)
1730 error (_(
"Duplicate variable object name"));
1744 hashval_t hash = htab_hash_string (var->
obj_name.c_str ());
1780 std::swap (child->
name, item->
name);
1785 child->
obj_name = string_printf (
"%s.%d_anonymous",
1788 child->
obj_name = string_printf (
"%s.%s",
1790 child->
name.c_str ());
1796 if (item->
value != NULL)
1860 if (var->
value !=
nullptr)
1924 if (pc < var->root->valid_block->start () ||
1935static struct value *
1938 struct value *new_val = NULL;
1939 struct varobj *var = *var_handle;
1940 bool within_scope =
false;
1951 within_scope =
true;
1978 new_val = var->
root->
exp->evaluate ();
1980 catch (
const gdb_exception_error &except)
1997static struct value *
2002 if (var_handle == NULL)
2019 if (tmp_var == NULL)
2042 tmp_var->
to = var->
to;
2046 *var_handle = tmp_var;
2048 *type_changed =
true;
2074 *type_changed =
true;
2081static struct value *
2106 return std::string ();
2114 opts->deref_ref =
false;
2121 const struct varobj *var)
2126 gdb::unique_xmalloc_ptr<char> encoding;
2128 CORE_ADDR str_addr = 0;
2129 bool string_print =
false;
2132 return std::string ();
2135 std::string thevalue;
2146 if (value_formatter)
2150 struct value *replacement;
2158 if (output !=
nullptr && output != Py_None)
2166 &
type, &len, &encoding);
2167 string_print =
true;
2177 gdb::unique_xmalloc_ptr<char> s
2184 gdb::unique_xmalloc_ptr<char> hint
2188 if (!strcmp (hint.get (),
"string"))
2189 string_print =
true;
2192 thevalue = std::string (s.get ());
2193 len = thevalue.size ();
2208 value = replacement;
2228 if (!thevalue.empty ())
2230 len, encoding.get (), 0, &opts);
2231 else if (string_print)
2248 && var->
value->lval ()))
2255 case TYPE_CODE_STRUCT:
2256 case TYPE_CODE_UNION:
2257 case TYPE_CODE_ARRAY:
2258 case TYPE_CODE_FUNC:
2259 case TYPE_CODE_METHOD:
2302 case TYPE_CODE_STRUCT:
2303 case TYPE_CODE_UNION:
2304 case TYPE_CODE_ARRAY:
2327 func ((*self)->rootvar);
2346 if (tmp_var !=
nullptr && tmp_var->
root->
global)
2375 struct objfile *bl_objfile = var->root->valid_block->objfile ();
2376 if (bl_objfile->separate_debug_objfile_backlink != nullptr)
2377 bl_objfile = bl_objfile->separate_debug_objfile_backlink;
2379 if (bl_objfile == objfile)
2385 var->root->is_valid = false;
2386 var->root->valid_block = nullptr;
2397 var->root->exp.reset ();
2400 if (!var->root->floating)
2401 var->root->is_valid = false;
2417 return htab_hash_string (obj->
obj_name.c_str ());
2426 const char *
name = (
const char *) b;
2440 _(
"Set varobj debugging."),
2441 _(
"Show varobj debugging."),
2442 _(
"When non-zero, varobj debugging is enabled."),
static struct @5 attributes[]
void * xcalloc(size_t number, size_t size)
const struct block * get_frame_block(frame_info_ptr frame, CORE_ADDR *addr_in_block)
bool varobj_is_anonymous_child(const struct varobj *child)
gdbpy_enter_varobj(const struct varobj *var)
const struct block * block() const
struct cmd_list_element * showdebuglist
struct cmd_list_element * setdebuglist
set_show_commands add_setshow_zuinteger_cmd(const char *name, enum command_class theclass, unsigned int *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
std::unique_ptr< expression > expression_up
@ INNERMOST_BLOCK_FOR_REGISTERS
@ INNERMOST_BLOCK_FOR_SYMBOLS
expression_up parse_exp_1(const char **, CORE_ADDR pc, const struct block *, parser_flags flags, innermost_block_tracker *=nullptr)
const struct frame_id null_frame_id
void select_frame(frame_info_ptr fi)
CORE_ADDR get_frame_pc(frame_info_ptr frame)
CORE_ADDR get_frame_base_address(frame_info_ptr fi)
bool frame_id_p(frame_id l)
struct gdbarch * get_frame_arch(frame_info_ptr this_frame)
frame_info_ptr get_selected_frame(const char *message)
frame_info_ptr frame_find_by_id(struct frame_id id)
frame_info_ptr get_current_frame(void)
struct frame_id get_frame_id(frame_info_ptr fi)
frame_info_ptr get_prev_frame(frame_info_ptr this_frame)
int gdbarch_addr_bit(struct gdbarch *gdbarch)
struct thread_info * find_thread_global_id(int global_id)
struct thread_info * inferior_thread(void)
void switch_to_thread(struct thread_info *thr)
struct type * get_target_type(struct type *type)
const struct builtin_type * builtin_type(struct gdbarch *gdbarch)
struct type * check_typedef(struct type *type)
#define TYPE_IS_REFERENCE(t)
const struct language_defn * current_language
static struct type * new_type(char *)
observable< struct objfile * > free_objfile
void print_value(value *val, const value_print_options &opts)
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 apply_varobj_pretty_printer(PyObject *printer_obj, struct value **replacement, struct ui_file *stream, const value_print_options *opts)
gdb::unique_xmalloc_ptr< char > gdbpy_get_display_hint(PyObject *printer)
gdbpy_ref gdbpy_get_varobj_pretty_printer(struct value *value)
gdb::ref_ptr< T, gdbpy_ref_policy< T > > gdbpy_ref
gdb::unique_xmalloc_ptr< char > python_string_to_target_string(PyObject *obj)
PyObject * value_to_value_object(struct value *val)
std::unique_ptr< varobj_iter > py_varobj_get_iterator(struct varobj *var, PyObject *printer, const value_print_options *opts)
void gdbpy_print_stack(void)
int gdb_python_initialized
PyObject * gdbpy_children_cst
PyObject * gdbpy_to_string_cst
void(* func)(remote_target *remote, char *)
struct type * builtin_char
std::string(* name_of_child)(const struct varobj *parent, int index)
std::string(* value_of_variable)(const struct varobj *var, enum varobj_display_formats format)
int(* number_of_children)(const struct varobj *parent)
struct type *(* type_of_child)(const struct varobj *parent, int index)
std::string(* path_expr_of_child)(const struct varobj *child)
bool(* value_is_changeable_p)(const struct varobj *var)
bool(* value_has_mutated)(const struct varobj *var, struct value *new_value, struct type *new_type)
bool(* is_path_expr_parent)(const struct varobj *var)
std::string(* name_of_variable)(const struct varobj *parent)
virtual void printstr(struct ui_file *stream, struct type *elttype, const gdb_byte *string, unsigned int length, const char *encoding, int force_ellipses, const struct value_print_options *options) const
struct objfile * separate_debug_objfile_backlink
struct type * type() const
PyObject * pretty_printer
std::unique_ptr< varobj_iter > child_iter
std::unique_ptr< varobj_item > saved_item
const struct language_defn * language_defn
const struct block * valid_block
const struct lang_varobj_ops * lang_ops
enum varobj_scope_status status
std::vector< struct varobj * > newobj
varobj(varobj_root *root_)
enum varobj_display_formats format
struct varobj_dynamic * dynamic
std::vector< varobj * > children
struct varobj_root * root
std::string type_to_string(struct type *type)
void gdb_printf(struct ui_file *stream, const char *format,...)
struct value * value_cast(struct type *type, struct value *arg2)
struct value * value_assign(struct value *toval, struct value *fromval)
void get_formatted_print_options(struct value_print_options *opts, char format)
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)
struct value * coerce_ref(struct value *arg)
struct value * coerce_array(struct value *arg)
struct type * value_actual_type(struct value *value, int resolve_simple_types, int *real_type_found)
value_ref_ptr release_value(struct value *val)
gdb::ref_ptr< struct value, value_ref_policy > value_ref_ptr
static struct value * value_of_root_1(struct varobj **var_handle)
int varobj_get_thread_id(const struct varobj *var)
static bool install_new_value(struct varobj *var, struct value *value, bool initial)
static std::list< struct varobj_root * > rootlist
static struct varobj * varobj_add_child(struct varobj *var, struct varobj_item *item)
static std::unique_ptr< varobj_iter > varobj_get_iterator(struct varobj *var)
static void uninstall_variable(struct varobj *)
static bool update_type_if_necessary(struct varobj *var, struct value *new_value)
static struct value * value_of_root(struct varobj **var_handle, bool *)
enum varobj_display_formats varobj_get_display_format(const struct varobj *var)
static int delete_variable(struct varobj *, bool)
static void install_variable(struct varobj *)
void _initialize_varobj()
static hashval_t hash_varobj(const void *a)
bool varobj_floating_p(const struct varobj *var)
int varobj_get_attributes(const struct varobj *var)
void varobj_enable_pretty_printing(void)
const char * varobj_get_path_expr(const struct varobj *var)
struct varobj * varobj_create(const char *objname, const char *expression, CORE_ADDR frame, enum varobj_type type)
static frame_info_ptr find_frame_addr_in_frame_chain(CORE_ADDR frame_addr)
static bool is_path_expr_parent(const struct varobj *var)
static htab_t varobj_table
void varobj_set_child_range(struct varobj *var, int from, int to)
static struct varobj * create_child_with_value(struct varobj *parent, int index, struct varobj_item *item)
void varobj_get_child_range(const struct varobj *var, int *from, int *to)
struct type * varobj_get_value_type(const struct varobj *var)
const struct varobj * varobj_get_path_expr_parent(const struct varobj *var)
bool varobj_value_is_changeable_p(const struct varobj *var)
bool varobj_editable_p(const struct varobj *var)
static bool check_scope(const struct varobj *var)
static void install_dynamic_child(struct varobj *var, std::vector< varobj * > *changed, std::vector< varobj * > *type_changed, std::vector< varobj * > *newobj, std::vector< varobj * > *unchanged, bool *cchanged, int index, struct varobj_item *item)
static std::string my_value_of_variable(struct varobj *var, enum varobj_display_formats format)
static void delete_variable_1(int *, struct varobj *, bool, bool)
static std::string name_of_child(struct varobj *, int)
static std::string name_of_variable(const struct varobj *)
const std::vector< varobj * > & varobj_list_children(struct varobj *var, int *from, int *to)
std::string varobj_gen_name(void)
const struct language_defn * varobj_get_language(const struct varobj *var)
std::string varobj_get_formatted_value(struct varobj *var, enum varobj_display_formats format)
bool varobj_default_value_is_changeable_p(const struct varobj *var)
static void show_varobjdebug(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
struct type * varobj_get_gdb_type(const struct varobj *var)
static int number_of_children(const struct varobj *)
gdb::unique_xmalloc_ptr< char > varobj_get_display_hint(const struct varobj *var)
const char * varobj_get_objname(const struct varobj *var)
void varobj_set_visualizer(struct varobj *var, const char *visualizer)
static int eq_varobj_and_string(const void *a, const void *b)
bool varobj_default_is_path_expr_parent(const struct varobj *var)
const char * varobj_format_string[]
static struct value * value_of_child(const struct varobj *parent, int index)
void varobj_set_frozen(struct varobj *var, bool frozen)
std::string varobj_get_value(struct varobj *var)
struct varobj * varobj_get_handle(const char *objname)
static void install_new_value_visualizer(struct varobj *var)
void varobj_formatted_print_options(struct value_print_options *opts, enum varobj_display_formats format)
static void varobj_re_set_iter(struct varobj *var)
bool varobj_set_value(struct varobj *var, const char *expression)
static bool pretty_printing
void varobj_restrict_range(const std::vector< varobj * > &children, int *from, int *to)
int varobj_get_num_children(struct varobj *var)
static bool varobj_value_has_mutated(const struct varobj *var, struct value *new_value, struct type *new_type)
bool varobj_get_frozen(const struct varobj *var)
static void varobj_invalidate_if_uses_objfile(struct objfile *objfile)
static bool is_root_p(const struct varobj *var)
bool varobj_is_dynamic_p(const struct varobj *var)
std::string varobj_value_get_print_value(struct value *value, enum varobj_display_formats format, const struct varobj *var)
std::vector< varobj_update_result > varobj_update(struct varobj **varp, bool is_explicit)
std::string varobj_get_type(struct varobj *var)
int varobj_delete(struct varobj *var, bool only_children)
void all_root_varobjs(gdb::function_view< void(struct varobj *var)> func)
bool varobj_has_more(const struct varobj *var, int to)
std::string varobj_get_expression(const struct varobj *var)
enum varobj_display_formats varobj_set_display_format(struct varobj *var, enum varobj_display_formats format)
static bool update_dynamic_varobj_children(struct varobj *var, std::vector< varobj * > *changed, std::vector< varobj * > *type_changed, std::vector< varobj * > *newobj, std::vector< varobj * > *unchanged, bool *cchanged, bool update_children, int from, int to)
static struct varobj * create_child(struct varobj *, int, std::string &)
#define CPLUS_FAKE_CHILD(x)