26#include "gdbsupport/gdb_regex.h"
56 {
"natural",
"binary",
"decimal",
"hexadecimal",
"octal",
"zero-hexadecimal" };
170 struct value *new_value);
233 if (frame_addr == (CORE_ADDR) 0)
247 if (addr_bit < (
sizeof (CORE_ADDR) * HOST_CHAR_BIT))
248 frame_base &= ((CORE_ADDR) 1 << addr_bit) - 1;
297 var->root->floating =
true;
319 var->root->gdbarch = var->root->exp->gdbarch;
320 var->root->language_defn = var->root->exp->language_defn;
323 catch (
const gdb_exception_error &except)
329 enum exp_opcode opcode = var->root->exp->first_opcode ();
330 if (opcode == OP_TYPE
331 || opcode == OP_TYPEOF
332 || opcode == OP_DECLTYPE)
335 " as an expression.\n");
340 var->root->valid_block =
341 var->root->floating ? NULL : tracker.
block ();
343 = var->root->floating ? false : var->root->valid_block ==
nullptr;
352 if (var->root->valid_block)
359 error (_(
"Failed to find the specified frame"));
374 catch (
const gdb_exception_error &except)
385 int real_type_found = 0;
393 var->root->lang_ops = var->root->exp->language_defn->varobj_ops ();
398 var->root->rootvar = var.get ();
408 if ((var != NULL) && (objname != NULL))
410 var->obj_name = objname;
414 return var.release ();
426 return string_printf (
"var%d",
id);
436 htab_hash_string (objname));
439 error (_(
"Variable object not found"));
477 if (val_obj ==
nullptr)
480 return PyObject_CallFunctionObjArgs (constructor, val_obj.get (), NULL);
522gdb::unique_xmalloc_ptr<char>
525 gdb::unique_xmalloc_ptr<char> result;
615 std::vector<varobj *> *changed,
616 std::vector<varobj *> *type_changed,
617 std::vector<varobj *> *newobj,
618 std::vector<varobj *> *unchanged,
630 newobj->push_back (child);
642 if (type_changed != NULL)
643 type_changed->push_back (existing);
647 if (!type_updated && changed != NULL)
648 changed->push_back (existing);
650 else if (!type_updated && unchanged != NULL)
651 unchanged->push_back (existing);
673static std::unique_ptr<varobj_iter>
685 gdb_assert_not_reached (
"requested an iterator from a non-dynamic varobj");
690 std::vector<varobj *> *changed,
691 std::vector<varobj *> *type_changed,
692 std::vector<varobj *> *newobj,
693 std::vector<varobj *> *unchanged,
695 bool update_children,
718 for (;
to < 0 || i <
to + 1; ++i)
720 std::unique_ptr<varobj_item> item;
735 if (
to < 0 || i <
to)
737 bool can_mention = from < 0 || i >=
from;
740 can_mention ? type_changed : NULL,
741 can_mention ? newobj : NULL,
742 can_mention ? unchanged : NULL,
743 can_mention ? cchanged : NULL, i,
759 for (
int j = i; j < var->
children.size (); ++j)
799const std::vector<varobj *> &
806 bool children_changed;
812 &children_changed,
false, 0, *
to);
866 return std::string ();
912 error (_(
"Invalid variable object (child of a dynamic varobj)"));
940 return var->
root->
exp->language_defn;
983 struct value *val = NULL;
1000 catch (
const gdb_exception_error &except)
1028 catch (
const gdb_exception_error &except)
1051 PyObject *visualizer)
1075 if (var->
value !=
nullptr)
1078 if (pretty_printer ==
nullptr)
1081 error (_(
"Cannot instantiate printer for default visualizer"));
1085 if (pretty_printer == Py_None)
1086 pretty_printer.reset (
nullptr);
1098 PyObject *pretty_printer;
1104 Py_INCREF (constructor);
1105 if (constructor == Py_None)
1106 pretty_printer = NULL;
1111 if (! pretty_printer)
1114 Py_DECREF (constructor);
1115 constructor = Py_None;
1116 Py_INCREF (constructor);
1119 if (pretty_printer == Py_None)
1121 Py_DECREF (pretty_printer);
1122 pretty_printer = NULL;
1170 if (opts.objectprint)
1177 if (curr_type_str != new_type_str)
1211 bool changed =
false;
1212 bool intentionally_not_fetched =
false;
1226 need_to_fetch = changeable;
1234 if (var->
type && var->
type->
code () == TYPE_CODE_UNION)
1244 need_to_fetch =
true;
1264 intentionally_not_fetched =
true;
1274 catch (
const gdb_exception_error &except)
1288 value_holder = value_ref_ptr::new_reference (
value);
1302 if (!initial && changeable)
1324 else if (var->
value == NULL &&
value == NULL)
1327 else if (var->
value == NULL ||
value == NULL)
1343 if (!initial && !changeable)
1349 changed = (var->
value != NULL) != (
value != NULL);
1353 var->
value = value_holder;
1410 mainmod = PyImport_AddModule (
"__main__");
1413 gdbpy_ref<> constructor (PyRun_String (visualizer, Py_eval_input,
1414 globals.get (), globals.get ()));
1416 if (constructor == NULL)
1419 error (_(
"Could not evaluate visualizer expression: %s"), visualizer);
1428 error (_(
"Python support required"));
1457 if (new_value != NULL)
1480std::vector<varobj_update_result>
1483 bool type_changed =
false;
1484 struct value *newobj;
1485 std::vector<varobj_update_result>
stack;
1486 std::vector<varobj_update_result> result;
1493 if (!is_explicit && (*varp)->frozen)
1496 if (!(*varp)->root->is_valid)
1502 if ((*varp)->root->rootvar == *varp)
1513 type_changed =
true;
1526 result.push_back (std::move (r));
1531 stack.push_back (std::move (r));
1534 stack.emplace_back (*varp);
1537 while (!
stack.empty ())
1580 std::vector<varobj *> changed, type_changed_vec, unchanged, newobj_vec;
1581 bool children_changed =
false;
1599 &
dummy,
false, 0, 0);
1605 result.push_back (std::move (r));
1614 &unchanged, &children_changed,
1617 if (children_changed || !newobj_vec.empty ())
1620 r.
newobj = std::move (newobj_vec);
1626 for (
int i = type_changed_vec.size () - 1; i >= 0; --i)
1635 stack.push_back (std::move (item));
1637 for (
int i = changed.size () - 1; i >= 0; --i)
1644 stack.push_back (std::move (item));
1646 for (
int i = unchanged.size () - 1; i >= 0; --i)
1648 if (!unchanged[i]->frozen)
1654 stack.push_back (std::move (item));
1658 result.push_back (std::move (r));
1668 for (
int i = v->
children.size () - 1; i >= 0; --i)
1673 if (c != NULL && !c->
frozen)
1674 stack.emplace_back (c);
1678 result.push_back (std::move (r));
1707 bool remove_from_parent_p)
1715 if (!remove_from_parent_p)
1723 if (only_children_p)
1731 *delcountp = *delcountp + 1;
1739 if ((remove_from_parent_p) && (var->
parent != NULL))
1753 hashval_t hash = htab_hash_string (var->
obj_name.c_str ());
1757 if (*slot !=
nullptr)
1758 error (_(
"Duplicate variable object name"));
1772 hashval_t hash = htab_hash_string (var->
obj_name.c_str ());
1808 std::swap (child->
name, item->
name);
1813 child->
obj_name = string_printf (
"%s.%d_anonymous",
1816 child->
obj_name = string_printf (
"%s.%s",
1818 child->
name.c_str ());
1824 if (item->
value != NULL)
1888 if (var->
value !=
nullptr)
1960 if (pc < var->root->valid_block->start () ||
1971static struct value *
1974 struct value *new_val = NULL;
1975 struct varobj *var = *var_handle;
1976 bool within_scope =
false;
1987 within_scope =
true;
2016 catch (
const gdb_exception_error &except)
2033static struct value *
2038 if (var_handle == NULL)
2055 if (tmp_var == NULL)
2078 tmp_var->
to = var->
to;
2082 *var_handle = tmp_var;
2084 *type_changed =
true;
2110 *type_changed =
true;
2117static struct value *
2139 return std::string ();
2147 opts->deref_ref = 0;
2154 const struct varobj *var)
2159 gdb::unique_xmalloc_ptr<char> encoding;
2161 CORE_ADDR str_addr = 0;
2162 bool string_print =
false;
2165 return std::string ();
2168 std::string thevalue;
2179 if (value_formatter)
2188 struct value *replacement;
2204 &
type, &len, &encoding);
2205 string_print =
true;
2215 gdb::unique_xmalloc_ptr<char> s
2222 gdb::unique_xmalloc_ptr<char> hint
2226 if (!strcmp (hint.get (),
"string"))
2227 string_print =
true;
2230 thevalue = std::string (s.get ());
2231 len = thevalue.size ();
2246 value = replacement;
2253 if (!thevalue.empty ())
2255 len, encoding.get (), 0, &opts);
2256 else if (string_print)
2280 case TYPE_CODE_STRUCT:
2281 case TYPE_CODE_UNION:
2282 case TYPE_CODE_ARRAY:
2283 case TYPE_CODE_FUNC:
2284 case TYPE_CODE_METHOD:
2327 case TYPE_CODE_STRUCT:
2328 case TYPE_CODE_UNION:
2329 case TYPE_CODE_ARRAY:
2352 func ((*self)->rootvar);
2371 if (tmp_var !=
nullptr && tmp_var->
root->
global)
2400 struct objfile *bl_objfile = block_objfile (var->root->valid_block);
2401 if (bl_objfile->separate_debug_objfile_backlink != nullptr)
2402 bl_objfile = bl_objfile->separate_debug_objfile_backlink;
2404 if (bl_objfile == objfile)
2410 var->root->is_valid = false;
2411 var->root->valid_block = nullptr;
2423 var->root->exp.reset ();
2426 if (!var->root->floating)
2427 var->root->is_valid = false;
2443 return htab_hash_string (obj->
obj_name.c_str ());
2452 const char *
name = (
const char *) b;
2466 _(
"Set varobj debugging."),
2467 _(
"Show varobj debugging."),
2468 _(
"When non-zero, varobj debugging is enabled."),
static struct @4 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)
struct value * evaluate_expression(struct expression *exp, struct type *expect_type)
struct value * evaluate_type(struct expression *exp)
std::unique_ptr< expression > expression_up
expression_up parse_exp_1(const char **, CORE_ADDR pc, const struct block *, int, innermost_block_tracker *=nullptr)
@ INNERMOST_BLOCK_FOR_REGISTERS
@ INNERMOST_BLOCK_FOR_SYMBOLS
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)
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
bool exp_uses_objfile(struct expression *exp, struct objfile *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
PyObject * pretty_printer
std::unique_ptr< varobj_iter > child_iter
std::unique_ptr< varobj_item > saved_item
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 type * value_type(const struct value *value)
int value_lazy(const struct value *value)
void value_fetch_lazy(struct value *val)
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 void construct_visualizer(struct varobj *var, PyObject *constructor)
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 enum varobj_display_formats variable_default_display(struct varobj *)
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 PyObject * instantiate_pretty_printer(PyObject *constructor, struct value *value)
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
static void install_default_visualizer(struct varobj *var)
static void install_visualizer(struct varobj_dynamic *var, PyObject *constructor, PyObject *visualizer)
void varobj_set_child_range(struct varobj *var, int from, int to)
static bool dynamic_varobj_has_child_method(const struct varobj *var)
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)