2000-02-03 05:14:45 +01:00
|
|
|
|
/* Implementation of the GDB variable objects API.
|
2005-01-14 19:17:20 +01:00
|
|
|
|
|
2006-02-14 20:05:40 +01:00
|
|
|
|
Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
|
2005-07-15 06:12:19 +02:00
|
|
|
|
Free Software Foundation, Inc.
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with this program; if not, write to the Free Software
|
2005-12-17 23:34:03 +01:00
|
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
|
|
Boston, MA 02110-1301, USA. */
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
|
|
|
|
#include "defs.h"
|
2005-02-20 02:19:24 +01:00
|
|
|
|
#include "exceptions.h"
|
2000-02-03 05:14:45 +01:00
|
|
|
|
#include "value.h"
|
|
|
|
|
#include "expression.h"
|
|
|
|
|
#include "frame.h"
|
|
|
|
|
#include "language.h"
|
|
|
|
|
#include "wrapper.h"
|
|
|
|
|
#include "gdbcmd.h"
|
2005-02-20 02:19:24 +01:00
|
|
|
|
|
|
|
|
|
#include "gdb_assert.h"
|
2002-08-02 22:51:21 +02:00
|
|
|
|
#include "gdb_string.h"
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
|
|
|
|
#include "varobj.h"
|
|
|
|
|
|
|
|
|
|
/* Non-zero if we want to see trace of varobj level stuff. */
|
|
|
|
|
|
|
|
|
|
int varobjdebug = 0;
|
2005-02-24 Andrew Cagney <cagney@gnu.org>
Add show_VARIABLE functions, update add_setshow call.
* varobj.c (_initialize_varobj, show_varobjdebug): Add and update.
* valprint.c (_initialize_valprint, show_print_max)
(show_stop_print_at_null, show_repeat_count_threshold)
(show_prettyprint_structs, show_unionprint)
(show_prettyprint_arrays, show_addressprint, show_input_radix)
(show_output_radix): Ditto.
* valops.c (_initialize_valops, show_overload_resolution): Ditto.
* utils.c (initialize_utils, show_chars_per_line)
(show_lines_per_page, show_demangle, show_pagination_enabled)
(show_sevenbit_strings, show_asm_demangle): Ditto
* tui/tui-win.c (_initialize_tui_win, show_tui_border_kind)
(show_tui_border_mode, show_tui_active_border_mode): Ditto.
* top.c (init_main, show_new_async_prompt)
(show_async_command_editing_p, show_write_history_p)
(show_history_size, show_history_filename, show_caution)
(show_annotation_level, init_main): Ditto.
* target.c (initialize_targets, show_targetdebug)
(show_trust_readonly): Ditto.
* symfile.c (_initialize_symfile, show_symbol_reloading)
(show_ext_args, show_download_write_size)
(show_debug_file_directory): Ditto.
* source.c (_initialize_source, show_lines_to_list): Ditto.
* solib.c (_initialize_solib, show_auto_solib_add)
(show_solib_search_path): Ditto.
* p-valprint.c (_initialize_pascal_valprint)
(show_pascal_static_field_print): Ditto.
* printcmd.c (_initialize_printcmd, show_max_symbolic_offset)
(show_print_symbol_filename): Add and update.
* parse.c (_initialize_parse, show_expressiondebug): Dito.
* observer.c (_initialize_observer, show_observer_debug): Dito.
* maint.c (_initialize_maint_cmds, show_watchdog)
(show_maintenance_profile_p): Dito.
* linux-nat.c (_initialize_linux_nat, show_debug_linux_nat): Dito.
* infrun.c (_initialize_infrun, show_debug_infrun)
(show_stop_on_solib_events, show_follow_fork_mode_string)
(show_scheduler_mode, show_step_stop_if_no_debug): Ditto.
* infcall.c (_initialize_infcall, show_coerce_float_to_double_p)
(show_unwind_on_signal_p): Ditto.
* gdbtypes.c (build_gdbtypes, show_opaque_type_resolution)
(_initialize_gdbtypes, show_overload_debug): Ditto.
* gdb-events.c, gdb-events.sh (_initialize_gdb_events)
(show_gdb_events_debug): Ditto.
* gdbarch.c, gdbarch.sh (show_gdbarch_debug)
(_initialize_gdbarch): Ditto.
* frame.c (_initialize_frame, show_backtrace_past_main)
(show_backtrace_past_entry, show_backtrace_limit)
(show_frame_debug): Ditto.
* exec.c (_initialize_exec, show_write_files): Ditto.
* dwarf2read.c (_initialize_dwarf2_read)
(show_dwarf2_max_cache_age): Ditto.
* demangle.c (_initialize_demangler)
(show_demangling_style_names): Ditto.
* dcache.c (_initialize_dcache, show_dcache_enabled_p): Ditto.
* cp-valprint.c (show_static_field_print)
(_initialize_cp_valprint, show_vtblprint, show_objectprint): Ditto.
* corefile.c (_initialize_core, show_gnutarget_string): Ditto.
* cli/cli-logging.c (_initialize_cli_logging)
(show_logging_overwrite, show_logging_redirect)
(show_logging_filename): Ditto.
* cli/cli-cmds.c (show_info_verbose, show_history_expansion_p)
(init_cli_cmds, show_baud_rate, show_remote_debug)
(show_remote_timeout, show_max_user_call_depth): Ditto.
* charset.c (show_host_charset_name, show_target_charset_name)
(initialize_charset): Ditto.
* breakpoint.c (show_can_use_hw_watchpoints)
(show_pending_break_support, _initialize_breakpoint): Ditto.
2005-02-24 14:51:36 +01:00
|
|
|
|
static void
|
|
|
|
|
show_varobjdebug (struct ui_file *file, int from_tty,
|
|
|
|
|
struct cmd_list_element *c, const char *value)
|
|
|
|
|
{
|
|
|
|
|
fprintf_filtered (file, _("Varobj debugging is %s.\n"), value);
|
|
|
|
|
}
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
|
|
|
|
/* String representations of gdb's format codes */
|
|
|
|
|
char *varobj_format_string[] =
|
2001-11-01 03:22:21 +01:00
|
|
|
|
{ "natural", "binary", "decimal", "hexadecimal", "octal" };
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
|
|
|
|
/* String representations of gdb's known languages */
|
2001-11-01 03:22:21 +01:00
|
|
|
|
char *varobj_language_string[] = { "unknown", "C", "C++", "Java" };
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
|
|
|
|
/* Data structures */
|
|
|
|
|
|
|
|
|
|
/* Every root variable has one of these structures saved in its
|
|
|
|
|
varobj. Members which must be free'd are noted. */
|
|
|
|
|
struct varobj_root
|
2001-11-01 03:22:21 +01:00
|
|
|
|
{
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
2001-11-01 03:22:21 +01:00
|
|
|
|
/* Alloc'd expression for this parent. */
|
|
|
|
|
struct expression *exp;
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
2001-11-01 03:22:21 +01:00
|
|
|
|
/* Block for which this expression is valid */
|
|
|
|
|
struct block *valid_block;
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
2001-11-01 03:22:21 +01:00
|
|
|
|
/* The frame for this expression */
|
2002-07-03 22:23:04 +02:00
|
|
|
|
struct frame_id frame;
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
2001-11-01 03:22:21 +01:00
|
|
|
|
/* If 1, "update" always recomputes the frame & valid block
|
|
|
|
|
using the currently selected frame. */
|
|
|
|
|
int use_selected_frame;
|
2000-03-13 22:51:46 +01:00
|
|
|
|
|
2001-11-01 03:22:21 +01:00
|
|
|
|
/* Language info for this variable and its children */
|
|
|
|
|
struct language_specific *lang;
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
2001-11-01 03:22:21 +01:00
|
|
|
|
/* The varobj for this root node. */
|
|
|
|
|
struct varobj *rootvar;
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
2001-11-01 03:22:21 +01:00
|
|
|
|
/* Next root variable */
|
|
|
|
|
struct varobj_root *next;
|
|
|
|
|
};
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
|
|
|
|
/* Every variable in the system has a structure of this type defined
|
|
|
|
|
for it. This structure holds all information necessary to manipulate
|
|
|
|
|
a particular object variable. Members which must be freed are noted. */
|
|
|
|
|
struct varobj
|
2001-11-01 03:22:21 +01:00
|
|
|
|
{
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
2001-11-01 03:22:21 +01:00
|
|
|
|
/* Alloc'd name of the variable for this object.. If this variable is a
|
|
|
|
|
child, then this name will be the child's source name.
|
|
|
|
|
(bar, not foo.bar) */
|
|
|
|
|
/* NOTE: This is the "expression" */
|
|
|
|
|
char *name;
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
2001-11-01 03:22:21 +01:00
|
|
|
|
/* The alloc'd name for this variable's object. This is here for
|
|
|
|
|
convenience when constructing this object's children. */
|
|
|
|
|
char *obj_name;
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
2001-11-01 03:22:21 +01:00
|
|
|
|
/* Index of this variable in its parent or -1 */
|
|
|
|
|
int index;
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
2001-11-01 03:22:21 +01:00
|
|
|
|
/* The type of this variable. This may NEVER be NULL. */
|
|
|
|
|
struct type *type;
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
2001-11-01 03:22:21 +01:00
|
|
|
|
/* The value of this expression or subexpression. This may be NULL. */
|
2001-11-01 03:37:56 +01:00
|
|
|
|
struct value *value;
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
2001-11-01 03:22:21 +01:00
|
|
|
|
/* Did an error occur evaluating the expression or getting its value? */
|
|
|
|
|
int error;
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
2001-11-01 03:22:21 +01:00
|
|
|
|
/* The number of (immediate) children this variable has */
|
|
|
|
|
int num_children;
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
2001-11-01 03:22:21 +01:00
|
|
|
|
/* If this object is a child, this points to its immediate parent. */
|
|
|
|
|
struct varobj *parent;
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
2001-11-01 03:22:21 +01:00
|
|
|
|
/* A list of this object's children */
|
|
|
|
|
struct varobj_child *children;
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
2001-11-01 03:22:21 +01:00
|
|
|
|
/* Description of the root variable. Points to root variable for children. */
|
|
|
|
|
struct varobj_root *root;
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
2001-11-01 03:22:21 +01:00
|
|
|
|
/* The format of the output for this object */
|
|
|
|
|
enum varobj_display_formats format;
|
2002-10-24 01:54:33 +02:00
|
|
|
|
|
|
|
|
|
/* Was this variable updated via a varobj_set_value operation */
|
|
|
|
|
int updated;
|
2001-11-01 03:22:21 +01:00
|
|
|
|
};
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
|
|
|
|
/* Every variable keeps a linked list of its children, described
|
|
|
|
|
by the following structure. */
|
|
|
|
|
/* FIXME: Deprecated. All should use vlist instead */
|
|
|
|
|
|
|
|
|
|
struct varobj_child
|
2001-11-01 03:22:21 +01:00
|
|
|
|
{
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
2001-11-01 03:22:21 +01:00
|
|
|
|
/* Pointer to the child's data */
|
|
|
|
|
struct varobj *child;
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
2001-11-01 03:22:21 +01:00
|
|
|
|
/* Pointer to the next child */
|
|
|
|
|
struct varobj_child *next;
|
|
|
|
|
};
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
|
|
|
|
/* A stack of varobjs */
|
|
|
|
|
/* FIXME: Deprecated. All should use vlist instead */
|
|
|
|
|
|
|
|
|
|
struct vstack
|
2001-11-01 03:22:21 +01:00
|
|
|
|
{
|
|
|
|
|
struct varobj *var;
|
|
|
|
|
struct vstack *next;
|
|
|
|
|
};
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
|
|
|
|
struct cpstack
|
2001-11-01 03:22:21 +01:00
|
|
|
|
{
|
|
|
|
|
char *name;
|
|
|
|
|
struct cpstack *next;
|
|
|
|
|
};
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
|
|
|
|
/* A list of varobjs */
|
|
|
|
|
|
|
|
|
|
struct vlist
|
2001-11-01 03:22:21 +01:00
|
|
|
|
{
|
|
|
|
|
struct varobj *var;
|
|
|
|
|
struct vlist *next;
|
|
|
|
|
};
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
|
|
|
|
/* Private function prototypes */
|
|
|
|
|
|
|
|
|
|
/* Helper functions for the above subcommands. */
|
|
|
|
|
|
2000-05-28 03:12:42 +02:00
|
|
|
|
static int delete_variable (struct cpstack **, struct varobj *, int);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
2000-05-28 03:12:42 +02:00
|
|
|
|
static void delete_variable_1 (struct cpstack **, int *,
|
|
|
|
|
struct varobj *, int, int);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
2000-05-28 03:12:42 +02:00
|
|
|
|
static int install_variable (struct varobj *);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
2000-05-28 03:12:42 +02:00
|
|
|
|
static void uninstall_variable (struct varobj *);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
2000-05-28 03:12:42 +02:00
|
|
|
|
static struct varobj *child_exists (struct varobj *, char *);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
2000-05-28 03:12:42 +02:00
|
|
|
|
static struct varobj *create_child (struct varobj *, int, char *);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
2000-05-28 03:12:42 +02:00
|
|
|
|
static void save_child_in_parent (struct varobj *, struct varobj *);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
2000-05-28 03:12:42 +02:00
|
|
|
|
static void remove_child_from_parent (struct varobj *, struct varobj *);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
|
|
|
|
/* Utility routines */
|
|
|
|
|
|
2000-05-28 03:12:42 +02:00
|
|
|
|
static struct varobj *new_variable (void);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
2000-05-28 03:12:42 +02:00
|
|
|
|
static struct varobj *new_root_variable (void);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
2000-05-28 03:12:42 +02:00
|
|
|
|
static void free_variable (struct varobj *var);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
2000-05-22 11:02:23 +02:00
|
|
|
|
static struct cleanup *make_cleanup_free_variable (struct varobj *var);
|
|
|
|
|
|
2000-05-28 03:12:42 +02:00
|
|
|
|
static struct type *get_type (struct varobj *var);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
2000-05-28 03:12:42 +02:00
|
|
|
|
static struct type *get_type_deref (struct varobj *var);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
2000-05-28 03:12:42 +02:00
|
|
|
|
static struct type *get_target_type (struct type *);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
2000-05-28 03:12:42 +02:00
|
|
|
|
static enum varobj_display_formats variable_default_display (struct varobj *);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
2001-11-01 03:37:56 +01:00
|
|
|
|
static int my_value_equal (struct value *, struct value *, int *);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
2000-05-28 03:12:42 +02:00
|
|
|
|
static void vpush (struct vstack **pstack, struct varobj *var);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
2000-05-28 03:12:42 +02:00
|
|
|
|
static struct varobj *vpop (struct vstack **pstack);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
2000-05-28 03:12:42 +02:00
|
|
|
|
static void cppush (struct cpstack **pstack, char *name);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
2000-05-28 03:12:42 +02:00
|
|
|
|
static char *cppop (struct cpstack **pstack);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
|
|
|
|
/* Language-specific routines. */
|
|
|
|
|
|
2000-05-28 03:12:42 +02:00
|
|
|
|
static enum varobj_languages variable_language (struct varobj *var);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
2000-05-28 03:12:42 +02:00
|
|
|
|
static int number_of_children (struct varobj *);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
2000-05-28 03:12:42 +02:00
|
|
|
|
static char *name_of_variable (struct varobj *);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
2000-05-28 03:12:42 +02:00
|
|
|
|
static char *name_of_child (struct varobj *, int);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
2001-11-01 03:37:56 +01:00
|
|
|
|
static struct value *value_of_root (struct varobj **var_handle, int *);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
2001-11-01 03:37:56 +01:00
|
|
|
|
static struct value *value_of_child (struct varobj *parent, int index);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
2000-05-28 03:12:42 +02:00
|
|
|
|
static struct type *type_of_child (struct varobj *var);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
2000-05-28 03:12:42 +02:00
|
|
|
|
static int variable_editable (struct varobj *var);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
2000-05-28 03:12:42 +02:00
|
|
|
|
static char *my_value_of_variable (struct varobj *var);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
2000-05-28 03:12:42 +02:00
|
|
|
|
static int type_changeable (struct varobj *var);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
|
|
|
|
/* C implementation */
|
|
|
|
|
|
2000-05-28 03:12:42 +02:00
|
|
|
|
static int c_number_of_children (struct varobj *var);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
2000-05-28 03:12:42 +02:00
|
|
|
|
static char *c_name_of_variable (struct varobj *parent);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
2000-05-28 03:12:42 +02:00
|
|
|
|
static char *c_name_of_child (struct varobj *parent, int index);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
2001-11-01 03:37:56 +01:00
|
|
|
|
static struct value *c_value_of_root (struct varobj **var_handle);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
2001-11-01 03:37:56 +01:00
|
|
|
|
static struct value *c_value_of_child (struct varobj *parent, int index);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
2000-05-28 03:12:42 +02:00
|
|
|
|
static struct type *c_type_of_child (struct varobj *parent, int index);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
2000-05-28 03:12:42 +02:00
|
|
|
|
static int c_variable_editable (struct varobj *var);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
2000-05-28 03:12:42 +02:00
|
|
|
|
static char *c_value_of_variable (struct varobj *var);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
|
|
|
|
/* C++ implementation */
|
|
|
|
|
|
2000-05-28 03:12:42 +02:00
|
|
|
|
static int cplus_number_of_children (struct varobj *var);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
2000-05-28 03:12:42 +02:00
|
|
|
|
static void cplus_class_num_children (struct type *type, int children[3]);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
2000-05-28 03:12:42 +02:00
|
|
|
|
static char *cplus_name_of_variable (struct varobj *parent);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
2000-05-28 03:12:42 +02:00
|
|
|
|
static char *cplus_name_of_child (struct varobj *parent, int index);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
2001-11-01 03:37:56 +01:00
|
|
|
|
static struct value *cplus_value_of_root (struct varobj **var_handle);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
2001-11-01 03:37:56 +01:00
|
|
|
|
static struct value *cplus_value_of_child (struct varobj *parent, int index);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
2000-05-28 03:12:42 +02:00
|
|
|
|
static struct type *cplus_type_of_child (struct varobj *parent, int index);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
2000-05-28 03:12:42 +02:00
|
|
|
|
static int cplus_variable_editable (struct varobj *var);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
2000-05-28 03:12:42 +02:00
|
|
|
|
static char *cplus_value_of_variable (struct varobj *var);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
|
|
|
|
/* Java implementation */
|
|
|
|
|
|
2000-05-28 03:12:42 +02:00
|
|
|
|
static int java_number_of_children (struct varobj *var);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
2000-05-28 03:12:42 +02:00
|
|
|
|
static char *java_name_of_variable (struct varobj *parent);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
2000-05-28 03:12:42 +02:00
|
|
|
|
static char *java_name_of_child (struct varobj *parent, int index);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
2001-11-01 03:37:56 +01:00
|
|
|
|
static struct value *java_value_of_root (struct varobj **var_handle);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
2001-11-01 03:37:56 +01:00
|
|
|
|
static struct value *java_value_of_child (struct varobj *parent, int index);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
2000-05-28 03:12:42 +02:00
|
|
|
|
static struct type *java_type_of_child (struct varobj *parent, int index);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
2000-05-28 03:12:42 +02:00
|
|
|
|
static int java_variable_editable (struct varobj *var);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
2000-05-28 03:12:42 +02:00
|
|
|
|
static char *java_value_of_variable (struct varobj *var);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
|
|
|
|
/* The language specific vector */
|
|
|
|
|
|
|
|
|
|
struct language_specific
|
2001-11-01 03:22:21 +01:00
|
|
|
|
{
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
2001-11-01 03:22:21 +01:00
|
|
|
|
/* The language of this variable */
|
|
|
|
|
enum varobj_languages language;
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
2001-11-01 03:22:21 +01:00
|
|
|
|
/* The number of children of PARENT. */
|
|
|
|
|
int (*number_of_children) (struct varobj * parent);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
2001-11-01 03:22:21 +01:00
|
|
|
|
/* The name (expression) of a root varobj. */
|
|
|
|
|
char *(*name_of_variable) (struct varobj * parent);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
2001-11-01 03:22:21 +01:00
|
|
|
|
/* The name of the INDEX'th child of PARENT. */
|
|
|
|
|
char *(*name_of_child) (struct varobj * parent, int index);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
2001-11-01 03:37:56 +01:00
|
|
|
|
/* The ``struct value *'' of the root variable ROOT. */
|
|
|
|
|
struct value *(*value_of_root) (struct varobj ** root_handle);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
2001-11-01 03:37:56 +01:00
|
|
|
|
/* The ``struct value *'' of the INDEX'th child of PARENT. */
|
|
|
|
|
struct value *(*value_of_child) (struct varobj * parent, int index);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
2001-11-01 03:22:21 +01:00
|
|
|
|
/* The type of the INDEX'th child of PARENT. */
|
|
|
|
|
struct type *(*type_of_child) (struct varobj * parent, int index);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
2001-11-01 03:22:21 +01:00
|
|
|
|
/* Is VAR editable? */
|
|
|
|
|
int (*variable_editable) (struct varobj * var);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
2001-11-01 03:22:21 +01:00
|
|
|
|
/* The current value of VAR. */
|
|
|
|
|
char *(*value_of_variable) (struct varobj * var);
|
|
|
|
|
};
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
|
|
|
|
/* Array of known source language routines. */
|
|
|
|
|
static struct language_specific
|
2001-11-01 03:22:21 +01:00
|
|
|
|
languages[vlang_end][sizeof (struct language_specific)] = {
|
2000-02-03 05:14:45 +01:00
|
|
|
|
/* Unknown (try treating as C */
|
|
|
|
|
{
|
2001-11-01 03:22:21 +01:00
|
|
|
|
vlang_unknown,
|
|
|
|
|
c_number_of_children,
|
|
|
|
|
c_name_of_variable,
|
|
|
|
|
c_name_of_child,
|
|
|
|
|
c_value_of_root,
|
|
|
|
|
c_value_of_child,
|
|
|
|
|
c_type_of_child,
|
|
|
|
|
c_variable_editable,
|
|
|
|
|
c_value_of_variable}
|
2000-02-03 05:14:45 +01:00
|
|
|
|
,
|
|
|
|
|
/* C */
|
|
|
|
|
{
|
2001-11-01 03:22:21 +01:00
|
|
|
|
vlang_c,
|
|
|
|
|
c_number_of_children,
|
|
|
|
|
c_name_of_variable,
|
|
|
|
|
c_name_of_child,
|
|
|
|
|
c_value_of_root,
|
|
|
|
|
c_value_of_child,
|
|
|
|
|
c_type_of_child,
|
|
|
|
|
c_variable_editable,
|
|
|
|
|
c_value_of_variable}
|
2000-02-03 05:14:45 +01:00
|
|
|
|
,
|
|
|
|
|
/* C++ */
|
|
|
|
|
{
|
2001-11-01 03:22:21 +01:00
|
|
|
|
vlang_cplus,
|
|
|
|
|
cplus_number_of_children,
|
|
|
|
|
cplus_name_of_variable,
|
|
|
|
|
cplus_name_of_child,
|
|
|
|
|
cplus_value_of_root,
|
|
|
|
|
cplus_value_of_child,
|
|
|
|
|
cplus_type_of_child,
|
|
|
|
|
cplus_variable_editable,
|
|
|
|
|
cplus_value_of_variable}
|
2000-02-03 05:14:45 +01:00
|
|
|
|
,
|
|
|
|
|
/* Java */
|
|
|
|
|
{
|
2001-11-01 03:22:21 +01:00
|
|
|
|
vlang_java,
|
|
|
|
|
java_number_of_children,
|
|
|
|
|
java_name_of_variable,
|
|
|
|
|
java_name_of_child,
|
|
|
|
|
java_value_of_root,
|
|
|
|
|
java_value_of_child,
|
|
|
|
|
java_type_of_child,
|
|
|
|
|
java_variable_editable,
|
|
|
|
|
java_value_of_variable}
|
2000-02-03 05:14:45 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* A little convenience enum for dealing with C++/Java */
|
|
|
|
|
enum vsections
|
2001-11-01 03:22:21 +01:00
|
|
|
|
{
|
|
|
|
|
v_public = 0, v_private, v_protected
|
|
|
|
|
};
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
|
|
|
|
/* Private data */
|
|
|
|
|
|
|
|
|
|
/* Mappings of varobj_display_formats enums to gdb's format codes */
|
2001-11-01 03:22:21 +01:00
|
|
|
|
static int format_code[] = { 0, 't', 'd', 'x', 'o' };
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
|
|
|
|
/* Header of the list of root variable objects */
|
|
|
|
|
static struct varobj_root *rootlist;
|
|
|
|
|
static int rootcount = 0; /* number of root varobjs in the list */
|
|
|
|
|
|
|
|
|
|
/* Prime number indicating the number of buckets in the hash table */
|
|
|
|
|
/* A prime large enough to avoid too many colisions */
|
|
|
|
|
#define VAROBJ_TABLE_SIZE 227
|
|
|
|
|
|
|
|
|
|
/* Pointer to the varobj hash table (built at run time) */
|
|
|
|
|
static struct vlist **varobj_table;
|
|
|
|
|
|
|
|
|
|
/* Is the variable X one of our "fake" children? */
|
|
|
|
|
#define CPLUS_FAKE_CHILD(x) \
|
|
|
|
|
((x) != NULL && (x)->type == NULL && (x)->value == NULL)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* API Implementation */
|
|
|
|
|
|
|
|
|
|
/* Creates a varobj (not its children) */
|
|
|
|
|
|
2002-11-24 15:16:38 +01:00
|
|
|
|
/* Return the full FRAME which corresponds to the given CORE_ADDR
|
|
|
|
|
or NULL if no FRAME on the chain corresponds to CORE_ADDR. */
|
|
|
|
|
|
|
|
|
|
static struct frame_info *
|
|
|
|
|
find_frame_addr_in_frame_chain (CORE_ADDR frame_addr)
|
|
|
|
|
{
|
|
|
|
|
struct frame_info *frame = NULL;
|
|
|
|
|
|
|
|
|
|
if (frame_addr == (CORE_ADDR) 0)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
while (1)
|
|
|
|
|
{
|
|
|
|
|
frame = get_prev_frame (frame);
|
|
|
|
|
if (frame == NULL)
|
|
|
|
|
return NULL;
|
* arm-tdep.c: Include frame-unwind.h, frame-base.h, and
trad-frame.h.
(arm_get_cache): Delete macro.
(struct arm_prologue_cache): Update comments. Make saved_regs into
a trad_frame_saved_reg pointer. Remove unwound_pc; rename unwound_sp
to prev_sp.
(thumb_scan_prologue): Update for cache changes. Don't call
DEPRECATED_PC_IN_CALL_DUMMY.
(arm_scan_prologue): Update for cache changes. Take NEXT_FRAME
argument and use it in desperation search for our prologue. Do not
search past the specified PC.
(arm_make_prologue_cache): Simplify.
(arm_prologue_this_id, arm_prologue_prev_register)
(arm_prologue_unwind, arm_prologue_unwind_sniffer)
(arm_normal_frame_base, arm_normal_base, arm_make_sigtramp_cache)
(arm_sigtramp_this_id, arm_sigtramp_prev_register)
(arm_sigtramp_unwind, arm_sigtramp_unwind_sniffer)
(arm_unwind_dummy_id, arm_unwind_pc, arm_unwind_sp): New.
(arm_frame_chain_valid, arm_find_callers_reg)
(arm_frame_saved_pc, arm_read_fp, arm_frame_init_saved_regs)
(arm_pop_frame): Delete obsolete methods.
(arm_minimal_frame_chain, arm_minimal_frame_info): Delete.
(arm_gdbarch_init): Update for new frame methods. Register prologue
and sigtramp unwinders. Set the default frame base method.
* Makefile.in (arm-tdep.o): Update dependencies.
* varobj.c (find_frame_addr_in_frame_chain): Call
get_frame_base_address.
* std-regs.c (value_of_builtin_frame_fp_reg): Likewise.
2003-09-03 22:46:02 +02:00
|
|
|
|
if (get_frame_base_address (frame) == frame_addr)
|
2002-11-24 15:16:38 +01:00
|
|
|
|
return frame;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2000-02-03 05:14:45 +01:00
|
|
|
|
struct varobj *
|
|
|
|
|
varobj_create (char *objname,
|
2001-11-01 03:22:21 +01:00
|
|
|
|
char *expression, CORE_ADDR frame, enum varobj_type type)
|
2000-02-03 05:14:45 +01:00
|
|
|
|
{
|
|
|
|
|
struct varobj *var;
|
2000-11-29 15:41:34 +01:00
|
|
|
|
struct frame_info *fi;
|
|
|
|
|
struct frame_info *old_fi = NULL;
|
2000-02-03 05:14:45 +01:00
|
|
|
|
struct block *block;
|
|
|
|
|
struct cleanup *old_chain;
|
|
|
|
|
|
|
|
|
|
/* Fill out a varobj structure for the (root) variable being constructed. */
|
|
|
|
|
var = new_root_variable ();
|
2000-05-22 11:02:23 +02:00
|
|
|
|
old_chain = make_cleanup_free_variable (var);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
|
|
|
|
if (expression != NULL)
|
|
|
|
|
{
|
|
|
|
|
char *p;
|
|
|
|
|
enum varobj_languages lang;
|
|
|
|
|
|
|
|
|
|
/* Parse and evaluate the expression, filling in as much
|
|
|
|
|
of the variable's data as possible */
|
|
|
|
|
|
|
|
|
|
/* Allow creator to specify context of variable */
|
2001-11-01 03:22:21 +01:00
|
|
|
|
if ((type == USE_CURRENT_FRAME) || (type == USE_SELECTED_FRAME))
|
2002-11-29 Andrew Cagney <ac131313@redhat.com>
* stack.c (selected_frame, select_frame): Move from here ...
* frame.c (selected_frame, select_frame): ... to here. Include
"language.h".
* Makefile.in (frame.o): Update dependencies.
* frame.c (get_selected_frame): New function.
* frame.h (get_selected_frame): Declare.
(deprecated_selected_frame): Rename selected_frame.
* ada-lang.c, ada-tasks.c, breakpoint.c, corelow.c: Update.
* eval.c, f-valprint.c, findvar.c, frame.c, frame.h: Update.
* h8300-tdep.c, h8500-tdep.c, hppa-tdep.c, infcmd.c: Update.
* inflow.c, infrun.c, macroscope.c, mips-tdep.c: Update.
* mn10300-tdep.c, ocd.c, regcache.h, remote-e7000.c: Update.
* remote-mips.c, remote-rdp.c, sh-tdep.c, sparc-tdep.c: Update.
* stack.c, thread.c, tracepoint.c, valops.c, varobj.c: Update.
* z8k-tdep.c, cli/cli-cmds.c: Update.
Index: mi/ChangeLog
2002-11-29 Andrew Cagney <ac131313@redhat.com>
* mi/mi-cmd-stack.c, mi/mi-main.c: Update to use
deprecated_selected_frame.
Index: tui/ChangeLog
2002-11-29 Andrew Cagney <ac131313@redhat.com>
* tui/tui-hooks.c: Update to use deprecated_selected_frame.
* tui/tui.c, tui/tuiDisassem.c, tui/tuiRegs.c: Ditto.
* tui/tuiSource.c, tui/tuiSourceWin.c, tui/tuiWin.c: Ditto.
2002-11-29 20:15:16 +01:00
|
|
|
|
fi = deprecated_selected_frame;
|
2000-02-03 05:14:45 +01:00
|
|
|
|
else
|
2002-11-24 15:16:38 +01:00
|
|
|
|
/* FIXME: cagney/2002-11-23: This code should be doing a
|
|
|
|
|
lookup using the frame ID and not just the frame's
|
|
|
|
|
``address''. This, of course, means an interface change.
|
|
|
|
|
However, with out that interface change ISAs, such as the
|
|
|
|
|
ia64 with its two stacks, won't work. Similar goes for the
|
|
|
|
|
case where there is a frameless function. */
|
2000-02-03 05:14:45 +01:00
|
|
|
|
fi = find_frame_addr_in_frame_chain (frame);
|
|
|
|
|
|
2000-03-13 22:51:46 +01:00
|
|
|
|
/* frame = -2 means always use selected frame */
|
|
|
|
|
if (type == USE_SELECTED_FRAME)
|
|
|
|
|
var->root->use_selected_frame = 1;
|
|
|
|
|
|
2000-02-03 05:14:45 +01:00
|
|
|
|
block = NULL;
|
|
|
|
|
if (fi != NULL)
|
gdb/ChangeLog:
* stack.c (get_selected_block): Add new argument `addr_in_block',
used to return the exact code address we used to select the block,
not just the block.
* blockframe.c (get_frame_block, get_current_block): Same.
* frame.h (get_frame_block, get_current_block,
get_selected_block): Update declarations.
* linespec.c, stack.c, blockframe.c, breakpoint.c, findvar.c,
linespec.c, varobj.c, printcmd.c, symtab.c: Callers changed.
gdb/mi/ChangeLog:
* mi-cmd-stack.c (list_args_or_locals): Pass new arg to
get_frame_block. (See entry in gdb/ChangeLog.)
2002-04-06 00:04:43 +02:00
|
|
|
|
block = get_frame_block (fi, 0);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
|
|
|
|
p = expression;
|
|
|
|
|
innermost_block = NULL;
|
2000-03-13 22:51:46 +01:00
|
|
|
|
/* Wrap the call to parse expression, so we can
|
|
|
|
|
return a sensible error. */
|
|
|
|
|
if (!gdb_parse_exp_1 (&p, block, 0, &var->root->exp))
|
|
|
|
|
{
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
|
|
|
|
/* Don't allow variables to be created for types. */
|
|
|
|
|
if (var->root->exp->elts[0].opcode == OP_TYPE)
|
|
|
|
|
{
|
|
|
|
|
do_cleanups (old_chain);
|
2005-01-14 19:17:20 +01:00
|
|
|
|
fprintf_unfiltered (gdb_stderr, "Attempt to use a type name"
|
|
|
|
|
" as an expression.\n");
|
2000-02-03 05:14:45 +01:00
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var->format = variable_default_display (var);
|
|
|
|
|
var->root->valid_block = innermost_block;
|
|
|
|
|
var->name = savestring (expression, strlen (expression));
|
|
|
|
|
|
|
|
|
|
/* When the frame is different from the current frame,
|
|
|
|
|
we must select the appropriate frame before parsing
|
|
|
|
|
the expression, otherwise the value will not be current.
|
|
|
|
|
Since select_frame is so benign, just call it for all cases. */
|
|
|
|
|
if (fi != NULL)
|
|
|
|
|
{
|
2002-12-04 01:05:54 +01:00
|
|
|
|
var->root->frame = get_frame_id (fi);
|
2002-11-29 Andrew Cagney <ac131313@redhat.com>
* stack.c (selected_frame, select_frame): Move from here ...
* frame.c (selected_frame, select_frame): ... to here. Include
"language.h".
* Makefile.in (frame.o): Update dependencies.
* frame.c (get_selected_frame): New function.
* frame.h (get_selected_frame): Declare.
(deprecated_selected_frame): Rename selected_frame.
* ada-lang.c, ada-tasks.c, breakpoint.c, corelow.c: Update.
* eval.c, f-valprint.c, findvar.c, frame.c, frame.h: Update.
* h8300-tdep.c, h8500-tdep.c, hppa-tdep.c, infcmd.c: Update.
* inflow.c, infrun.c, macroscope.c, mips-tdep.c: Update.
* mn10300-tdep.c, ocd.c, regcache.h, remote-e7000.c: Update.
* remote-mips.c, remote-rdp.c, sh-tdep.c, sparc-tdep.c: Update.
* stack.c, thread.c, tracepoint.c, valops.c, varobj.c: Update.
* z8k-tdep.c, cli/cli-cmds.c: Update.
Index: mi/ChangeLog
2002-11-29 Andrew Cagney <ac131313@redhat.com>
* mi/mi-cmd-stack.c, mi/mi-main.c: Update to use
deprecated_selected_frame.
Index: tui/ChangeLog
2002-11-29 Andrew Cagney <ac131313@redhat.com>
* tui/tui-hooks.c: Update to use deprecated_selected_frame.
* tui/tui.c, tui/tuiDisassem.c, tui/tuiRegs.c: Ditto.
* tui/tuiSource.c, tui/tuiSourceWin.c, tui/tuiWin.c: Ditto.
2002-11-29 20:15:16 +01:00
|
|
|
|
old_fi = deprecated_selected_frame;
|
2002-05-05 03:15:13 +02:00
|
|
|
|
select_frame (fi);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* We definitively need to catch errors here.
|
|
|
|
|
If evaluate_expression succeeds we got the value we wanted.
|
|
|
|
|
But if it fails, we still go on with a call to evaluate_type() */
|
|
|
|
|
if (gdb_evaluate_expression (var->root->exp, &var->value))
|
|
|
|
|
{
|
|
|
|
|
/* no error */
|
|
|
|
|
release_value (var->value);
|
2005-02-02 23:34:36 +01:00
|
|
|
|
if (value_lazy (var->value))
|
2000-02-03 05:14:45 +01:00
|
|
|
|
gdb_value_fetch_lazy (var->value);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
var->value = evaluate_type (var->root->exp);
|
|
|
|
|
|
2004-11-12 Andrew Cagney <cagney@gnu.org>
* value.h (VALUE_TYPE, VALUE_NEXT, VALUE_OFFSET, VALUE_BITSIZE)
(VALUE_BITPOS): Delete.
(value_type, value_offset, value_bitsize, value_bitpos): Declare.
* value.c (value_type, value_offset, value_bitpos)
(value_bitsize): New functions. Update references.
* arm-tdep.c, gnu-v3-abi.c, hpacc-abi.c, gnu-v2-abi.c: Update.
* f-valprint.c, cp-valprint.c, c-valprint.c: Update.
* ada-valprint.c, typeprint.c, scm-valprint.c, scm-exp.c: Update.
* p-valprint.c, jv-valprint.c, jv-lang.c, varobj.c: Update.
* objc-lang.c, ada-lang.c, std-regs.c, stack.c: Update.
* infcall.c, linespec.c, printcmd.c, valarith.c: Update.
* valops.c, eval.c, findvar.c, breakpoint.c: Update.
* tracepoint.c, ax-gdb.c, mi/mi-main.c, cli/cli-dump.c:
* rs6000-tdep.c, ppc-sysv-tdep.c: Update.
2004-11-12 22:45:08 +01:00
|
|
|
|
var->type = value_type (var->value);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
|
|
|
|
/* Set language info */
|
|
|
|
|
lang = variable_language (var);
|
|
|
|
|
var->root->lang = languages[lang];
|
|
|
|
|
|
|
|
|
|
/* Set ourselves as our root */
|
|
|
|
|
var->root->rootvar = var;
|
|
|
|
|
|
|
|
|
|
/* Reset the selected frame */
|
|
|
|
|
if (fi != NULL)
|
2002-05-05 03:15:13 +02:00
|
|
|
|
select_frame (old_fi);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
}
|
|
|
|
|
|
2000-03-13 22:51:46 +01:00
|
|
|
|
/* If the variable object name is null, that means this
|
|
|
|
|
is a temporary variable, so don't install it. */
|
|
|
|
|
|
|
|
|
|
if ((var != NULL) && (objname != NULL))
|
2000-02-03 05:14:45 +01:00
|
|
|
|
{
|
|
|
|
|
var->obj_name = savestring (objname, strlen (objname));
|
|
|
|
|
|
|
|
|
|
/* If a varobj name is duplicated, the install will fail so
|
|
|
|
|
we must clenup */
|
|
|
|
|
if (!install_variable (var))
|
|
|
|
|
{
|
|
|
|
|
do_cleanups (old_chain);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
discard_cleanups (old_chain);
|
|
|
|
|
return var;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Generates an unique name that can be used for a varobj */
|
|
|
|
|
|
|
|
|
|
char *
|
|
|
|
|
varobj_gen_name (void)
|
|
|
|
|
{
|
|
|
|
|
static int id = 0;
|
2002-07-03 22:23:04 +02:00
|
|
|
|
char *obj_name;
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
|
|
|
|
/* generate a name for this object */
|
|
|
|
|
id++;
|
2004-06-29 01:59:29 +02:00
|
|
|
|
obj_name = xstrprintf ("var%d", id);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
2002-07-03 22:23:04 +02:00
|
|
|
|
return obj_name;
|
2000-02-03 05:14:45 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Given an "objname", returns the pointer to the corresponding varobj
|
|
|
|
|
or NULL if not found */
|
|
|
|
|
|
|
|
|
|
struct varobj *
|
|
|
|
|
varobj_get_handle (char *objname)
|
|
|
|
|
{
|
|
|
|
|
struct vlist *cv;
|
|
|
|
|
const char *chp;
|
|
|
|
|
unsigned int index = 0;
|
|
|
|
|
unsigned int i = 1;
|
|
|
|
|
|
|
|
|
|
for (chp = objname; *chp; chp++)
|
|
|
|
|
{
|
|
|
|
|
index = (index + (i++ * (unsigned int) *chp)) % VAROBJ_TABLE_SIZE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cv = *(varobj_table + index);
|
|
|
|
|
while ((cv != NULL) && (strcmp (cv->var->obj_name, objname) != 0))
|
|
|
|
|
cv = cv->next;
|
|
|
|
|
|
|
|
|
|
if (cv == NULL)
|
2005-02-10 Andrew Cagney <cagney@gnu.org>
Mark up all error and warning messages.
* ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update.
* bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update.
* core-aout.c, core-regset.c, corefile.c, corelow.c: Update.
* cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update.
* dbxread.c, demangle.c, doublest.c, dsrec.c: Update.
* dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update.
* event-top.c, exec.c, expprint.c, f-lang.c: Update.
* f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update.
* frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update.
* gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update.
* hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update.
* hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update.
* hpread.c, hpux-thread.c, i386-linux-nat.c: Update.
* i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update.
* ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update.
* infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update.
* inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update.
* kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update.
* linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update.
* m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update.
* m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update.
* maint.c, mdebugread.c, mem-break.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update.
* nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update.
* observer.c, ocd.c, p-lang.c, p-typeprint.c: Update.
* p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update.
* ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update.
* remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update.
* remote-rdp.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote-utils.h, remote.c: Update.
* rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update.
* ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update.
* sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update.
* solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update.
* solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update.
* somread.c, somsolib.c, source.c, stabsread.c: Update.
* stack.c, std-regs.c, symfile-mem.c, symfile.c: Update.
* symmisc.c, symtab.c, target.c, thread.c, top.c: Update.
* tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update.
* uw-thread.c, valarith.c, valops.c, valprint.c: Update.
* value.c, varobj.c, version.in, win32-nat.c, wince.c: Update.
* xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update.
* cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update.
* cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update.
* mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update.
* mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update.
* mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update.
* tui/tui-win.c: Update.
2005-02-11 05:06:14 +01:00
|
|
|
|
error (_("Variable object not found"));
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
|
|
|
|
return cv->var;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Given the handle, return the name of the object */
|
|
|
|
|
|
|
|
|
|
char *
|
|
|
|
|
varobj_get_objname (struct varobj *var)
|
|
|
|
|
{
|
|
|
|
|
return var->obj_name;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Given the handle, return the expression represented by the object */
|
|
|
|
|
|
|
|
|
|
char *
|
|
|
|
|
varobj_get_expression (struct varobj *var)
|
|
|
|
|
{
|
|
|
|
|
return name_of_variable (var);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Deletes a varobj and all its children if only_children == 0,
|
|
|
|
|
otherwise deletes only the children; returns a malloc'ed list of all the
|
|
|
|
|
(malloc'ed) names of the variables that have been deleted (NULL terminated) */
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
varobj_delete (struct varobj *var, char ***dellist, int only_children)
|
|
|
|
|
{
|
|
|
|
|
int delcount;
|
|
|
|
|
int mycount;
|
|
|
|
|
struct cpstack *result = NULL;
|
|
|
|
|
char **cp;
|
|
|
|
|
|
|
|
|
|
/* Initialize a stack for temporary results */
|
|
|
|
|
cppush (&result, NULL);
|
|
|
|
|
|
|
|
|
|
if (only_children)
|
|
|
|
|
/* Delete only the variable children */
|
|
|
|
|
delcount = delete_variable (&result, var, 1 /* only the children */ );
|
|
|
|
|
else
|
|
|
|
|
/* Delete the variable and all its children */
|
|
|
|
|
delcount = delete_variable (&result, var, 0 /* parent+children */ );
|
|
|
|
|
|
|
|
|
|
/* We may have been asked to return a list of what has been deleted */
|
|
|
|
|
if (dellist != NULL)
|
|
|
|
|
{
|
|
|
|
|
*dellist = xmalloc ((delcount + 1) * sizeof (char *));
|
|
|
|
|
|
|
|
|
|
cp = *dellist;
|
|
|
|
|
mycount = delcount;
|
|
|
|
|
*cp = cppop (&result);
|
|
|
|
|
while ((*cp != NULL) && (mycount > 0))
|
|
|
|
|
{
|
|
|
|
|
mycount--;
|
|
|
|
|
cp++;
|
|
|
|
|
*cp = cppop (&result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (mycount || (*cp != NULL))
|
2005-02-10 Andrew Cagney <cagney@gnu.org>
Mark up all error and warning messages.
* ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update.
* bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update.
* core-aout.c, core-regset.c, corefile.c, corelow.c: Update.
* cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update.
* dbxread.c, demangle.c, doublest.c, dsrec.c: Update.
* dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update.
* event-top.c, exec.c, expprint.c, f-lang.c: Update.
* f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update.
* frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update.
* gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update.
* hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update.
* hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update.
* hpread.c, hpux-thread.c, i386-linux-nat.c: Update.
* i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update.
* ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update.
* infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update.
* inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update.
* kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update.
* linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update.
* m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update.
* m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update.
* maint.c, mdebugread.c, mem-break.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update.
* nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update.
* observer.c, ocd.c, p-lang.c, p-typeprint.c: Update.
* p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update.
* ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update.
* remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update.
* remote-rdp.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote-utils.h, remote.c: Update.
* rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update.
* ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update.
* sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update.
* solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update.
* solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update.
* somread.c, somsolib.c, source.c, stabsread.c: Update.
* stack.c, std-regs.c, symfile-mem.c, symfile.c: Update.
* symmisc.c, symtab.c, target.c, thread.c, top.c: Update.
* tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update.
* uw-thread.c, valarith.c, valops.c, valprint.c: Update.
* value.c, varobj.c, version.in, win32-nat.c, wince.c: Update.
* xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update.
* cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update.
* cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update.
* mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update.
* mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update.
* mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update.
* tui/tui-win.c: Update.
2005-02-11 05:06:14 +01:00
|
|
|
|
warning (_("varobj_delete: assertion failed - mycount(=%d) <> 0"),
|
2001-11-01 03:22:21 +01:00
|
|
|
|
mycount);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return delcount;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Set/Get variable object display format */
|
|
|
|
|
|
|
|
|
|
enum varobj_display_formats
|
|
|
|
|
varobj_set_display_format (struct varobj *var,
|
|
|
|
|
enum varobj_display_formats format)
|
|
|
|
|
{
|
|
|
|
|
switch (format)
|
|
|
|
|
{
|
|
|
|
|
case FORMAT_NATURAL:
|
|
|
|
|
case FORMAT_BINARY:
|
|
|
|
|
case FORMAT_DECIMAL:
|
|
|
|
|
case FORMAT_HEXADECIMAL:
|
|
|
|
|
case FORMAT_OCTAL:
|
|
|
|
|
var->format = format;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
var->format = variable_default_display (var);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return var->format;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
enum varobj_display_formats
|
|
|
|
|
varobj_get_display_format (struct varobj *var)
|
|
|
|
|
{
|
|
|
|
|
return var->format;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
varobj_get_num_children (struct varobj *var)
|
|
|
|
|
{
|
|
|
|
|
if (var->num_children == -1)
|
|
|
|
|
var->num_children = number_of_children (var);
|
|
|
|
|
|
|
|
|
|
return var->num_children;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Creates a list of the immediate children of a variable object;
|
|
|
|
|
the return code is the number of such children or -1 on error */
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
varobj_list_children (struct varobj *var, struct varobj ***childlist)
|
|
|
|
|
{
|
|
|
|
|
struct varobj *child;
|
|
|
|
|
char *name;
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
/* sanity check: have we been passed a pointer? */
|
|
|
|
|
if (childlist == NULL)
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
|
|
*childlist = NULL;
|
|
|
|
|
|
|
|
|
|
if (var->num_children == -1)
|
|
|
|
|
var->num_children = number_of_children (var);
|
|
|
|
|
|
|
|
|
|
/* List of children */
|
|
|
|
|
*childlist = xmalloc ((var->num_children + 1) * sizeof (struct varobj *));
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < var->num_children; i++)
|
|
|
|
|
{
|
|
|
|
|
/* Mark as the end in case we bail out */
|
|
|
|
|
*((*childlist) + i) = NULL;
|
|
|
|
|
|
|
|
|
|
/* check if child exists, if not create */
|
|
|
|
|
name = name_of_child (var, i);
|
|
|
|
|
child = child_exists (var, name);
|
|
|
|
|
if (child == NULL)
|
|
|
|
|
child = create_child (var, i, name);
|
|
|
|
|
|
|
|
|
|
*((*childlist) + i) = child;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* End of list is marked by a NULL pointer */
|
|
|
|
|
*((*childlist) + i) = NULL;
|
|
|
|
|
|
|
|
|
|
return var->num_children;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Obtain the type of an object Variable as a string similar to the one gdb
|
|
|
|
|
prints on the console */
|
|
|
|
|
|
|
|
|
|
char *
|
|
|
|
|
varobj_get_type (struct varobj *var)
|
|
|
|
|
{
|
2001-11-01 03:37:56 +01:00
|
|
|
|
struct value *val;
|
2000-02-03 05:14:45 +01:00
|
|
|
|
struct cleanup *old_chain;
|
|
|
|
|
struct ui_file *stb;
|
|
|
|
|
char *thetype;
|
|
|
|
|
long length;
|
|
|
|
|
|
|
|
|
|
/* For the "fake" variables, do not return a type. (It's type is
|
|
|
|
|
NULL, too.) */
|
|
|
|
|
if (CPLUS_FAKE_CHILD (var))
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
stb = mem_fileopen ();
|
|
|
|
|
old_chain = make_cleanup_ui_file_delete (stb);
|
|
|
|
|
|
2001-11-01 03:37:56 +01:00
|
|
|
|
/* To print the type, we simply create a zero ``struct value *'' and
|
2000-02-03 05:14:45 +01:00
|
|
|
|
cast it to our type. We then typeprint this variable. */
|
|
|
|
|
val = value_zero (var->type, not_lval);
|
2004-11-12 Andrew Cagney <cagney@gnu.org>
* value.h (VALUE_TYPE, VALUE_NEXT, VALUE_OFFSET, VALUE_BITSIZE)
(VALUE_BITPOS): Delete.
(value_type, value_offset, value_bitsize, value_bitpos): Declare.
* value.c (value_type, value_offset, value_bitpos)
(value_bitsize): New functions. Update references.
* arm-tdep.c, gnu-v3-abi.c, hpacc-abi.c, gnu-v2-abi.c: Update.
* f-valprint.c, cp-valprint.c, c-valprint.c: Update.
* ada-valprint.c, typeprint.c, scm-valprint.c, scm-exp.c: Update.
* p-valprint.c, jv-valprint.c, jv-lang.c, varobj.c: Update.
* objc-lang.c, ada-lang.c, std-regs.c, stack.c: Update.
* infcall.c, linespec.c, printcmd.c, valarith.c: Update.
* valops.c, eval.c, findvar.c, breakpoint.c: Update.
* tracepoint.c, ax-gdb.c, mi/mi-main.c, cli/cli-dump.c:
* rs6000-tdep.c, ppc-sysv-tdep.c: Update.
2004-11-12 22:45:08 +01:00
|
|
|
|
type_print (value_type (val), "", stb, -1);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
|
|
|
|
thetype = ui_file_xstrdup (stb, &length);
|
|
|
|
|
do_cleanups (old_chain);
|
|
|
|
|
return thetype;
|
|
|
|
|
}
|
|
|
|
|
|
2005-07-15 06:12:19 +02:00
|
|
|
|
/* Obtain the type of an object variable. */
|
|
|
|
|
|
|
|
|
|
struct type *
|
|
|
|
|
varobj_get_gdb_type (struct varobj *var)
|
|
|
|
|
{
|
|
|
|
|
return var->type;
|
|
|
|
|
}
|
|
|
|
|
|
2000-02-03 05:14:45 +01:00
|
|
|
|
enum varobj_languages
|
|
|
|
|
varobj_get_language (struct varobj *var)
|
|
|
|
|
{
|
|
|
|
|
return variable_language (var);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
varobj_get_attributes (struct varobj *var)
|
|
|
|
|
{
|
|
|
|
|
int attributes = 0;
|
|
|
|
|
|
|
|
|
|
if (variable_editable (var))
|
|
|
|
|
/* FIXME: define masks for attributes */
|
|
|
|
|
attributes |= 0x00000001; /* Editable */
|
|
|
|
|
|
|
|
|
|
return attributes;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
char *
|
|
|
|
|
varobj_get_value (struct varobj *var)
|
|
|
|
|
{
|
|
|
|
|
return my_value_of_variable (var);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Set the value of an object variable (if it is editable) to the
|
|
|
|
|
value of the given expression */
|
|
|
|
|
/* Note: Invokes functions that can call error() */
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
varobj_set_value (struct varobj *var, char *expression)
|
|
|
|
|
{
|
2001-11-01 03:37:56 +01:00
|
|
|
|
struct value *val;
|
2000-02-03 05:14:45 +01:00
|
|
|
|
int offset = 0;
|
2005-02-20 02:19:24 +01:00
|
|
|
|
int error = 0;
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
|
|
|
|
/* The argument "expression" contains the variable's new value.
|
|
|
|
|
We need to first construct a legal expression for this -- ugh! */
|
|
|
|
|
/* Does this cover all the bases? */
|
|
|
|
|
struct expression *exp;
|
2001-11-01 03:37:56 +01:00
|
|
|
|
struct value *value;
|
2000-02-03 05:14:45 +01:00
|
|
|
|
int saved_input_radix = input_radix;
|
|
|
|
|
|
2002-01-13 21:17:55 +01:00
|
|
|
|
if (var->value != NULL && variable_editable (var) && !var->error)
|
2000-02-03 05:14:45 +01:00
|
|
|
|
{
|
|
|
|
|
char *s = expression;
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
input_radix = 10; /* ALWAYS reset to decimal temporarily */
|
2006-03-27 02:15:22 +02:00
|
|
|
|
exp = parse_exp_1 (&s, 0, 0);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
if (!gdb_evaluate_expression (exp, &value))
|
|
|
|
|
{
|
|
|
|
|
/* We cannot proceed without a valid expression. */
|
2001-01-19 06:45:16 +01:00
|
|
|
|
xfree (exp);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2002-10-24 01:54:33 +02:00
|
|
|
|
if (!my_value_equal (var->value, value, &error))
|
|
|
|
|
var->updated = 1;
|
2002-01-13 21:17:55 +01:00
|
|
|
|
if (!gdb_value_assign (var->value, value, &val))
|
2000-11-07 00:12:29 +01:00
|
|
|
|
return 0;
|
2000-02-03 05:14:45 +01:00
|
|
|
|
value_free (var->value);
|
|
|
|
|
release_value (val);
|
|
|
|
|
var->value = val;
|
|
|
|
|
input_radix = saved_input_radix;
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Returns a malloc'ed list with all root variable objects */
|
|
|
|
|
int
|
|
|
|
|
varobj_list (struct varobj ***varlist)
|
|
|
|
|
{
|
|
|
|
|
struct varobj **cv;
|
|
|
|
|
struct varobj_root *croot;
|
|
|
|
|
int mycount = rootcount;
|
|
|
|
|
|
|
|
|
|
/* Alloc (rootcount + 1) entries for the result */
|
|
|
|
|
*varlist = xmalloc ((rootcount + 1) * sizeof (struct varobj *));
|
|
|
|
|
|
|
|
|
|
cv = *varlist;
|
|
|
|
|
croot = rootlist;
|
|
|
|
|
while ((croot != NULL) && (mycount > 0))
|
|
|
|
|
{
|
|
|
|
|
*cv = croot->rootvar;
|
|
|
|
|
mycount--;
|
|
|
|
|
cv++;
|
|
|
|
|
croot = croot->next;
|
|
|
|
|
}
|
|
|
|
|
/* Mark the end of the list */
|
|
|
|
|
*cv = NULL;
|
|
|
|
|
|
|
|
|
|
if (mycount || (croot != NULL))
|
2001-11-01 03:22:21 +01:00
|
|
|
|
warning
|
|
|
|
|
("varobj_list: assertion failed - wrong tally of root vars (%d:%d)",
|
|
|
|
|
rootcount, mycount);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
|
|
|
|
return rootcount;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Update the values for a variable and its children. This is a
|
|
|
|
|
two-pronged attack. First, re-parse the value for the root's
|
|
|
|
|
expression to see if it's changed. Then go all the way
|
|
|
|
|
through its children, reconstructing them and noting if they've
|
|
|
|
|
changed.
|
2000-03-13 22:51:46 +01:00
|
|
|
|
Return value:
|
|
|
|
|
-1 if there was an error updating the varobj
|
|
|
|
|
-2 if the type changed
|
|
|
|
|
Otherwise it is the number of children + parent changed
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
2001-08-17 20:56:49 +02:00
|
|
|
|
Only root variables can be updated...
|
|
|
|
|
|
|
|
|
|
NOTE: This function may delete the caller's varobj. If it
|
|
|
|
|
returns -2, then it has done this and VARP will be modified
|
|
|
|
|
to point to the new varobj. */
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
|
|
|
|
int
|
2001-08-17 20:56:49 +02:00
|
|
|
|
varobj_update (struct varobj **varp, struct varobj ***changelist)
|
2000-02-03 05:14:45 +01:00
|
|
|
|
{
|
|
|
|
|
int changed = 0;
|
2005-02-20 02:19:24 +01:00
|
|
|
|
int error = 0;
|
2000-03-13 22:51:46 +01:00
|
|
|
|
int type_changed;
|
2000-02-03 05:14:45 +01:00
|
|
|
|
int i;
|
|
|
|
|
int vleft;
|
|
|
|
|
struct varobj *v;
|
|
|
|
|
struct varobj **cv;
|
2000-11-29 15:41:34 +01:00
|
|
|
|
struct varobj **templist = NULL;
|
2001-11-01 03:37:56 +01:00
|
|
|
|
struct value *new;
|
2000-02-03 05:14:45 +01:00
|
|
|
|
struct vstack *stack = NULL;
|
|
|
|
|
struct vstack *result = NULL;
|
2002-07-03 22:23:04 +02:00
|
|
|
|
struct frame_id old_fid;
|
|
|
|
|
struct frame_info *fi;
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
|
|
|
|
/* sanity check: have we been passed a pointer? */
|
|
|
|
|
if (changelist == NULL)
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
|
|
/* Only root variables can be updated... */
|
2001-08-17 20:56:49 +02:00
|
|
|
|
if ((*varp)->root->rootvar != *varp)
|
2000-02-03 05:14:45 +01:00
|
|
|
|
/* Not a root var */
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
|
|
/* Save the selected stack frame, since we will need to change it
|
|
|
|
|
in order to evaluate expressions. */
|
2002-12-04 01:05:54 +01:00
|
|
|
|
old_fid = get_frame_id (deprecated_selected_frame);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
|
|
|
|
/* Update the root variable. value_of_root can return NULL
|
|
|
|
|
if the variable is no longer around, i.e. we stepped out of
|
2000-03-13 22:51:46 +01:00
|
|
|
|
the frame in which a local existed. We are letting the
|
|
|
|
|
value_of_root variable dispose of the varobj if the type
|
|
|
|
|
has changed. */
|
|
|
|
|
type_changed = 1;
|
2001-08-17 20:56:49 +02:00
|
|
|
|
new = value_of_root (varp, &type_changed);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
if (new == NULL)
|
2000-03-13 22:51:46 +01:00
|
|
|
|
{
|
2001-08-17 20:56:49 +02:00
|
|
|
|
(*varp)->error = 1;
|
2000-03-13 22:51:46 +01:00
|
|
|
|
return -1;
|
|
|
|
|
}
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
|
|
|
|
/* Initialize a stack for temporary results */
|
|
|
|
|
vpush (&result, NULL);
|
|
|
|
|
|
2000-10-13 22:31:38 +02:00
|
|
|
|
/* If this is a "use_selected_frame" varobj, and its type has changed,
|
|
|
|
|
them note that it's changed. */
|
|
|
|
|
if (type_changed)
|
2000-02-03 05:14:45 +01:00
|
|
|
|
{
|
2001-08-17 20:56:49 +02:00
|
|
|
|
vpush (&result, *varp);
|
2000-10-13 22:31:38 +02:00
|
|
|
|
changed++;
|
|
|
|
|
}
|
|
|
|
|
/* If values are not equal, note that it's changed.
|
|
|
|
|
There a couple of exceptions here, though.
|
|
|
|
|
We don't want some types to be reported as "changed". */
|
2002-10-24 01:54:33 +02:00
|
|
|
|
else if (type_changeable (*varp) &&
|
2005-02-20 02:19:24 +01:00
|
|
|
|
((*varp)->updated || !my_value_equal ((*varp)->value, new, &error)))
|
2000-10-13 22:31:38 +02:00
|
|
|
|
{
|
2001-08-17 20:56:49 +02:00
|
|
|
|
vpush (&result, *varp);
|
2002-10-24 01:54:33 +02:00
|
|
|
|
(*varp)->updated = 0;
|
2000-10-13 22:31:38 +02:00
|
|
|
|
changed++;
|
2005-02-20 02:19:24 +01:00
|
|
|
|
/* Its value is going to be updated to NEW. */
|
|
|
|
|
(*varp)->error = error;
|
2000-02-03 05:14:45 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* We must always keep around the new value for this root
|
|
|
|
|
variable expression, or we lose the updated children! */
|
2001-08-17 20:56:49 +02:00
|
|
|
|
value_free ((*varp)->value);
|
|
|
|
|
(*varp)->value = new;
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
|
|
|
|
/* Initialize a stack */
|
|
|
|
|
vpush (&stack, NULL);
|
|
|
|
|
|
|
|
|
|
/* Push the root's children */
|
2001-08-17 20:56:49 +02:00
|
|
|
|
if ((*varp)->children != NULL)
|
2000-02-03 05:14:45 +01:00
|
|
|
|
{
|
|
|
|
|
struct varobj_child *c;
|
2001-08-17 20:56:49 +02:00
|
|
|
|
for (c = (*varp)->children; c != NULL; c = c->next)
|
2000-02-03 05:14:45 +01:00
|
|
|
|
vpush (&stack, c->child);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Walk through the children, reconstructing them all. */
|
|
|
|
|
v = vpop (&stack);
|
|
|
|
|
while (v != NULL)
|
|
|
|
|
{
|
|
|
|
|
/* Push any children */
|
|
|
|
|
if (v->children != NULL)
|
|
|
|
|
{
|
|
|
|
|
struct varobj_child *c;
|
|
|
|
|
for (c = v->children; c != NULL; c = c->next)
|
|
|
|
|
vpush (&stack, c->child);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Update this variable */
|
|
|
|
|
new = value_of_child (v->parent, v->index);
|
2002-10-24 01:54:33 +02:00
|
|
|
|
if (type_changeable (v) &&
|
2005-02-20 02:19:24 +01:00
|
|
|
|
(v->updated || !my_value_equal (v->value, new, &error)))
|
2000-02-03 05:14:45 +01:00
|
|
|
|
{
|
|
|
|
|
/* Note that it's changed */
|
|
|
|
|
vpush (&result, v);
|
2002-10-24 01:54:33 +02:00
|
|
|
|
v->updated = 0;
|
2000-02-03 05:14:45 +01:00
|
|
|
|
changed++;
|
|
|
|
|
}
|
2005-02-20 02:19:24 +01:00
|
|
|
|
/* Its value is going to be updated to NEW. */
|
|
|
|
|
v->error = error;
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
|
|
|
|
/* We must always keep new values, since children depend on it. */
|
|
|
|
|
if (v->value != NULL)
|
|
|
|
|
value_free (v->value);
|
|
|
|
|
v->value = new;
|
|
|
|
|
|
|
|
|
|
/* Get next child */
|
|
|
|
|
v = vpop (&stack);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Alloc (changed + 1) list entries */
|
|
|
|
|
/* FIXME: add a cleanup for the allocated list(s)
|
|
|
|
|
because one day the select_frame called below can longjump */
|
|
|
|
|
*changelist = xmalloc ((changed + 1) * sizeof (struct varobj *));
|
|
|
|
|
if (changed > 1)
|
|
|
|
|
{
|
|
|
|
|
templist = xmalloc ((changed + 1) * sizeof (struct varobj *));
|
|
|
|
|
cv = templist;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
cv = *changelist;
|
|
|
|
|
|
|
|
|
|
/* Copy from result stack to list */
|
|
|
|
|
vleft = changed;
|
|
|
|
|
*cv = vpop (&result);
|
|
|
|
|
while ((*cv != NULL) && (vleft > 0))
|
|
|
|
|
{
|
|
|
|
|
vleft--;
|
|
|
|
|
cv++;
|
|
|
|
|
*cv = vpop (&result);
|
|
|
|
|
}
|
|
|
|
|
if (vleft)
|
2005-02-10 Andrew Cagney <cagney@gnu.org>
Mark up all error and warning messages.
* ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update.
* bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update.
* core-aout.c, core-regset.c, corefile.c, corelow.c: Update.
* cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update.
* dbxread.c, demangle.c, doublest.c, dsrec.c: Update.
* dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update.
* event-top.c, exec.c, expprint.c, f-lang.c: Update.
* f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update.
* frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update.
* gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update.
* hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update.
* hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update.
* hpread.c, hpux-thread.c, i386-linux-nat.c: Update.
* i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update.
* ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update.
* infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update.
* inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update.
* kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update.
* linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update.
* m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update.
* m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update.
* maint.c, mdebugread.c, mem-break.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update.
* nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update.
* observer.c, ocd.c, p-lang.c, p-typeprint.c: Update.
* p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update.
* ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update.
* remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update.
* remote-rdp.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote-utils.h, remote.c: Update.
* rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update.
* ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update.
* sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update.
* solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update.
* solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update.
* somread.c, somsolib.c, source.c, stabsread.c: Update.
* stack.c, std-regs.c, symfile-mem.c, symfile.c: Update.
* symmisc.c, symtab.c, target.c, thread.c, top.c: Update.
* tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update.
* uw-thread.c, valarith.c, valops.c, valprint.c: Update.
* value.c, varobj.c, version.in, win32-nat.c, wince.c: Update.
* xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update.
* cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update.
* cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update.
* mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update.
* mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update.
* mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update.
* tui/tui-win.c: Update.
2005-02-11 05:06:14 +01:00
|
|
|
|
warning (_("varobj_update: assertion failed - vleft <> 0"));
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
|
|
|
|
if (changed > 1)
|
|
|
|
|
{
|
|
|
|
|
/* Now we revert the order. */
|
2001-11-01 03:22:21 +01:00
|
|
|
|
for (i = 0; i < changed; i++)
|
|
|
|
|
*(*changelist + i) = *(templist + changed - 1 - i);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
*(*changelist + changed) = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Restore selected frame */
|
2002-07-03 22:23:04 +02:00
|
|
|
|
fi = frame_find_by_id (old_fid);
|
|
|
|
|
if (fi)
|
|
|
|
|
select_frame (fi);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
2000-03-13 22:51:46 +01:00
|
|
|
|
if (type_changed)
|
|
|
|
|
return -2;
|
|
|
|
|
else
|
|
|
|
|
return changed;
|
2000-02-03 05:14:45 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Helper functions */
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Variable object construction/destruction
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
static int
|
2000-07-30 03:48:28 +02:00
|
|
|
|
delete_variable (struct cpstack **resultp, struct varobj *var,
|
|
|
|
|
int only_children_p)
|
2000-02-03 05:14:45 +01:00
|
|
|
|
{
|
|
|
|
|
int delcount = 0;
|
|
|
|
|
|
|
|
|
|
delete_variable_1 (resultp, &delcount, var,
|
|
|
|
|
only_children_p, 1 /* remove_from_parent_p */ );
|
|
|
|
|
|
|
|
|
|
return delcount;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Delete the variable object VAR and its children */
|
|
|
|
|
/* IMPORTANT NOTE: If we delete a variable which is a child
|
|
|
|
|
and the parent is not removed we dump core. It must be always
|
|
|
|
|
initially called with remove_from_parent_p set */
|
|
|
|
|
static void
|
2001-11-01 03:22:21 +01:00
|
|
|
|
delete_variable_1 (struct cpstack **resultp, int *delcountp,
|
|
|
|
|
struct varobj *var, int only_children_p,
|
|
|
|
|
int remove_from_parent_p)
|
2000-02-03 05:14:45 +01:00
|
|
|
|
{
|
|
|
|
|
struct varobj_child *vc;
|
|
|
|
|
struct varobj_child *next;
|
|
|
|
|
|
|
|
|
|
/* Delete any children of this variable, too. */
|
|
|
|
|
for (vc = var->children; vc != NULL; vc = next)
|
|
|
|
|
{
|
|
|
|
|
if (!remove_from_parent_p)
|
|
|
|
|
vc->child->parent = NULL;
|
|
|
|
|
delete_variable_1 (resultp, delcountp, vc->child, 0, only_children_p);
|
|
|
|
|
next = vc->next;
|
2000-12-15 02:01:51 +01:00
|
|
|
|
xfree (vc);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* if we were called to delete only the children we are done here */
|
|
|
|
|
if (only_children_p)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
/* Otherwise, add it to the list of deleted ones and proceed to do so */
|
2000-03-13 22:51:46 +01:00
|
|
|
|
/* If the name is null, this is a temporary variable, that has not
|
|
|
|
|
yet been installed, don't report it, it belongs to the caller... */
|
|
|
|
|
if (var->obj_name != NULL)
|
2000-02-03 05:14:45 +01:00
|
|
|
|
{
|
2001-01-26 20:47:23 +01:00
|
|
|
|
cppush (resultp, xstrdup (var->obj_name));
|
2000-02-03 05:14:45 +01:00
|
|
|
|
*delcountp = *delcountp + 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* If this variable has a parent, remove it from its parent's list */
|
|
|
|
|
/* OPTIMIZATION: if the parent of this variable is also being deleted,
|
|
|
|
|
(as indicated by remove_from_parent_p) we don't bother doing an
|
|
|
|
|
expensive list search to find the element to remove when we are
|
|
|
|
|
discarding the list afterwards */
|
2001-11-01 03:22:21 +01:00
|
|
|
|
if ((remove_from_parent_p) && (var->parent != NULL))
|
2000-02-03 05:14:45 +01:00
|
|
|
|
{
|
|
|
|
|
remove_child_from_parent (var->parent, var);
|
|
|
|
|
}
|
2001-11-01 03:22:21 +01:00
|
|
|
|
|
2000-03-13 22:51:46 +01:00
|
|
|
|
if (var->obj_name != NULL)
|
|
|
|
|
uninstall_variable (var);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
|
|
|
|
/* Free memory associated with this variable */
|
|
|
|
|
free_variable (var);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Install the given variable VAR with the object name VAR->OBJ_NAME. */
|
|
|
|
|
static int
|
2000-07-30 03:48:28 +02:00
|
|
|
|
install_variable (struct varobj *var)
|
2000-02-03 05:14:45 +01:00
|
|
|
|
{
|
|
|
|
|
struct vlist *cv;
|
|
|
|
|
struct vlist *newvl;
|
|
|
|
|
const char *chp;
|
|
|
|
|
unsigned int index = 0;
|
|
|
|
|
unsigned int i = 1;
|
|
|
|
|
|
|
|
|
|
for (chp = var->obj_name; *chp; chp++)
|
|
|
|
|
{
|
|
|
|
|
index = (index + (i++ * (unsigned int) *chp)) % VAROBJ_TABLE_SIZE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cv = *(varobj_table + index);
|
|
|
|
|
while ((cv != NULL) && (strcmp (cv->var->obj_name, var->obj_name) != 0))
|
|
|
|
|
cv = cv->next;
|
|
|
|
|
|
|
|
|
|
if (cv != NULL)
|
2005-02-10 Andrew Cagney <cagney@gnu.org>
Mark up all error and warning messages.
* ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update.
* bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update.
* core-aout.c, core-regset.c, corefile.c, corelow.c: Update.
* cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update.
* dbxread.c, demangle.c, doublest.c, dsrec.c: Update.
* dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update.
* event-top.c, exec.c, expprint.c, f-lang.c: Update.
* f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update.
* frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update.
* gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update.
* hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update.
* hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update.
* hpread.c, hpux-thread.c, i386-linux-nat.c: Update.
* i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update.
* ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update.
* infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update.
* inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update.
* kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update.
* linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update.
* m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update.
* m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update.
* maint.c, mdebugread.c, mem-break.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update.
* nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update.
* observer.c, ocd.c, p-lang.c, p-typeprint.c: Update.
* p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update.
* ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update.
* remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update.
* remote-rdp.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote-utils.h, remote.c: Update.
* rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update.
* ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update.
* sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update.
* solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update.
* solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update.
* somread.c, somsolib.c, source.c, stabsread.c: Update.
* stack.c, std-regs.c, symfile-mem.c, symfile.c: Update.
* symmisc.c, symtab.c, target.c, thread.c, top.c: Update.
* tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update.
* uw-thread.c, valarith.c, valops.c, valprint.c: Update.
* value.c, varobj.c, version.in, win32-nat.c, wince.c: Update.
* xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update.
* cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update.
* cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update.
* mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update.
* mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update.
* mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update.
* tui/tui-win.c: Update.
2005-02-11 05:06:14 +01:00
|
|
|
|
error (_("Duplicate variable object name"));
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
|
|
|
|
/* Add varobj to hash table */
|
|
|
|
|
newvl = xmalloc (sizeof (struct vlist));
|
|
|
|
|
newvl->next = *(varobj_table + index);
|
|
|
|
|
newvl->var = var;
|
|
|
|
|
*(varobj_table + index) = newvl;
|
|
|
|
|
|
|
|
|
|
/* If root, add varobj to root list */
|
|
|
|
|
if (var->root->rootvar == var)
|
|
|
|
|
{
|
|
|
|
|
/* Add to list of root variables */
|
|
|
|
|
if (rootlist == NULL)
|
|
|
|
|
var->root->next = NULL;
|
|
|
|
|
else
|
|
|
|
|
var->root->next = rootlist;
|
|
|
|
|
rootlist = var->root;
|
|
|
|
|
rootcount++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 1; /* OK */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Unistall the object VAR. */
|
|
|
|
|
static void
|
2000-07-30 03:48:28 +02:00
|
|
|
|
uninstall_variable (struct varobj *var)
|
2000-02-03 05:14:45 +01:00
|
|
|
|
{
|
|
|
|
|
struct vlist *cv;
|
|
|
|
|
struct vlist *prev;
|
|
|
|
|
struct varobj_root *cr;
|
|
|
|
|
struct varobj_root *prer;
|
|
|
|
|
const char *chp;
|
|
|
|
|
unsigned int index = 0;
|
|
|
|
|
unsigned int i = 1;
|
|
|
|
|
|
|
|
|
|
/* Remove varobj from hash table */
|
|
|
|
|
for (chp = var->obj_name; *chp; chp++)
|
|
|
|
|
{
|
|
|
|
|
index = (index + (i++ * (unsigned int) *chp)) % VAROBJ_TABLE_SIZE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cv = *(varobj_table + index);
|
|
|
|
|
prev = NULL;
|
|
|
|
|
while ((cv != NULL) && (strcmp (cv->var->obj_name, var->obj_name) != 0))
|
|
|
|
|
{
|
|
|
|
|
prev = cv;
|
|
|
|
|
cv = cv->next;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (varobjdebug)
|
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "Deleting %s\n", var->obj_name);
|
|
|
|
|
|
|
|
|
|
if (cv == NULL)
|
|
|
|
|
{
|
2001-11-01 03:22:21 +01:00
|
|
|
|
warning
|
|
|
|
|
("Assertion failed: Could not find variable object \"%s\" to delete",
|
|
|
|
|
var->obj_name);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (prev == NULL)
|
|
|
|
|
*(varobj_table + index) = cv->next;
|
|
|
|
|
else
|
|
|
|
|
prev->next = cv->next;
|
|
|
|
|
|
2000-12-15 02:01:51 +01:00
|
|
|
|
xfree (cv);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
|
|
|
|
/* If root, remove varobj from root list */
|
|
|
|
|
if (var->root->rootvar == var)
|
|
|
|
|
{
|
|
|
|
|
/* Remove from list of root variables */
|
|
|
|
|
if (rootlist == var->root)
|
|
|
|
|
rootlist = var->root->next;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
prer = NULL;
|
|
|
|
|
cr = rootlist;
|
|
|
|
|
while ((cr != NULL) && (cr->rootvar != var))
|
|
|
|
|
{
|
|
|
|
|
prer = cr;
|
|
|
|
|
cr = cr->next;
|
|
|
|
|
}
|
|
|
|
|
if (cr == NULL)
|
|
|
|
|
{
|
2001-11-01 03:22:21 +01:00
|
|
|
|
warning
|
|
|
|
|
("Assertion failed: Could not find varobj \"%s\" in root list",
|
|
|
|
|
var->obj_name);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (prer == NULL)
|
|
|
|
|
rootlist = NULL;
|
|
|
|
|
else
|
|
|
|
|
prer->next = cr->next;
|
|
|
|
|
}
|
|
|
|
|
rootcount--;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Does a child with the name NAME exist in VAR? If so, return its data.
|
|
|
|
|
If not, return NULL. */
|
|
|
|
|
static struct varobj *
|
2000-11-10 02:19:47 +01:00
|
|
|
|
child_exists (struct varobj *var, char *name)
|
2000-02-03 05:14:45 +01:00
|
|
|
|
{
|
|
|
|
|
struct varobj_child *vc;
|
|
|
|
|
|
|
|
|
|
for (vc = var->children; vc != NULL; vc = vc->next)
|
|
|
|
|
{
|
2002-11-05 23:31:00 +01:00
|
|
|
|
if (strcmp (vc->child->name, name) == 0)
|
2000-02-03 05:14:45 +01:00
|
|
|
|
return vc->child;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Create and install a child of the parent of the given name */
|
|
|
|
|
static struct varobj *
|
2000-07-30 03:48:28 +02:00
|
|
|
|
create_child (struct varobj *parent, int index, char *name)
|
2000-02-03 05:14:45 +01:00
|
|
|
|
{
|
|
|
|
|
struct varobj *child;
|
|
|
|
|
char *childs_name;
|
|
|
|
|
|
|
|
|
|
child = new_variable ();
|
|
|
|
|
|
|
|
|
|
/* name is allocated by name_of_child */
|
|
|
|
|
child->name = name;
|
|
|
|
|
child->index = index;
|
|
|
|
|
child->value = value_of_child (parent, index);
|
2002-06-15 20:45:32 +02:00
|
|
|
|
if ((!CPLUS_FAKE_CHILD (child) && child->value == NULL) || parent->error)
|
2000-02-03 05:14:45 +01:00
|
|
|
|
child->error = 1;
|
|
|
|
|
child->parent = parent;
|
|
|
|
|
child->root = parent->root;
|
2004-06-29 01:59:29 +02:00
|
|
|
|
childs_name = xstrprintf ("%s.%s", parent->obj_name, name);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
child->obj_name = childs_name;
|
|
|
|
|
install_variable (child);
|
|
|
|
|
|
|
|
|
|
/* Save a pointer to this child in the parent */
|
|
|
|
|
save_child_in_parent (parent, child);
|
|
|
|
|
|
|
|
|
|
/* Note the type of this child */
|
|
|
|
|
child->type = type_of_child (child);
|
|
|
|
|
|
|
|
|
|
return child;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* FIXME: This should be a generic add to list */
|
|
|
|
|
/* Save CHILD in the PARENT's data. */
|
|
|
|
|
static void
|
2000-07-30 03:48:28 +02:00
|
|
|
|
save_child_in_parent (struct varobj *parent, struct varobj *child)
|
2000-02-03 05:14:45 +01:00
|
|
|
|
{
|
|
|
|
|
struct varobj_child *vc;
|
|
|
|
|
|
|
|
|
|
/* Insert the child at the top */
|
|
|
|
|
vc = parent->children;
|
|
|
|
|
parent->children =
|
|
|
|
|
(struct varobj_child *) xmalloc (sizeof (struct varobj_child));
|
|
|
|
|
|
|
|
|
|
parent->children->next = vc;
|
|
|
|
|
parent->children->child = child;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* FIXME: This should be a generic remove from list */
|
|
|
|
|
/* Remove the CHILD from the PARENT's list of children. */
|
|
|
|
|
static void
|
2000-07-30 03:48:28 +02:00
|
|
|
|
remove_child_from_parent (struct varobj *parent, struct varobj *child)
|
2000-02-03 05:14:45 +01:00
|
|
|
|
{
|
|
|
|
|
struct varobj_child *vc, *prev;
|
|
|
|
|
|
|
|
|
|
/* Find the child in the parent's list */
|
|
|
|
|
prev = NULL;
|
|
|
|
|
for (vc = parent->children; vc != NULL;)
|
|
|
|
|
{
|
|
|
|
|
if (vc->child == child)
|
|
|
|
|
break;
|
|
|
|
|
prev = vc;
|
|
|
|
|
vc = vc->next;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (prev == NULL)
|
|
|
|
|
parent->children = vc->next;
|
|
|
|
|
else
|
|
|
|
|
prev->next = vc->next;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Miscellaneous utility functions.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/* Allocate memory and initialize a new variable */
|
|
|
|
|
static struct varobj *
|
|
|
|
|
new_variable (void)
|
|
|
|
|
{
|
|
|
|
|
struct varobj *var;
|
|
|
|
|
|
|
|
|
|
var = (struct varobj *) xmalloc (sizeof (struct varobj));
|
|
|
|
|
var->name = NULL;
|
|
|
|
|
var->obj_name = NULL;
|
|
|
|
|
var->index = -1;
|
|
|
|
|
var->type = NULL;
|
|
|
|
|
var->value = NULL;
|
|
|
|
|
var->error = 0;
|
|
|
|
|
var->num_children = -1;
|
|
|
|
|
var->parent = NULL;
|
|
|
|
|
var->children = NULL;
|
|
|
|
|
var->format = 0;
|
|
|
|
|
var->root = NULL;
|
2002-10-24 01:54:33 +02:00
|
|
|
|
var->updated = 0;
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
|
|
|
|
return var;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Allocate memory and initialize a new root variable */
|
|
|
|
|
static struct varobj *
|
|
|
|
|
new_root_variable (void)
|
|
|
|
|
{
|
|
|
|
|
struct varobj *var = new_variable ();
|
|
|
|
|
var->root = (struct varobj_root *) xmalloc (sizeof (struct varobj_root));;
|
|
|
|
|
var->root->lang = NULL;
|
|
|
|
|
var->root->exp = NULL;
|
|
|
|
|
var->root->valid_block = NULL;
|
2002-12-04 01:05:54 +01:00
|
|
|
|
var->root->frame = null_frame_id;
|
2000-03-13 22:51:46 +01:00
|
|
|
|
var->root->use_selected_frame = 0;
|
2000-02-03 05:14:45 +01:00
|
|
|
|
var->root->rootvar = NULL;
|
|
|
|
|
|
|
|
|
|
return var;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Free any allocated memory associated with VAR. */
|
|
|
|
|
static void
|
2000-07-30 03:48:28 +02:00
|
|
|
|
free_variable (struct varobj *var)
|
2000-02-03 05:14:45 +01:00
|
|
|
|
{
|
|
|
|
|
/* Free the expression if this is a root variable. */
|
|
|
|
|
if (var->root->rootvar == var)
|
|
|
|
|
{
|
2006-02-14 19:45:14 +01:00
|
|
|
|
free_current_contents (&var->root->exp);
|
2001-01-19 06:45:16 +01:00
|
|
|
|
xfree (var->root);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
}
|
|
|
|
|
|
2001-01-19 06:45:16 +01:00
|
|
|
|
xfree (var->name);
|
|
|
|
|
xfree (var->obj_name);
|
|
|
|
|
xfree (var);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
}
|
|
|
|
|
|
2000-05-22 11:02:23 +02:00
|
|
|
|
static void
|
|
|
|
|
do_free_variable_cleanup (void *var)
|
|
|
|
|
{
|
|
|
|
|
free_variable (var);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static struct cleanup *
|
|
|
|
|
make_cleanup_free_variable (struct varobj *var)
|
|
|
|
|
{
|
|
|
|
|
return make_cleanup (do_free_variable_cleanup, var);
|
|
|
|
|
}
|
|
|
|
|
|
2003-06-19 22:40:40 +02:00
|
|
|
|
/* This returns the type of the variable. It also skips past typedefs
|
|
|
|
|
to return the real type of the variable.
|
2002-09-24 20:50:34 +02:00
|
|
|
|
|
|
|
|
|
NOTE: TYPE_TARGET_TYPE should NOT be used anywhere in this file
|
|
|
|
|
except within get_target_type and get_type. */
|
2000-02-03 05:14:45 +01:00
|
|
|
|
static struct type *
|
2000-07-30 03:48:28 +02:00
|
|
|
|
get_type (struct varobj *var)
|
2000-02-03 05:14:45 +01:00
|
|
|
|
{
|
|
|
|
|
struct type *type;
|
|
|
|
|
type = var->type;
|
|
|
|
|
|
2003-06-19 22:40:40 +02:00
|
|
|
|
if (type != NULL)
|
|
|
|
|
type = check_typedef (type);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
|
|
|
|
return type;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* This returns the type of the variable, dereferencing pointers, too. */
|
|
|
|
|
static struct type *
|
2000-07-30 03:48:28 +02:00
|
|
|
|
get_type_deref (struct varobj *var)
|
2000-02-03 05:14:45 +01:00
|
|
|
|
{
|
|
|
|
|
struct type *type;
|
|
|
|
|
|
|
|
|
|
type = get_type (var);
|
|
|
|
|
|
|
|
|
|
if (type != NULL && (TYPE_CODE (type) == TYPE_CODE_PTR
|
|
|
|
|
|| TYPE_CODE (type) == TYPE_CODE_REF))
|
|
|
|
|
type = get_target_type (type);
|
|
|
|
|
|
|
|
|
|
return type;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* This returns the target type (or NULL) of TYPE, also skipping
|
2002-09-24 20:50:34 +02:00
|
|
|
|
past typedefs, just like get_type ().
|
|
|
|
|
|
|
|
|
|
NOTE: TYPE_TARGET_TYPE should NOT be used anywhere in this file
|
|
|
|
|
except within get_target_type and get_type. */
|
2000-02-03 05:14:45 +01:00
|
|
|
|
static struct type *
|
2000-07-30 03:48:28 +02:00
|
|
|
|
get_target_type (struct type *type)
|
2000-02-03 05:14:45 +01:00
|
|
|
|
{
|
|
|
|
|
if (type != NULL)
|
|
|
|
|
{
|
|
|
|
|
type = TYPE_TARGET_TYPE (type);
|
2003-06-19 22:40:40 +02:00
|
|
|
|
if (type != NULL)
|
|
|
|
|
type = check_typedef (type);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return type;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* What is the default display for this variable? We assume that
|
|
|
|
|
everything is "natural". Any exceptions? */
|
|
|
|
|
static enum varobj_display_formats
|
2000-07-30 03:48:28 +02:00
|
|
|
|
variable_default_display (struct varobj *var)
|
2000-02-03 05:14:45 +01:00
|
|
|
|
{
|
|
|
|
|
return FORMAT_NATURAL;
|
|
|
|
|
}
|
|
|
|
|
|
2005-02-20 02:19:24 +01:00
|
|
|
|
/* This function is similar to GDB's value_contents_equal, except that
|
|
|
|
|
this one is "safe"; it never longjmps. It determines if the VAL1's
|
|
|
|
|
value is the same as VAL2. If for some reason the value of VAR2
|
|
|
|
|
can't be established, *ERROR2 is set to non-zero. */
|
|
|
|
|
|
2000-02-03 05:14:45 +01:00
|
|
|
|
static int
|
2005-03-20 21:30:35 +01:00
|
|
|
|
my_value_equal (struct value *val1, struct value *volatile val2, int *error2)
|
2000-02-03 05:14:45 +01:00
|
|
|
|
{
|
2005-04-26 07:03:41 +02:00
|
|
|
|
volatile struct gdb_exception except;
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
2005-02-20 02:19:24 +01:00
|
|
|
|
/* As a special case, if both are null, we say they're equal. */
|
2000-02-03 05:14:45 +01:00
|
|
|
|
if (val1 == NULL && val2 == NULL)
|
|
|
|
|
return 1;
|
|
|
|
|
else if (val1 == NULL || val2 == NULL)
|
|
|
|
|
return 0;
|
|
|
|
|
|
2005-02-20 02:19:24 +01:00
|
|
|
|
/* The contents of VAL1 are supposed to be known. */
|
|
|
|
|
gdb_assert (!value_lazy (val1));
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
2005-02-20 02:19:24 +01:00
|
|
|
|
/* Make sure we also know the contents of VAL2. */
|
|
|
|
|
val2 = coerce_array (val2);
|
|
|
|
|
TRY_CATCH (except, RETURN_MASK_ERROR)
|
2000-02-03 05:14:45 +01:00
|
|
|
|
{
|
2005-02-20 02:19:24 +01:00
|
|
|
|
if (value_lazy (val2))
|
|
|
|
|
value_fetch_lazy (val2);
|
|
|
|
|
}
|
|
|
|
|
if (except.reason < 0)
|
|
|
|
|
{
|
|
|
|
|
*error2 = 1;
|
|
|
|
|
return 0;
|
2000-02-03 05:14:45 +01:00
|
|
|
|
}
|
2005-02-20 02:19:24 +01:00
|
|
|
|
gdb_assert (!value_lazy (val2));
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
2005-02-20 02:19:24 +01:00
|
|
|
|
return value_contents_equal (val1, val2);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* FIXME: The following should be generic for any pointer */
|
|
|
|
|
static void
|
2000-07-30 03:48:28 +02:00
|
|
|
|
vpush (struct vstack **pstack, struct varobj *var)
|
2000-02-03 05:14:45 +01:00
|
|
|
|
{
|
|
|
|
|
struct vstack *s;
|
|
|
|
|
|
|
|
|
|
s = (struct vstack *) xmalloc (sizeof (struct vstack));
|
|
|
|
|
s->var = var;
|
|
|
|
|
s->next = *pstack;
|
|
|
|
|
*pstack = s;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* FIXME: The following should be generic for any pointer */
|
|
|
|
|
static struct varobj *
|
2000-07-30 03:48:28 +02:00
|
|
|
|
vpop (struct vstack **pstack)
|
2000-02-03 05:14:45 +01:00
|
|
|
|
{
|
|
|
|
|
struct vstack *s;
|
|
|
|
|
struct varobj *v;
|
|
|
|
|
|
|
|
|
|
if ((*pstack)->var == NULL && (*pstack)->next == NULL)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
s = *pstack;
|
|
|
|
|
v = s->var;
|
|
|
|
|
*pstack = (*pstack)->next;
|
2000-12-15 02:01:51 +01:00
|
|
|
|
xfree (s);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
|
|
|
|
return v;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* FIXME: The following should be generic for any pointer */
|
|
|
|
|
static void
|
2000-07-30 03:48:28 +02:00
|
|
|
|
cppush (struct cpstack **pstack, char *name)
|
2000-02-03 05:14:45 +01:00
|
|
|
|
{
|
|
|
|
|
struct cpstack *s;
|
|
|
|
|
|
|
|
|
|
s = (struct cpstack *) xmalloc (sizeof (struct cpstack));
|
|
|
|
|
s->name = name;
|
|
|
|
|
s->next = *pstack;
|
|
|
|
|
*pstack = s;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* FIXME: The following should be generic for any pointer */
|
|
|
|
|
static char *
|
2000-07-30 03:48:28 +02:00
|
|
|
|
cppop (struct cpstack **pstack)
|
2000-02-03 05:14:45 +01:00
|
|
|
|
{
|
|
|
|
|
struct cpstack *s;
|
|
|
|
|
char *v;
|
|
|
|
|
|
|
|
|
|
if ((*pstack)->name == NULL && (*pstack)->next == NULL)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
s = *pstack;
|
|
|
|
|
v = s->name;
|
|
|
|
|
*pstack = (*pstack)->next;
|
2000-12-15 02:01:51 +01:00
|
|
|
|
xfree (s);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
|
|
|
|
return v;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Language-dependencies
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/* Common entry points */
|
|
|
|
|
|
|
|
|
|
/* Get the language of variable VAR. */
|
|
|
|
|
static enum varobj_languages
|
2000-07-30 03:48:28 +02:00
|
|
|
|
variable_language (struct varobj *var)
|
2000-02-03 05:14:45 +01:00
|
|
|
|
{
|
|
|
|
|
enum varobj_languages lang;
|
|
|
|
|
|
|
|
|
|
switch (var->root->exp->language_defn->la_language)
|
|
|
|
|
{
|
|
|
|
|
default:
|
|
|
|
|
case language_c:
|
|
|
|
|
lang = vlang_c;
|
|
|
|
|
break;
|
|
|
|
|
case language_cplus:
|
|
|
|
|
lang = vlang_cplus;
|
|
|
|
|
break;
|
|
|
|
|
case language_java:
|
|
|
|
|
lang = vlang_java;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return lang;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Return the number of children for a given variable.
|
|
|
|
|
The result of this function is defined by the language
|
|
|
|
|
implementation. The number of children returned by this function
|
|
|
|
|
is the number of children that the user will see in the variable
|
|
|
|
|
display. */
|
|
|
|
|
static int
|
2000-07-30 03:48:28 +02:00
|
|
|
|
number_of_children (struct varobj *var)
|
2000-02-03 05:14:45 +01:00
|
|
|
|
{
|
|
|
|
|
return (*var->root->lang->number_of_children) (var);;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* What is the expression for the root varobj VAR? Returns a malloc'd string. */
|
|
|
|
|
static char *
|
2000-07-30 03:48:28 +02:00
|
|
|
|
name_of_variable (struct varobj *var)
|
2000-02-03 05:14:45 +01:00
|
|
|
|
{
|
|
|
|
|
return (*var->root->lang->name_of_variable) (var);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* What is the name of the INDEX'th child of VAR? Returns a malloc'd string. */
|
|
|
|
|
static char *
|
2000-07-30 03:48:28 +02:00
|
|
|
|
name_of_child (struct varobj *var, int index)
|
2000-02-03 05:14:45 +01:00
|
|
|
|
{
|
|
|
|
|
return (*var->root->lang->name_of_child) (var, index);
|
|
|
|
|
}
|
|
|
|
|
|
2001-11-01 03:37:56 +01:00
|
|
|
|
/* What is the ``struct value *'' of the root variable VAR?
|
2000-03-13 22:51:46 +01:00
|
|
|
|
TYPE_CHANGED controls what to do if the type of a
|
|
|
|
|
use_selected_frame = 1 variable changes. On input,
|
|
|
|
|
TYPE_CHANGED = 1 means discard the old varobj, and replace
|
|
|
|
|
it with this one. TYPE_CHANGED = 0 means leave it around.
|
|
|
|
|
NB: In both cases, var_handle will point to the new varobj,
|
|
|
|
|
so if you use TYPE_CHANGED = 0, you will have to stash the
|
|
|
|
|
old varobj pointer away somewhere before calling this.
|
|
|
|
|
On return, TYPE_CHANGED will be 1 if the type has changed, and
|
|
|
|
|
0 otherwise. */
|
2001-11-01 03:37:56 +01:00
|
|
|
|
static struct value *
|
2000-07-30 03:48:28 +02:00
|
|
|
|
value_of_root (struct varobj **var_handle, int *type_changed)
|
2000-02-03 05:14:45 +01:00
|
|
|
|
{
|
2000-03-13 22:51:46 +01:00
|
|
|
|
struct varobj *var;
|
|
|
|
|
|
|
|
|
|
if (var_handle == NULL)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
var = *var_handle;
|
|
|
|
|
|
|
|
|
|
/* This should really be an exception, since this should
|
|
|
|
|
only get called with a root variable. */
|
|
|
|
|
|
|
|
|
|
if (var->root->rootvar != var)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
if (var->root->use_selected_frame)
|
|
|
|
|
{
|
|
|
|
|
struct varobj *tmp_var;
|
|
|
|
|
char *old_type, *new_type;
|
|
|
|
|
old_type = varobj_get_type (var);
|
|
|
|
|
tmp_var = varobj_create (NULL, var->name, (CORE_ADDR) 0,
|
|
|
|
|
USE_SELECTED_FRAME);
|
|
|
|
|
if (tmp_var == NULL)
|
|
|
|
|
{
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
new_type = varobj_get_type (tmp_var);
|
2001-11-01 03:22:21 +01:00
|
|
|
|
if (strcmp (old_type, new_type) == 0)
|
2000-03-13 22:51:46 +01:00
|
|
|
|
{
|
|
|
|
|
varobj_delete (tmp_var, NULL, 0);
|
|
|
|
|
*type_changed = 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (*type_changed)
|
|
|
|
|
{
|
2001-11-01 03:22:21 +01:00
|
|
|
|
tmp_var->obj_name =
|
2000-03-13 22:51:46 +01:00
|
|
|
|
savestring (var->obj_name, strlen (var->obj_name));
|
2001-05-10 18:57:01 +02:00
|
|
|
|
varobj_delete (var, NULL, 0);
|
2000-03-13 22:51:46 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2001-11-01 03:22:21 +01:00
|
|
|
|
tmp_var->obj_name = varobj_gen_name ();
|
2000-03-13 22:51:46 +01:00
|
|
|
|
}
|
|
|
|
|
install_variable (tmp_var);
|
|
|
|
|
*var_handle = tmp_var;
|
2001-08-17 20:56:49 +02:00
|
|
|
|
var = *var_handle;
|
2000-03-13 22:51:46 +01:00
|
|
|
|
*type_changed = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
*type_changed = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (*var->root->lang->value_of_root) (var_handle);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
}
|
|
|
|
|
|
2001-11-01 03:37:56 +01:00
|
|
|
|
/* What is the ``struct value *'' for the INDEX'th child of PARENT? */
|
|
|
|
|
static struct value *
|
2000-07-30 03:48:28 +02:00
|
|
|
|
value_of_child (struct varobj *parent, int index)
|
2000-02-03 05:14:45 +01:00
|
|
|
|
{
|
2001-11-01 03:37:56 +01:00
|
|
|
|
struct value *value;
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
|
|
|
|
value = (*parent->root->lang->value_of_child) (parent, index);
|
|
|
|
|
|
|
|
|
|
/* If we're being lazy, fetch the real value of the variable. */
|
2005-02-02 23:34:36 +01:00
|
|
|
|
if (value != NULL && value_lazy (value))
|
2002-01-13 21:17:55 +01:00
|
|
|
|
{
|
|
|
|
|
/* If we fail to fetch the value of the child, return
|
2002-06-15 20:45:32 +02:00
|
|
|
|
NULL so that callers notice that we're leaving an
|
|
|
|
|
error message. */
|
2002-01-13 21:17:55 +01:00
|
|
|
|
if (!gdb_value_fetch_lazy (value))
|
|
|
|
|
value = NULL;
|
|
|
|
|
}
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
|
|
|
|
return value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* What is the type of VAR? */
|
|
|
|
|
static struct type *
|
2000-07-30 03:48:28 +02:00
|
|
|
|
type_of_child (struct varobj *var)
|
2000-02-03 05:14:45 +01:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
/* If the child had no evaluation errors, var->value
|
|
|
|
|
will be non-NULL and contain a valid type. */
|
|
|
|
|
if (var->value != NULL)
|
2004-11-12 Andrew Cagney <cagney@gnu.org>
* value.h (VALUE_TYPE, VALUE_NEXT, VALUE_OFFSET, VALUE_BITSIZE)
(VALUE_BITPOS): Delete.
(value_type, value_offset, value_bitsize, value_bitpos): Declare.
* value.c (value_type, value_offset, value_bitpos)
(value_bitsize): New functions. Update references.
* arm-tdep.c, gnu-v3-abi.c, hpacc-abi.c, gnu-v2-abi.c: Update.
* f-valprint.c, cp-valprint.c, c-valprint.c: Update.
* ada-valprint.c, typeprint.c, scm-valprint.c, scm-exp.c: Update.
* p-valprint.c, jv-valprint.c, jv-lang.c, varobj.c: Update.
* objc-lang.c, ada-lang.c, std-regs.c, stack.c: Update.
* infcall.c, linespec.c, printcmd.c, valarith.c: Update.
* valops.c, eval.c, findvar.c, breakpoint.c: Update.
* tracepoint.c, ax-gdb.c, mi/mi-main.c, cli/cli-dump.c:
* rs6000-tdep.c, ppc-sysv-tdep.c: Update.
2004-11-12 22:45:08 +01:00
|
|
|
|
return value_type (var->value);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
|
|
|
|
/* Otherwise, we must compute the type. */
|
|
|
|
|
return (*var->root->lang->type_of_child) (var->parent, var->index);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Is this variable editable? Use the variable's type to make
|
|
|
|
|
this determination. */
|
|
|
|
|
static int
|
2000-07-30 03:48:28 +02:00
|
|
|
|
variable_editable (struct varobj *var)
|
2000-02-03 05:14:45 +01:00
|
|
|
|
{
|
|
|
|
|
return (*var->root->lang->variable_editable) (var);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* GDB already has a command called "value_of_variable". Sigh. */
|
|
|
|
|
static char *
|
2000-07-30 03:48:28 +02:00
|
|
|
|
my_value_of_variable (struct varobj *var)
|
2000-02-03 05:14:45 +01:00
|
|
|
|
{
|
|
|
|
|
return (*var->root->lang->value_of_variable) (var);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Is VAR something that can change? Depending on language,
|
|
|
|
|
some variable's values never change. For example,
|
|
|
|
|
struct and unions never change values. */
|
|
|
|
|
static int
|
2000-07-30 03:48:28 +02:00
|
|
|
|
type_changeable (struct varobj *var)
|
2000-02-03 05:14:45 +01:00
|
|
|
|
{
|
|
|
|
|
int r;
|
|
|
|
|
struct type *type;
|
|
|
|
|
|
|
|
|
|
if (CPLUS_FAKE_CHILD (var))
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
type = get_type (var);
|
|
|
|
|
|
|
|
|
|
switch (TYPE_CODE (type))
|
|
|
|
|
{
|
2001-11-01 03:22:21 +01:00
|
|
|
|
case TYPE_CODE_STRUCT:
|
|
|
|
|
case TYPE_CODE_UNION:
|
|
|
|
|
case TYPE_CODE_ARRAY:
|
|
|
|
|
r = 0;
|
|
|
|
|
break;
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
2001-11-01 03:22:21 +01:00
|
|
|
|
default:
|
|
|
|
|
r = 1;
|
2000-02-03 05:14:45 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return r;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* C */
|
|
|
|
|
static int
|
2000-07-30 03:48:28 +02:00
|
|
|
|
c_number_of_children (struct varobj *var)
|
2000-02-03 05:14:45 +01:00
|
|
|
|
{
|
|
|
|
|
struct type *type;
|
|
|
|
|
struct type *target;
|
|
|
|
|
int children;
|
|
|
|
|
|
|
|
|
|
type = get_type (var);
|
|
|
|
|
target = get_target_type (type);
|
|
|
|
|
children = 0;
|
|
|
|
|
|
|
|
|
|
switch (TYPE_CODE (type))
|
|
|
|
|
{
|
|
|
|
|
case TYPE_CODE_ARRAY:
|
|
|
|
|
if (TYPE_LENGTH (type) > 0 && TYPE_LENGTH (target) > 0
|
2001-11-01 03:22:21 +01:00
|
|
|
|
&& TYPE_ARRAY_UPPER_BOUND_TYPE (type) != BOUND_CANNOT_BE_DETERMINED)
|
2000-02-03 05:14:45 +01:00
|
|
|
|
children = TYPE_LENGTH (type) / TYPE_LENGTH (target);
|
|
|
|
|
else
|
|
|
|
|
children = -1;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case TYPE_CODE_STRUCT:
|
|
|
|
|
case TYPE_CODE_UNION:
|
|
|
|
|
children = TYPE_NFIELDS (type);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case TYPE_CODE_PTR:
|
|
|
|
|
/* This is where things get compilcated. All pointers have one child.
|
|
|
|
|
Except, of course, for struct and union ptr, which we automagically
|
2001-05-10 18:44:56 +02:00
|
|
|
|
dereference for the user and function ptrs, which have no children.
|
|
|
|
|
We also don't dereference void* as we don't know what to show.
|
|
|
|
|
We can show char* so we allow it to be dereferenced. If you decide
|
|
|
|
|
to test for it, please mind that a little magic is necessary to
|
|
|
|
|
properly identify it: char* has TYPE_CODE == TYPE_CODE_INT and
|
|
|
|
|
TYPE_NAME == "char" */
|
|
|
|
|
|
2000-02-03 05:14:45 +01:00
|
|
|
|
switch (TYPE_CODE (target))
|
|
|
|
|
{
|
|
|
|
|
case TYPE_CODE_STRUCT:
|
|
|
|
|
case TYPE_CODE_UNION:
|
|
|
|
|
children = TYPE_NFIELDS (target);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case TYPE_CODE_FUNC:
|
2001-05-10 18:44:56 +02:00
|
|
|
|
case TYPE_CODE_VOID:
|
2000-02-03 05:14:45 +01:00
|
|
|
|
children = 0;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
2001-05-10 18:44:56 +02:00
|
|
|
|
children = 1;
|
2000-02-03 05:14:45 +01:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
/* Other types have no children */
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return children;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static char *
|
2000-07-30 03:48:28 +02:00
|
|
|
|
c_name_of_variable (struct varobj *parent)
|
2000-02-03 05:14:45 +01:00
|
|
|
|
{
|
|
|
|
|
return savestring (parent->name, strlen (parent->name));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static char *
|
2000-07-30 03:48:28 +02:00
|
|
|
|
c_name_of_child (struct varobj *parent, int index)
|
2000-02-03 05:14:45 +01:00
|
|
|
|
{
|
|
|
|
|
struct type *type;
|
|
|
|
|
struct type *target;
|
|
|
|
|
char *name;
|
|
|
|
|
char *string;
|
|
|
|
|
|
|
|
|
|
type = get_type (parent);
|
|
|
|
|
target = get_target_type (type);
|
|
|
|
|
|
|
|
|
|
switch (TYPE_CODE (type))
|
|
|
|
|
{
|
|
|
|
|
case TYPE_CODE_ARRAY:
|
2006-03-27 02:15:22 +02:00
|
|
|
|
name = xstrprintf ("%d", index
|
|
|
|
|
+ TYPE_LOW_BOUND (TYPE_INDEX_TYPE (type)));
|
2000-02-03 05:14:45 +01:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case TYPE_CODE_STRUCT:
|
|
|
|
|
case TYPE_CODE_UNION:
|
|
|
|
|
string = TYPE_FIELD_NAME (type, index);
|
|
|
|
|
name = savestring (string, strlen (string));
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case TYPE_CODE_PTR:
|
|
|
|
|
switch (TYPE_CODE (target))
|
|
|
|
|
{
|
|
|
|
|
case TYPE_CODE_STRUCT:
|
|
|
|
|
case TYPE_CODE_UNION:
|
|
|
|
|
string = TYPE_FIELD_NAME (target, index);
|
|
|
|
|
name = savestring (string, strlen (string));
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
2004-06-29 01:59:29 +02:00
|
|
|
|
name = xstrprintf ("*%s", parent->name);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
/* This should not happen */
|
|
|
|
|
name = xstrdup ("???");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return name;
|
|
|
|
|
}
|
|
|
|
|
|
2001-11-01 03:37:56 +01:00
|
|
|
|
static struct value *
|
2000-07-30 03:48:28 +02:00
|
|
|
|
c_value_of_root (struct varobj **var_handle)
|
2000-02-03 05:14:45 +01:00
|
|
|
|
{
|
2001-11-01 03:37:56 +01:00
|
|
|
|
struct value *new_val;
|
2000-03-13 22:51:46 +01:00
|
|
|
|
struct varobj *var = *var_handle;
|
2000-02-03 05:14:45 +01:00
|
|
|
|
struct frame_info *fi;
|
|
|
|
|
int within_scope;
|
|
|
|
|
|
2000-03-13 22:51:46 +01:00
|
|
|
|
/* Only root variables can be updated... */
|
|
|
|
|
if (var->root->rootvar != var)
|
|
|
|
|
/* Not a root var */
|
|
|
|
|
return NULL;
|
|
|
|
|
|
2001-11-01 03:22:21 +01:00
|
|
|
|
|
2000-02-03 05:14:45 +01:00
|
|
|
|
/* Determine whether the variable is still around. */
|
|
|
|
|
if (var->root->valid_block == NULL)
|
|
|
|
|
within_scope = 1;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
reinit_frame_cache ();
|
2002-07-03 22:23:04 +02:00
|
|
|
|
fi = frame_find_by_id (var->root->frame);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
within_scope = fi != NULL;
|
|
|
|
|
/* FIXME: select_frame could fail */
|
|
|
|
|
if (within_scope)
|
2002-05-05 03:15:13 +02:00
|
|
|
|
select_frame (fi);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
}
|
2001-11-01 03:22:21 +01:00
|
|
|
|
|
2000-02-03 05:14:45 +01:00
|
|
|
|
if (within_scope)
|
|
|
|
|
{
|
2000-03-13 22:51:46 +01:00
|
|
|
|
/* We need to catch errors here, because if evaluate
|
2001-11-01 03:22:21 +01:00
|
|
|
|
expression fails we just want to make val->error = 1 and
|
|
|
|
|
go on */
|
2000-02-03 05:14:45 +01:00
|
|
|
|
if (gdb_evaluate_expression (var->root->exp, &new_val))
|
|
|
|
|
{
|
2005-02-02 23:34:36 +01:00
|
|
|
|
if (value_lazy (new_val))
|
2000-02-03 05:14:45 +01:00
|
|
|
|
{
|
2000-03-13 22:51:46 +01:00
|
|
|
|
/* We need to catch errors because if
|
2001-11-01 03:22:21 +01:00
|
|
|
|
value_fetch_lazy fails we still want to continue
|
|
|
|
|
(after making val->error = 1) */
|
2005-02-06 Andrew Cagney <cagney@gnu.org>
* value.c (value_contents, value_contents_writeable): New
functions.
* value.h (VALUE_CONTENTS): Delete macro.
(value_contents, value_contents_writeable): Declare.
* xstormy16-tdep.c, value.c, valops.c, valarith.c: Update.
* stack.c, sparc-tdep.c, sparc64-tdep.c, sh-tdep.c: Update.
* sh64-tdep.c, scm-valprint.c, scm-exp.c, s390-tdep.c: Update.
* rs6000-tdep.c, p-valprint.c, printcmd.c: Update.
* ppc-sysv-tdep.c, mips-tdep.c, mi/mi-main.c: Update.
* m88k-tdep.c, m68hc11-tdep.c, m32r-tdep.c: Update.
* jv-valprint.c, ia64-tdep.c, hppa-tdep.c: Update.
* hpacc-abi.c, f-valprint.c, frv-tdep.c, eval.c: Update.
* c-valprint.c, cris-tdep.c, cp-valprint.c: Update.
* cli/cli-dump.c, breakpoint.c, avr-tdep.c, arm-tdep.c: Update.
* arm-linux-tdep.c, amd64-tdep.c, alpha-tdep.c: Update.
* ada-valprint.c, ada-lang.c: Update.
2005-02-07 01:09:56 +01:00
|
|
|
|
/* FIXME: Shouldn't be using value_contents()? The
|
|
|
|
|
comment on value_fetch_lazy() says it is only called
|
|
|
|
|
from the macro... */
|
2000-02-03 05:14:45 +01:00
|
|
|
|
if (!gdb_value_fetch_lazy (new_val))
|
|
|
|
|
var->error = 1;
|
|
|
|
|
else
|
|
|
|
|
var->error = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
var->error = 1;
|
2001-11-01 03:22:21 +01:00
|
|
|
|
|
2000-02-03 05:14:45 +01:00
|
|
|
|
release_value (new_val);
|
|
|
|
|
return new_val;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2001-11-01 03:37:56 +01:00
|
|
|
|
static struct value *
|
2000-07-30 03:48:28 +02:00
|
|
|
|
c_value_of_child (struct varobj *parent, int index)
|
2000-02-03 05:14:45 +01:00
|
|
|
|
{
|
2001-11-01 03:37:56 +01:00
|
|
|
|
struct value *value;
|
|
|
|
|
struct value *temp;
|
|
|
|
|
struct value *indval;
|
2000-02-03 05:14:45 +01:00
|
|
|
|
struct type *type, *target;
|
|
|
|
|
char *name;
|
2006-03-27 02:15:22 +02:00
|
|
|
|
int real_index;
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
|
|
|
|
type = get_type (parent);
|
|
|
|
|
target = get_target_type (type);
|
|
|
|
|
name = name_of_child (parent, index);
|
|
|
|
|
temp = parent->value;
|
|
|
|
|
value = NULL;
|
|
|
|
|
|
|
|
|
|
if (temp != NULL)
|
|
|
|
|
{
|
|
|
|
|
switch (TYPE_CODE (type))
|
|
|
|
|
{
|
|
|
|
|
case TYPE_CODE_ARRAY:
|
2006-03-27 02:15:22 +02:00
|
|
|
|
real_index = index + TYPE_LOW_BOUND (TYPE_INDEX_TYPE (type));
|
2000-03-30 22:15:35 +02:00
|
|
|
|
#if 0
|
2001-11-01 03:22:21 +01:00
|
|
|
|
/* This breaks if the array lives in a (vector) register. */
|
2006-03-27 02:15:22 +02:00
|
|
|
|
value = value_slice (temp, real_index, 1);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
temp = value_coerce_array (value);
|
|
|
|
|
gdb_value_ind (temp, &value);
|
2000-03-30 22:15:35 +02:00
|
|
|
|
#else
|
2006-03-27 02:15:22 +02:00
|
|
|
|
indval = value_from_longest (builtin_type_int, (LONGEST) real_index);
|
2000-03-30 22:15:35 +02:00
|
|
|
|
gdb_value_subscript (temp, indval, &value);
|
|
|
|
|
#endif
|
2000-02-03 05:14:45 +01:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case TYPE_CODE_STRUCT:
|
|
|
|
|
case TYPE_CODE_UNION:
|
2002-06-15 20:45:32 +02:00
|
|
|
|
gdb_value_struct_elt (NULL, &value, &temp, NULL, name, NULL,
|
|
|
|
|
"vstructure");
|
2000-02-03 05:14:45 +01:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case TYPE_CODE_PTR:
|
|
|
|
|
switch (TYPE_CODE (target))
|
|
|
|
|
{
|
|
|
|
|
case TYPE_CODE_STRUCT:
|
|
|
|
|
case TYPE_CODE_UNION:
|
2002-06-15 20:45:32 +02:00
|
|
|
|
gdb_value_struct_elt (NULL, &value, &temp, NULL, name, NULL,
|
|
|
|
|
"vstructure");
|
2000-02-03 05:14:45 +01:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
gdb_value_ind (temp, &value);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (value != NULL)
|
|
|
|
|
release_value (value);
|
|
|
|
|
|
2001-11-20 19:08:14 +01:00
|
|
|
|
xfree (name);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
return value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static struct type *
|
2000-07-30 03:48:28 +02:00
|
|
|
|
c_type_of_child (struct varobj *parent, int index)
|
2000-02-03 05:14:45 +01:00
|
|
|
|
{
|
|
|
|
|
struct type *type;
|
|
|
|
|
char *name = name_of_child (parent, index);
|
|
|
|
|
|
|
|
|
|
switch (TYPE_CODE (parent->type))
|
|
|
|
|
{
|
|
|
|
|
case TYPE_CODE_ARRAY:
|
2002-09-24 20:50:34 +02:00
|
|
|
|
type = get_target_type (parent->type);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case TYPE_CODE_STRUCT:
|
|
|
|
|
case TYPE_CODE_UNION:
|
|
|
|
|
type = lookup_struct_elt_type (parent->type, name, 0);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case TYPE_CODE_PTR:
|
2002-09-24 20:50:34 +02:00
|
|
|
|
switch (TYPE_CODE (get_target_type (parent->type)))
|
2000-02-03 05:14:45 +01:00
|
|
|
|
{
|
|
|
|
|
case TYPE_CODE_STRUCT:
|
|
|
|
|
case TYPE_CODE_UNION:
|
|
|
|
|
type = lookup_struct_elt_type (parent->type, name, 0);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
2002-09-24 20:50:34 +02:00
|
|
|
|
type = get_target_type (parent->type);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
/* This should not happen as only the above types have children */
|
2005-02-10 Andrew Cagney <cagney@gnu.org>
Mark up all error and warning messages.
* ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update.
* bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update.
* core-aout.c, core-regset.c, corefile.c, corelow.c: Update.
* cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update.
* dbxread.c, demangle.c, doublest.c, dsrec.c: Update.
* dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update.
* event-top.c, exec.c, expprint.c, f-lang.c: Update.
* f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update.
* frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update.
* gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update.
* hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update.
* hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update.
* hpread.c, hpux-thread.c, i386-linux-nat.c: Update.
* i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update.
* ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update.
* infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update.
* inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update.
* kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update.
* linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update.
* m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update.
* m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update.
* maint.c, mdebugread.c, mem-break.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update.
* nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update.
* observer.c, ocd.c, p-lang.c, p-typeprint.c: Update.
* p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update.
* ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update.
* remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update.
* remote-rdp.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote-utils.h, remote.c: Update.
* rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update.
* ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update.
* sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update.
* solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update.
* solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update.
* somread.c, somsolib.c, source.c, stabsread.c: Update.
* stack.c, std-regs.c, symfile-mem.c, symfile.c: Update.
* symmisc.c, symtab.c, target.c, thread.c, top.c: Update.
* tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update.
* uw-thread.c, valarith.c, valops.c, valprint.c: Update.
* value.c, varobj.c, version.in, win32-nat.c, wince.c: Update.
* xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update.
* cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update.
* cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update.
* mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update.
* mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update.
* mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update.
* tui/tui-win.c: Update.
2005-02-11 05:06:14 +01:00
|
|
|
|
warning (_("Child of parent whose type does not allow children"));
|
2000-02-03 05:14:45 +01:00
|
|
|
|
/* FIXME: Can we still go on? */
|
|
|
|
|
type = NULL;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2001-11-20 19:08:14 +01:00
|
|
|
|
xfree (name);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
return type;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int
|
2000-07-30 03:48:28 +02:00
|
|
|
|
c_variable_editable (struct varobj *var)
|
2000-02-03 05:14:45 +01:00
|
|
|
|
{
|
|
|
|
|
switch (TYPE_CODE (get_type (var)))
|
|
|
|
|
{
|
|
|
|
|
case TYPE_CODE_STRUCT:
|
|
|
|
|
case TYPE_CODE_UNION:
|
|
|
|
|
case TYPE_CODE_ARRAY:
|
|
|
|
|
case TYPE_CODE_FUNC:
|
|
|
|
|
case TYPE_CODE_MEMBER:
|
|
|
|
|
case TYPE_CODE_METHOD:
|
|
|
|
|
return 0;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
return 1;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static char *
|
2000-07-30 03:48:28 +02:00
|
|
|
|
c_value_of_variable (struct varobj *var)
|
2000-02-03 05:14:45 +01:00
|
|
|
|
{
|
|
|
|
|
/* BOGUS: if val_print sees a struct/class, it will print out its
|
|
|
|
|
children instead of "{...}" */
|
2002-07-03 22:23:04 +02:00
|
|
|
|
|
|
|
|
|
switch (TYPE_CODE (get_type (var)))
|
2000-02-03 05:14:45 +01:00
|
|
|
|
{
|
|
|
|
|
case TYPE_CODE_STRUCT:
|
|
|
|
|
case TYPE_CODE_UNION:
|
|
|
|
|
return xstrdup ("{...}");
|
|
|
|
|
/* break; */
|
|
|
|
|
|
|
|
|
|
case TYPE_CODE_ARRAY:
|
|
|
|
|
{
|
2002-07-03 22:23:04 +02:00
|
|
|
|
char *number;
|
2004-06-29 01:59:29 +02:00
|
|
|
|
number = xstrprintf ("[%d]", var->num_children);
|
2002-07-03 22:23:04 +02:00
|
|
|
|
return (number);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
}
|
|
|
|
|
/* break; */
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
{
|
2002-01-13 21:17:55 +01:00
|
|
|
|
if (var->value == NULL)
|
|
|
|
|
{
|
|
|
|
|
/* This can happen if we attempt to get the value of a struct
|
|
|
|
|
member when the parent is an invalid pointer. This is an
|
|
|
|
|
error condition, so we should tell the caller. */
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2002-07-03 22:23:04 +02:00
|
|
|
|
long dummy;
|
|
|
|
|
struct ui_file *stb = mem_fileopen ();
|
|
|
|
|
struct cleanup *old_chain = make_cleanup_ui_file_delete (stb);
|
|
|
|
|
char *thevalue;
|
|
|
|
|
|
2005-02-02 23:34:36 +01:00
|
|
|
|
if (value_lazy (var->value))
|
2002-01-13 21:17:55 +01:00
|
|
|
|
gdb_value_fetch_lazy (var->value);
|
2005-02-28 18:00:49 +01:00
|
|
|
|
common_val_print (var->value, stb,
|
|
|
|
|
format_code[(int) var->format], 1, 0, 0);
|
2002-01-13 21:17:55 +01:00
|
|
|
|
thevalue = ui_file_xstrdup (stb, &dummy);
|
|
|
|
|
do_cleanups (old_chain);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
return thevalue;
|
|
|
|
|
}
|
2002-07-03 22:23:04 +02:00
|
|
|
|
}
|
2000-02-03 05:14:45 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* C++ */
|
|
|
|
|
|
|
|
|
|
static int
|
2000-07-30 03:48:28 +02:00
|
|
|
|
cplus_number_of_children (struct varobj *var)
|
2000-02-03 05:14:45 +01:00
|
|
|
|
{
|
|
|
|
|
struct type *type;
|
|
|
|
|
int children, dont_know;
|
|
|
|
|
|
|
|
|
|
dont_know = 1;
|
|
|
|
|
children = 0;
|
|
|
|
|
|
|
|
|
|
if (!CPLUS_FAKE_CHILD (var))
|
|
|
|
|
{
|
|
|
|
|
type = get_type_deref (var);
|
|
|
|
|
|
|
|
|
|
if (((TYPE_CODE (type)) == TYPE_CODE_STRUCT) ||
|
2001-11-01 03:22:21 +01:00
|
|
|
|
((TYPE_CODE (type)) == TYPE_CODE_UNION))
|
2000-02-03 05:14:45 +01:00
|
|
|
|
{
|
|
|
|
|
int kids[3];
|
|
|
|
|
|
|
|
|
|
cplus_class_num_children (type, kids);
|
|
|
|
|
if (kids[v_public] != 0)
|
|
|
|
|
children++;
|
|
|
|
|
if (kids[v_private] != 0)
|
|
|
|
|
children++;
|
|
|
|
|
if (kids[v_protected] != 0)
|
|
|
|
|
children++;
|
|
|
|
|
|
|
|
|
|
/* Add any baseclasses */
|
|
|
|
|
children += TYPE_N_BASECLASSES (type);
|
|
|
|
|
dont_know = 0;
|
|
|
|
|
|
|
|
|
|
/* FIXME: save children in var */
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
int kids[3];
|
|
|
|
|
|
|
|
|
|
type = get_type_deref (var->parent);
|
|
|
|
|
|
|
|
|
|
cplus_class_num_children (type, kids);
|
2002-11-05 23:31:00 +01:00
|
|
|
|
if (strcmp (var->name, "public") == 0)
|
2000-02-03 05:14:45 +01:00
|
|
|
|
children = kids[v_public];
|
2002-11-05 23:31:00 +01:00
|
|
|
|
else if (strcmp (var->name, "private") == 0)
|
2000-02-03 05:14:45 +01:00
|
|
|
|
children = kids[v_private];
|
|
|
|
|
else
|
|
|
|
|
children = kids[v_protected];
|
|
|
|
|
dont_know = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (dont_know)
|
|
|
|
|
children = c_number_of_children (var);
|
|
|
|
|
|
|
|
|
|
return children;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Compute # of public, private, and protected variables in this class.
|
|
|
|
|
That means we need to descend into all baseclasses and find out
|
|
|
|
|
how many are there, too. */
|
|
|
|
|
static void
|
2000-11-10 02:19:47 +01:00
|
|
|
|
cplus_class_num_children (struct type *type, int children[3])
|
2000-02-03 05:14:45 +01:00
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
children[v_public] = 0;
|
|
|
|
|
children[v_private] = 0;
|
|
|
|
|
children[v_protected] = 0;
|
|
|
|
|
|
|
|
|
|
for (i = TYPE_N_BASECLASSES (type); i < TYPE_NFIELDS (type); i++)
|
|
|
|
|
{
|
|
|
|
|
/* If we have a virtual table pointer, omit it. */
|
2001-11-01 03:22:21 +01:00
|
|
|
|
if (TYPE_VPTR_BASETYPE (type) == type && TYPE_VPTR_FIELDNO (type) == i)
|
2000-02-03 05:14:45 +01:00
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
if (TYPE_FIELD_PROTECTED (type, i))
|
|
|
|
|
children[v_protected]++;
|
|
|
|
|
else if (TYPE_FIELD_PRIVATE (type, i))
|
|
|
|
|
children[v_private]++;
|
|
|
|
|
else
|
|
|
|
|
children[v_public]++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static char *
|
2000-07-30 03:48:28 +02:00
|
|
|
|
cplus_name_of_variable (struct varobj *parent)
|
2000-02-03 05:14:45 +01:00
|
|
|
|
{
|
|
|
|
|
return c_name_of_variable (parent);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static char *
|
2000-07-30 03:48:28 +02:00
|
|
|
|
cplus_name_of_child (struct varobj *parent, int index)
|
2000-02-03 05:14:45 +01:00
|
|
|
|
{
|
|
|
|
|
char *name;
|
|
|
|
|
struct type *type;
|
|
|
|
|
|
|
|
|
|
if (CPLUS_FAKE_CHILD (parent))
|
|
|
|
|
{
|
|
|
|
|
/* Looking for children of public, private, or protected. */
|
|
|
|
|
type = get_type_deref (parent->parent);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
type = get_type_deref (parent);
|
|
|
|
|
|
|
|
|
|
name = NULL;
|
|
|
|
|
switch (TYPE_CODE (type))
|
|
|
|
|
{
|
|
|
|
|
case TYPE_CODE_STRUCT:
|
|
|
|
|
case TYPE_CODE_UNION:
|
|
|
|
|
if (CPLUS_FAKE_CHILD (parent))
|
|
|
|
|
{
|
2002-11-05 23:31:00 +01:00
|
|
|
|
/* The fields of the class type are ordered as they
|
|
|
|
|
appear in the class. We are given an index for a
|
|
|
|
|
particular access control type ("public","protected",
|
|
|
|
|
or "private"). We must skip over fields that don't
|
|
|
|
|
have the access control we are looking for to properly
|
|
|
|
|
find the indexed field. */
|
|
|
|
|
int type_index = TYPE_N_BASECLASSES (type);
|
|
|
|
|
if (strcmp (parent->name, "private") == 0)
|
|
|
|
|
{
|
|
|
|
|
while (index >= 0)
|
|
|
|
|
{
|
|
|
|
|
if (TYPE_VPTR_BASETYPE (type) == type
|
|
|
|
|
&& type_index == TYPE_VPTR_FIELDNO (type))
|
|
|
|
|
; /* ignore vptr */
|
|
|
|
|
else if (TYPE_FIELD_PRIVATE (type, type_index))
|
|
|
|
|
--index;
|
|
|
|
|
++type_index;
|
|
|
|
|
}
|
|
|
|
|
--type_index;
|
|
|
|
|
}
|
|
|
|
|
else if (strcmp (parent->name, "protected") == 0)
|
|
|
|
|
{
|
|
|
|
|
while (index >= 0)
|
|
|
|
|
{
|
|
|
|
|
if (TYPE_VPTR_BASETYPE (type) == type
|
|
|
|
|
&& type_index == TYPE_VPTR_FIELDNO (type))
|
|
|
|
|
; /* ignore vptr */
|
|
|
|
|
else if (TYPE_FIELD_PROTECTED (type, type_index))
|
|
|
|
|
--index;
|
|
|
|
|
++type_index;
|
|
|
|
|
}
|
|
|
|
|
--type_index;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
while (index >= 0)
|
|
|
|
|
{
|
|
|
|
|
if (TYPE_VPTR_BASETYPE (type) == type
|
|
|
|
|
&& type_index == TYPE_VPTR_FIELDNO (type))
|
|
|
|
|
; /* ignore vptr */
|
|
|
|
|
else if (!TYPE_FIELD_PRIVATE (type, type_index) &&
|
|
|
|
|
!TYPE_FIELD_PROTECTED (type, type_index))
|
|
|
|
|
--index;
|
|
|
|
|
++type_index;
|
|
|
|
|
}
|
|
|
|
|
--type_index;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
name = TYPE_FIELD_NAME (type, type_index);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
}
|
|
|
|
|
else if (index < TYPE_N_BASECLASSES (type))
|
2002-11-05 23:31:00 +01:00
|
|
|
|
/* We are looking up the name of a base class */
|
2000-02-03 05:14:45 +01:00
|
|
|
|
name = TYPE_FIELD_NAME (type, index);
|
|
|
|
|
else
|
|
|
|
|
{
|
2002-11-05 23:31:00 +01:00
|
|
|
|
int children[3];
|
|
|
|
|
cplus_class_num_children(type, children);
|
|
|
|
|
|
2000-02-03 05:14:45 +01:00
|
|
|
|
/* Everything beyond the baseclasses can
|
2002-11-05 23:31:00 +01:00
|
|
|
|
only be "public", "private", or "protected"
|
|
|
|
|
|
|
|
|
|
The special "fake" children are always output by varobj in
|
|
|
|
|
this order. So if INDEX == 2, it MUST be "protected". */
|
2000-02-03 05:14:45 +01:00
|
|
|
|
index -= TYPE_N_BASECLASSES (type);
|
|
|
|
|
switch (index)
|
|
|
|
|
{
|
|
|
|
|
case 0:
|
2002-11-05 23:31:00 +01:00
|
|
|
|
if (children[v_public] > 0)
|
|
|
|
|
name = "public";
|
|
|
|
|
else if (children[v_private] > 0)
|
|
|
|
|
name = "private";
|
|
|
|
|
else
|
|
|
|
|
name = "protected";
|
|
|
|
|
break;
|
2000-02-03 05:14:45 +01:00
|
|
|
|
case 1:
|
2002-11-05 23:31:00 +01:00
|
|
|
|
if (children[v_public] > 0)
|
2000-02-03 05:14:45 +01:00
|
|
|
|
{
|
2002-11-05 23:31:00 +01:00
|
|
|
|
if (children[v_private] > 0)
|
|
|
|
|
name = "private";
|
|
|
|
|
else
|
|
|
|
|
name = "protected";
|
2000-02-03 05:14:45 +01:00
|
|
|
|
}
|
2002-11-05 23:31:00 +01:00
|
|
|
|
else if (children[v_private] > 0)
|
|
|
|
|
name = "protected";
|
|
|
|
|
break;
|
2000-02-03 05:14:45 +01:00
|
|
|
|
case 2:
|
2002-11-05 23:31:00 +01:00
|
|
|
|
/* Must be protected */
|
|
|
|
|
name = "protected";
|
|
|
|
|
break;
|
2000-02-03 05:14:45 +01:00
|
|
|
|
default:
|
|
|
|
|
/* error! */
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (name == NULL)
|
|
|
|
|
return c_name_of_child (parent, index);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (name != NULL)
|
|
|
|
|
name = savestring (name, strlen (name));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return name;
|
|
|
|
|
}
|
|
|
|
|
|
2001-11-01 03:37:56 +01:00
|
|
|
|
static struct value *
|
2000-07-30 03:48:28 +02:00
|
|
|
|
cplus_value_of_root (struct varobj **var_handle)
|
2000-02-03 05:14:45 +01:00
|
|
|
|
{
|
2000-03-13 22:51:46 +01:00
|
|
|
|
return c_value_of_root (var_handle);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
}
|
|
|
|
|
|
2001-11-01 03:37:56 +01:00
|
|
|
|
static struct value *
|
2000-07-30 03:48:28 +02:00
|
|
|
|
cplus_value_of_child (struct varobj *parent, int index)
|
2000-02-03 05:14:45 +01:00
|
|
|
|
{
|
|
|
|
|
struct type *type;
|
2001-11-01 03:37:56 +01:00
|
|
|
|
struct value *value;
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
|
|
|
|
if (CPLUS_FAKE_CHILD (parent))
|
|
|
|
|
type = get_type_deref (parent->parent);
|
|
|
|
|
else
|
|
|
|
|
type = get_type_deref (parent);
|
|
|
|
|
|
|
|
|
|
value = NULL;
|
|
|
|
|
|
|
|
|
|
if (((TYPE_CODE (type)) == TYPE_CODE_STRUCT) ||
|
|
|
|
|
((TYPE_CODE (type)) == TYPE_CODE_UNION))
|
|
|
|
|
{
|
|
|
|
|
if (CPLUS_FAKE_CHILD (parent))
|
|
|
|
|
{
|
2001-11-20 19:08:14 +01:00
|
|
|
|
char *name;
|
2001-11-01 03:37:56 +01:00
|
|
|
|
struct value *temp = parent->parent->value;
|
2001-11-19 20:44:04 +01:00
|
|
|
|
|
2002-01-13 21:17:55 +01:00
|
|
|
|
if (temp == NULL)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
2001-11-20 19:08:14 +01:00
|
|
|
|
name = name_of_child (parent, index);
|
2001-11-19 20:44:04 +01:00
|
|
|
|
gdb_value_struct_elt (NULL, &value, &temp, NULL, name, NULL,
|
|
|
|
|
"cplus_structure");
|
|
|
|
|
if (value != NULL)
|
|
|
|
|
release_value (value);
|
2001-11-20 19:08:14 +01:00
|
|
|
|
|
|
|
|
|
xfree (name);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
}
|
|
|
|
|
else if (index >= TYPE_N_BASECLASSES (type))
|
|
|
|
|
{
|
|
|
|
|
/* public, private, or protected */
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* Baseclass */
|
|
|
|
|
if (parent->value != NULL)
|
|
|
|
|
{
|
2002-01-13 21:17:55 +01:00
|
|
|
|
struct value *temp = NULL;
|
2000-02-03 05:14:45 +01:00
|
|
|
|
|
2004-11-12 Andrew Cagney <cagney@gnu.org>
* value.h (VALUE_TYPE, VALUE_NEXT, VALUE_OFFSET, VALUE_BITSIZE)
(VALUE_BITPOS): Delete.
(value_type, value_offset, value_bitsize, value_bitpos): Declare.
* value.c (value_type, value_offset, value_bitpos)
(value_bitsize): New functions. Update references.
* arm-tdep.c, gnu-v3-abi.c, hpacc-abi.c, gnu-v2-abi.c: Update.
* f-valprint.c, cp-valprint.c, c-valprint.c: Update.
* ada-valprint.c, typeprint.c, scm-valprint.c, scm-exp.c: Update.
* p-valprint.c, jv-valprint.c, jv-lang.c, varobj.c: Update.
* objc-lang.c, ada-lang.c, std-regs.c, stack.c: Update.
* infcall.c, linespec.c, printcmd.c, valarith.c: Update.
* valops.c, eval.c, findvar.c, breakpoint.c: Update.
* tracepoint.c, ax-gdb.c, mi/mi-main.c, cli/cli-dump.c:
* rs6000-tdep.c, ppc-sysv-tdep.c: Update.
2004-11-12 22:45:08 +01:00
|
|
|
|
if (TYPE_CODE (value_type (parent->value)) == TYPE_CODE_PTR
|
|
|
|
|
|| TYPE_CODE (value_type (parent->value)) == TYPE_CODE_REF)
|
2001-10-10 19:01:52 +02:00
|
|
|
|
{
|
|
|
|
|
if (!gdb_value_ind (parent->value, &temp))
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2000-02-03 05:14:45 +01:00
|
|
|
|
else
|
|
|
|
|
temp = parent->value;
|
|
|
|
|
|
2002-01-13 21:17:55 +01:00
|
|
|
|
if (temp != NULL)
|
|
|
|
|
{
|
|
|
|
|
value = value_cast (TYPE_FIELD_TYPE (type, index), temp);
|
|
|
|
|
release_value (value);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* We failed to evaluate the parent's value, so don't even
|
|
|
|
|
bother trying to evaluate this child. */
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2000-02-03 05:14:45 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (value == NULL)
|
|
|
|
|
return c_value_of_child (parent, index);
|
|
|
|
|
|
|
|
|
|
return value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static struct type *
|
2000-07-30 03:48:28 +02:00
|
|
|
|
cplus_type_of_child (struct varobj *parent, int index)
|
2000-02-03 05:14:45 +01:00
|
|
|
|
{
|
|
|
|
|
struct type *type, *t;
|
|
|
|
|
|
2002-01-13 21:17:55 +01:00
|
|
|
|
if (CPLUS_FAKE_CHILD (parent))
|
|
|
|
|
{
|
|
|
|
|
/* Looking for the type of a child of public, private, or protected. */
|
|
|
|
|
t = get_type_deref (parent->parent);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
t = get_type_deref (parent);
|
|
|
|
|
|
2000-02-03 05:14:45 +01:00
|
|
|
|
type = NULL;
|
|
|
|
|
switch (TYPE_CODE (t))
|
|
|
|
|
{
|
|
|
|
|
case TYPE_CODE_STRUCT:
|
|
|
|
|
case TYPE_CODE_UNION:
|
2002-01-13 21:17:55 +01:00
|
|
|
|
if (CPLUS_FAKE_CHILD (parent))
|
2000-02-03 05:14:45 +01:00
|
|
|
|
{
|
2002-01-13 21:17:55 +01:00
|
|
|
|
char *name = cplus_name_of_child (parent, index);
|
|
|
|
|
type = lookup_struct_elt_type (t, name, 0);
|
|
|
|
|
xfree (name);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
}
|
2002-01-13 21:17:55 +01:00
|
|
|
|
else if (index < TYPE_N_BASECLASSES (t))
|
|
|
|
|
type = TYPE_FIELD_TYPE (t, index);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
else
|
|
|
|
|
{
|
2002-01-13 21:17:55 +01:00
|
|
|
|
/* special */
|
|
|
|
|
return NULL;
|
2000-02-03 05:14:45 +01:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (type == NULL)
|
|
|
|
|
return c_type_of_child (parent, index);
|
|
|
|
|
|
|
|
|
|
return type;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int
|
2000-07-30 03:48:28 +02:00
|
|
|
|
cplus_variable_editable (struct varobj *var)
|
2000-02-03 05:14:45 +01:00
|
|
|
|
{
|
|
|
|
|
if (CPLUS_FAKE_CHILD (var))
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
return c_variable_editable (var);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static char *
|
2000-07-30 03:48:28 +02:00
|
|
|
|
cplus_value_of_variable (struct varobj *var)
|
2000-02-03 05:14:45 +01:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
/* If we have one of our special types, don't print out
|
|
|
|
|
any value. */
|
|
|
|
|
if (CPLUS_FAKE_CHILD (var))
|
|
|
|
|
return xstrdup ("");
|
|
|
|
|
|
|
|
|
|
return c_value_of_variable (var);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Java */
|
|
|
|
|
|
|
|
|
|
static int
|
2000-07-30 03:48:28 +02:00
|
|
|
|
java_number_of_children (struct varobj *var)
|
2000-02-03 05:14:45 +01:00
|
|
|
|
{
|
|
|
|
|
return cplus_number_of_children (var);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static char *
|
2000-07-30 03:48:28 +02:00
|
|
|
|
java_name_of_variable (struct varobj *parent)
|
2000-02-03 05:14:45 +01:00
|
|
|
|
{
|
|
|
|
|
char *p, *name;
|
|
|
|
|
|
|
|
|
|
name = cplus_name_of_variable (parent);
|
|
|
|
|
/* If the name has "-" in it, it is because we
|
|
|
|
|
needed to escape periods in the name... */
|
|
|
|
|
p = name;
|
|
|
|
|
|
|
|
|
|
while (*p != '\000')
|
|
|
|
|
{
|
|
|
|
|
if (*p == '-')
|
|
|
|
|
*p = '.';
|
|
|
|
|
p++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return name;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static char *
|
2000-07-30 03:48:28 +02:00
|
|
|
|
java_name_of_child (struct varobj *parent, int index)
|
2000-02-03 05:14:45 +01:00
|
|
|
|
{
|
|
|
|
|
char *name, *p;
|
|
|
|
|
|
|
|
|
|
name = cplus_name_of_child (parent, index);
|
|
|
|
|
/* Escape any periods in the name... */
|
|
|
|
|
p = name;
|
|
|
|
|
|
|
|
|
|
while (*p != '\000')
|
|
|
|
|
{
|
|
|
|
|
if (*p == '.')
|
|
|
|
|
*p = '-';
|
|
|
|
|
p++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return name;
|
|
|
|
|
}
|
|
|
|
|
|
2001-11-01 03:37:56 +01:00
|
|
|
|
static struct value *
|
2000-07-30 03:48:28 +02:00
|
|
|
|
java_value_of_root (struct varobj **var_handle)
|
2000-02-03 05:14:45 +01:00
|
|
|
|
{
|
2000-03-13 22:51:46 +01:00
|
|
|
|
return cplus_value_of_root (var_handle);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
}
|
|
|
|
|
|
2001-11-01 03:37:56 +01:00
|
|
|
|
static struct value *
|
2000-07-30 03:48:28 +02:00
|
|
|
|
java_value_of_child (struct varobj *parent, int index)
|
2000-02-03 05:14:45 +01:00
|
|
|
|
{
|
|
|
|
|
return cplus_value_of_child (parent, index);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static struct type *
|
2000-07-30 03:48:28 +02:00
|
|
|
|
java_type_of_child (struct varobj *parent, int index)
|
2000-02-03 05:14:45 +01:00
|
|
|
|
{
|
|
|
|
|
return cplus_type_of_child (parent, index);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int
|
2000-07-30 03:48:28 +02:00
|
|
|
|
java_variable_editable (struct varobj *var)
|
2000-02-03 05:14:45 +01:00
|
|
|
|
{
|
|
|
|
|
return cplus_variable_editable (var);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static char *
|
2000-07-30 03:48:28 +02:00
|
|
|
|
java_value_of_variable (struct varobj *var)
|
2000-02-03 05:14:45 +01:00
|
|
|
|
{
|
|
|
|
|
return cplus_value_of_variable (var);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
extern void _initialize_varobj (void);
|
|
|
|
|
void
|
|
|
|
|
_initialize_varobj (void)
|
|
|
|
|
{
|
|
|
|
|
int sizeof_table = sizeof (struct vlist *) * VAROBJ_TABLE_SIZE;
|
|
|
|
|
|
|
|
|
|
varobj_table = xmalloc (sizeof_table);
|
|
|
|
|
memset (varobj_table, 0, sizeof_table);
|
|
|
|
|
|
2005-02-18 Andrew Cagney <cagney@gnu.org>
Use add_setshow_zinteger_cmd through out. Re-sync gdbarch.sh
and gdbarch.c.
* breakpoint.c, frame.c, gdb-events.sh, gdbarch.sh: Update.
* gdbtypes.c, infrun.c, linux-nat.c, maint.c, monitor.c: Update.
* pa64solib.c, parse.c, remote-mips.c, ser-go32.c: Update.
* serial.c, solib-frv.c, somsolib.c, target.c, top.c: Update.
* varobj.c, cli/cli-cmds.c: Update.
* gdbarch.c, gdb-events.c: Regenerate.
2005-02-18 19:58:56 +01:00
|
|
|
|
add_setshow_zinteger_cmd ("debugvarobj", class_maintenance,
|
|
|
|
|
&varobjdebug, _("\
|
|
|
|
|
Set varobj debugging."), _("\
|
|
|
|
|
Show varobj debugging."), _("\
|
|
|
|
|
When non-zero, varobj debugging is enabled."),
|
|
|
|
|
NULL,
|
2005-02-24 Andrew Cagney <cagney@gnu.org>
Add show_VARIABLE functions, update add_setshow call.
* varobj.c (_initialize_varobj, show_varobjdebug): Add and update.
* valprint.c (_initialize_valprint, show_print_max)
(show_stop_print_at_null, show_repeat_count_threshold)
(show_prettyprint_structs, show_unionprint)
(show_prettyprint_arrays, show_addressprint, show_input_radix)
(show_output_radix): Ditto.
* valops.c (_initialize_valops, show_overload_resolution): Ditto.
* utils.c (initialize_utils, show_chars_per_line)
(show_lines_per_page, show_demangle, show_pagination_enabled)
(show_sevenbit_strings, show_asm_demangle): Ditto
* tui/tui-win.c (_initialize_tui_win, show_tui_border_kind)
(show_tui_border_mode, show_tui_active_border_mode): Ditto.
* top.c (init_main, show_new_async_prompt)
(show_async_command_editing_p, show_write_history_p)
(show_history_size, show_history_filename, show_caution)
(show_annotation_level, init_main): Ditto.
* target.c (initialize_targets, show_targetdebug)
(show_trust_readonly): Ditto.
* symfile.c (_initialize_symfile, show_symbol_reloading)
(show_ext_args, show_download_write_size)
(show_debug_file_directory): Ditto.
* source.c (_initialize_source, show_lines_to_list): Ditto.
* solib.c (_initialize_solib, show_auto_solib_add)
(show_solib_search_path): Ditto.
* p-valprint.c (_initialize_pascal_valprint)
(show_pascal_static_field_print): Ditto.
* printcmd.c (_initialize_printcmd, show_max_symbolic_offset)
(show_print_symbol_filename): Add and update.
* parse.c (_initialize_parse, show_expressiondebug): Dito.
* observer.c (_initialize_observer, show_observer_debug): Dito.
* maint.c (_initialize_maint_cmds, show_watchdog)
(show_maintenance_profile_p): Dito.
* linux-nat.c (_initialize_linux_nat, show_debug_linux_nat): Dito.
* infrun.c (_initialize_infrun, show_debug_infrun)
(show_stop_on_solib_events, show_follow_fork_mode_string)
(show_scheduler_mode, show_step_stop_if_no_debug): Ditto.
* infcall.c (_initialize_infcall, show_coerce_float_to_double_p)
(show_unwind_on_signal_p): Ditto.
* gdbtypes.c (build_gdbtypes, show_opaque_type_resolution)
(_initialize_gdbtypes, show_overload_debug): Ditto.
* gdb-events.c, gdb-events.sh (_initialize_gdb_events)
(show_gdb_events_debug): Ditto.
* gdbarch.c, gdbarch.sh (show_gdbarch_debug)
(_initialize_gdbarch): Ditto.
* frame.c (_initialize_frame, show_backtrace_past_main)
(show_backtrace_past_entry, show_backtrace_limit)
(show_frame_debug): Ditto.
* exec.c (_initialize_exec, show_write_files): Ditto.
* dwarf2read.c (_initialize_dwarf2_read)
(show_dwarf2_max_cache_age): Ditto.
* demangle.c (_initialize_demangler)
(show_demangling_style_names): Ditto.
* dcache.c (_initialize_dcache, show_dcache_enabled_p): Ditto.
* cp-valprint.c (show_static_field_print)
(_initialize_cp_valprint, show_vtblprint, show_objectprint): Ditto.
* corefile.c (_initialize_core, show_gnutarget_string): Ditto.
* cli/cli-logging.c (_initialize_cli_logging)
(show_logging_overwrite, show_logging_redirect)
(show_logging_filename): Ditto.
* cli/cli-cmds.c (show_info_verbose, show_history_expansion_p)
(init_cli_cmds, show_baud_rate, show_remote_debug)
(show_remote_timeout, show_max_user_call_depth): Ditto.
* charset.c (show_host_charset_name, show_target_charset_name)
(initialize_charset): Ditto.
* breakpoint.c (show_can_use_hw_watchpoints)
(show_pending_break_support, _initialize_breakpoint): Ditto.
2005-02-24 14:51:36 +01:00
|
|
|
|
show_varobjdebug,
|
2005-02-18 Andrew Cagney <cagney@gnu.org>
Use add_setshow_zinteger_cmd through out. Re-sync gdbarch.sh
and gdbarch.c.
* breakpoint.c, frame.c, gdb-events.sh, gdbarch.sh: Update.
* gdbtypes.c, infrun.c, linux-nat.c, maint.c, monitor.c: Update.
* pa64solib.c, parse.c, remote-mips.c, ser-go32.c: Update.
* serial.c, solib-frv.c, somsolib.c, target.c, top.c: Update.
* varobj.c, cli/cli-cmds.c: Update.
* gdbarch.c, gdb-events.c: Regenerate.
2005-02-18 19:58:56 +01:00
|
|
|
|
&setlist, &showlist);
|
2000-02-03 05:14:45 +01:00
|
|
|
|
}
|