OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [gdb-5.0/] [gdb/] [varobj.c] - Diff between revs 105 and 1765

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 105 Rev 1765
/* Implementation of the GDB variable objects API.
/* Implementation of the GDB variable objects API.
   Copyright 1999, 2000 Free Software Foundation, Inc.
   Copyright 1999, 2000 Free Software Foundation, Inc.
 
 
   This program is free software; you can redistribute it and/or modify
   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
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.
   (at your option) any later version.
 
 
   This program is distributed in the hope that it will be useful,
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.
   GNU General Public License for more details.
 
 
   You should have received a copy of the GNU General Public License
   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   along with this program; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place - Suite 330,
   Foundation, Inc., 59 Temple Place - Suite 330,
   Boston, MA 02111-1307, USA.  */
   Boston, MA 02111-1307, USA.  */
 
 
#include "defs.h"
#include "defs.h"
#include "value.h"
#include "value.h"
#include "expression.h"
#include "expression.h"
#include "frame.h"
#include "frame.h"
#include "valprint.h"
#include "valprint.h"
#include "language.h"
#include "language.h"
#include "wrapper.h"
#include "wrapper.h"
#include "gdbcmd.h"
#include "gdbcmd.h"
#include <math.h>
#include <math.h>
 
 
#include "varobj.h"
#include "varobj.h"
 
 
/* Non-zero if we want to see trace of varobj level stuff.  */
/* Non-zero if we want to see trace of varobj level stuff.  */
 
 
int varobjdebug = 0;
int varobjdebug = 0;
 
 
/* String representations of gdb's format codes */
/* String representations of gdb's format codes */
char *varobj_format_string[] =
char *varobj_format_string[] =
{"natural", "binary", "decimal", "hexadecimal", "octal"};
{"natural", "binary", "decimal", "hexadecimal", "octal"};
 
 
/* String representations of gdb's known languages */
/* String representations of gdb's known languages */
char *varobj_language_string[] =
char *varobj_language_string[] =
{"unknown", "C", "C++", "Java"};
{"unknown", "C", "C++", "Java"};
 
 
/* Data structures */
/* Data structures */
 
 
/* Every root variable has one of these structures saved in its
/* Every root variable has one of these structures saved in its
   varobj. Members which must be free'd are noted. */
   varobj. Members which must be free'd are noted. */
struct varobj_root
struct varobj_root
  {
  {
 
 
    /* Alloc'd expression for this parent. */
    /* Alloc'd expression for this parent. */
    struct expression *exp;
    struct expression *exp;
 
 
    /* Block for which this expression is valid */
    /* Block for which this expression is valid */
    struct block *valid_block;
    struct block *valid_block;
 
 
    /* The frame for this expression */
    /* The frame for this expression */
    CORE_ADDR frame;
    CORE_ADDR frame;
 
 
    /* If 1, "update" always recomputes the frame & valid block
    /* If 1, "update" always recomputes the frame & valid block
       using the currently selected frame. */
       using the currently selected frame. */
    int use_selected_frame;
    int use_selected_frame;
 
 
    /* Language info for this variable and its children */
    /* Language info for this variable and its children */
    struct language_specific *lang;
    struct language_specific *lang;
 
 
    /* The varobj for this root node. */
    /* The varobj for this root node. */
    struct varobj *rootvar;
    struct varobj *rootvar;
 
 
    /* Next root variable */
    /* Next root variable */
    struct varobj_root *next;
    struct varobj_root *next;
  };
  };
 
 
/* Every variable in the system has a structure of this type defined
/* Every variable in the system has a structure of this type defined
   for it. This structure holds all information necessary to manipulate
   for it. This structure holds all information necessary to manipulate
   a particular object variable. Members which must be freed are noted. */
   a particular object variable. Members which must be freed are noted. */
struct varobj
struct varobj
  {
  {
 
 
    /* Alloc'd name of the variable for this object.. If this variable is a
    /* 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.
       child, then this name will be the child's source name.
       (bar, not foo.bar) */
       (bar, not foo.bar) */
    /* NOTE: This is the "expression" */
    /* NOTE: This is the "expression" */
    char *name;
    char *name;
 
 
    /* The alloc'd name for this variable's object. This is here for
    /* The alloc'd name for this variable's object. This is here for
       convenience when constructing this object's children. */
       convenience when constructing this object's children. */
    char *obj_name;
    char *obj_name;
 
 
    /* Index of this variable in its parent or -1 */
    /* Index of this variable in its parent or -1 */
    int index;
    int index;
 
 
    /* The type of this variable. This may NEVER be NULL. */
    /* The type of this variable. This may NEVER be NULL. */
    struct type *type;
    struct type *type;
 
 
    /* The value of this expression or subexpression.  This may be NULL. */
    /* The value of this expression or subexpression.  This may be NULL. */
    value_ptr value;
    value_ptr value;
 
 
    /* Did an error occur evaluating the expression or getting its value? */
    /* Did an error occur evaluating the expression or getting its value? */
    int error;
    int error;
 
 
    /* The number of (immediate) children this variable has */
    /* The number of (immediate) children this variable has */
    int num_children;
    int num_children;
 
 
    /* If this object is a child, this points to its immediate parent. */
    /* If this object is a child, this points to its immediate parent. */
    struct varobj *parent;
    struct varobj *parent;
 
 
    /* A list of this object's children */
    /* A list of this object's children */
    struct varobj_child *children;
    struct varobj_child *children;
 
 
    /* Description of the root variable. Points to root variable for children. */
    /* Description of the root variable. Points to root variable for children. */
    struct varobj_root *root;
    struct varobj_root *root;
 
 
    /* The format of the output for this object */
    /* The format of the output for this object */
    enum varobj_display_formats format;
    enum varobj_display_formats format;
  };
  };
 
 
/* Every variable keeps a linked list of its children, described
/* Every variable keeps a linked list of its children, described
   by the following structure. */
   by the following structure. */
/* FIXME: Deprecated.  All should use vlist instead */
/* FIXME: Deprecated.  All should use vlist instead */
 
 
struct varobj_child
struct varobj_child
  {
  {
 
 
    /* Pointer to the child's data */
    /* Pointer to the child's data */
    struct varobj *child;
    struct varobj *child;
 
 
    /* Pointer to the next child */
    /* Pointer to the next child */
    struct varobj_child *next;
    struct varobj_child *next;
  };
  };
 
 
/* A stack of varobjs */
/* A stack of varobjs */
/* FIXME: Deprecated.  All should use vlist instead */
/* FIXME: Deprecated.  All should use vlist instead */
 
 
struct vstack
struct vstack
  {
  {
    struct varobj *var;
    struct varobj *var;
    struct vstack *next;
    struct vstack *next;
  };
  };
 
 
struct cpstack
struct cpstack
  {
  {
    char *name;
    char *name;
    struct cpstack *next;
    struct cpstack *next;
  };
  };
 
 
/* A list of varobjs */
/* A list of varobjs */
 
 
struct vlist
struct vlist
  {
  {
    struct varobj *var;
    struct varobj *var;
    struct vlist *next;
    struct vlist *next;
  };
  };
 
 
/* Private function prototypes */
/* Private function prototypes */
 
 
/* Helper functions for the above subcommands. */
/* Helper functions for the above subcommands. */
 
 
static int delete_variable PARAMS ((struct cpstack **, struct varobj *, int));
static int delete_variable PARAMS ((struct cpstack **, struct varobj *, int));
 
 
static void delete_variable_1 PARAMS ((struct cpstack **, int *,
static void delete_variable_1 PARAMS ((struct cpstack **, int *,
                                       struct varobj *, int, int));
                                       struct varobj *, int, int));
 
 
static int install_variable PARAMS ((struct varobj *));
static int install_variable PARAMS ((struct varobj *));
 
 
static void uninstall_variable PARAMS ((struct varobj *));
static void uninstall_variable PARAMS ((struct varobj *));
 
 
static struct varobj *child_exists PARAMS ((struct varobj *, char *));
static struct varobj *child_exists PARAMS ((struct varobj *, char *));
 
 
static struct varobj *create_child PARAMS ((struct varobj *, int, char *));
static struct varobj *create_child PARAMS ((struct varobj *, int, char *));
 
 
static void save_child_in_parent PARAMS ((struct varobj *, struct varobj *));
static void save_child_in_parent PARAMS ((struct varobj *, struct varobj *));
 
 
static void remove_child_from_parent PARAMS ((struct varobj *, struct varobj *));
static void remove_child_from_parent PARAMS ((struct varobj *, struct varobj *));
 
 
/* Utility routines */
/* Utility routines */
 
 
static struct varobj *new_variable PARAMS ((void));
static struct varobj *new_variable PARAMS ((void));
 
 
static struct varobj *new_root_variable PARAMS ((void));
static struct varobj *new_root_variable PARAMS ((void));
 
 
static void free_variable PARAMS ((struct varobj * var));
static void free_variable PARAMS ((struct varobj * var));
 
 
static struct type *get_type PARAMS ((struct varobj * var));
static struct type *get_type PARAMS ((struct varobj * var));
 
 
static struct type *get_type_deref PARAMS ((struct varobj * var));
static struct type *get_type_deref PARAMS ((struct varobj * var));
 
 
static struct type *get_target_type PARAMS ((struct type *));
static struct type *get_target_type PARAMS ((struct type *));
 
 
static enum varobj_display_formats variable_default_display PARAMS ((struct varobj *));
static enum varobj_display_formats variable_default_display PARAMS ((struct varobj *));
 
 
static int my_value_equal PARAMS ((value_ptr, value_ptr, int *));
static int my_value_equal PARAMS ((value_ptr, value_ptr, int *));
 
 
static void vpush PARAMS ((struct vstack ** pstack, struct varobj * var));
static void vpush PARAMS ((struct vstack ** pstack, struct varobj * var));
 
 
static struct varobj *vpop PARAMS ((struct vstack ** pstack));
static struct varobj *vpop PARAMS ((struct vstack ** pstack));
 
 
static void cppush PARAMS ((struct cpstack ** pstack, char *name));
static void cppush PARAMS ((struct cpstack ** pstack, char *name));
 
 
static char *cppop PARAMS ((struct cpstack ** pstack));
static char *cppop PARAMS ((struct cpstack ** pstack));
 
 
/* Language-specific routines. */
/* Language-specific routines. */
 
 
static enum varobj_languages variable_language PARAMS ((struct varobj * var));
static enum varobj_languages variable_language PARAMS ((struct varobj * var));
 
 
static int number_of_children PARAMS ((struct varobj *));
static int number_of_children PARAMS ((struct varobj *));
 
 
static char *name_of_variable PARAMS ((struct varobj *));
static char *name_of_variable PARAMS ((struct varobj *));
 
 
static char *name_of_child PARAMS ((struct varobj *, int));
static char *name_of_child PARAMS ((struct varobj *, int));
 
 
static value_ptr value_of_root PARAMS ((struct varobj ** var_handle,
static value_ptr value_of_root PARAMS ((struct varobj ** var_handle,
                                        int *));
                                        int *));
 
 
static value_ptr value_of_child PARAMS ((struct varobj * parent, int index));
static value_ptr value_of_child PARAMS ((struct varobj * parent, int index));
 
 
static struct type *type_of_child PARAMS ((struct varobj * var));
static struct type *type_of_child PARAMS ((struct varobj * var));
 
 
static int variable_editable PARAMS ((struct varobj * var));
static int variable_editable PARAMS ((struct varobj * var));
 
 
static char *my_value_of_variable PARAMS ((struct varobj * var));
static char *my_value_of_variable PARAMS ((struct varobj * var));
 
 
static int type_changeable PARAMS ((struct varobj * var));
static int type_changeable PARAMS ((struct varobj * var));
 
 
/* C implementation */
/* C implementation */
 
 
static int c_number_of_children PARAMS ((struct varobj * var));
static int c_number_of_children PARAMS ((struct varobj * var));
 
 
static char *c_name_of_variable PARAMS ((struct varobj * parent));
static char *c_name_of_variable PARAMS ((struct varobj * parent));
 
 
static char *c_name_of_child PARAMS ((struct varobj * parent, int index));
static char *c_name_of_child PARAMS ((struct varobj * parent, int index));
 
 
static value_ptr c_value_of_root PARAMS ((struct varobj ** var_handle));
static value_ptr c_value_of_root PARAMS ((struct varobj ** var_handle));
 
 
static value_ptr c_value_of_child PARAMS ((struct varobj * parent, int index));
static value_ptr c_value_of_child PARAMS ((struct varobj * parent, int index));
 
 
static struct type *c_type_of_child PARAMS ((struct varobj * parent, int index));
static struct type *c_type_of_child PARAMS ((struct varobj * parent, int index));
 
 
static int c_variable_editable PARAMS ((struct varobj * var));
static int c_variable_editable PARAMS ((struct varobj * var));
 
 
static char *c_value_of_variable PARAMS ((struct varobj * var));
static char *c_value_of_variable PARAMS ((struct varobj * var));
 
 
/* C++ implementation */
/* C++ implementation */
 
 
static int cplus_number_of_children PARAMS ((struct varobj * var));
static int cplus_number_of_children PARAMS ((struct varobj * var));
 
 
static void cplus_class_num_children PARAMS ((struct type * type, int children[3]));
static void cplus_class_num_children PARAMS ((struct type * type, int children[3]));
 
 
static char *cplus_name_of_variable PARAMS ((struct varobj * parent));
static char *cplus_name_of_variable PARAMS ((struct varobj * parent));
 
 
static char *cplus_name_of_child PARAMS ((struct varobj * parent, int index));
static char *cplus_name_of_child PARAMS ((struct varobj * parent, int index));
 
 
static value_ptr cplus_value_of_root PARAMS ((struct varobj ** var_handle));
static value_ptr cplus_value_of_root PARAMS ((struct varobj ** var_handle));
 
 
static value_ptr cplus_value_of_child PARAMS ((struct varobj * parent, int index));
static value_ptr cplus_value_of_child PARAMS ((struct varobj * parent, int index));
 
 
static struct type *cplus_type_of_child PARAMS ((struct varobj * parent, int index));
static struct type *cplus_type_of_child PARAMS ((struct varobj * parent, int index));
 
 
static int cplus_variable_editable PARAMS ((struct varobj * var));
static int cplus_variable_editable PARAMS ((struct varobj * var));
 
 
static char *cplus_value_of_variable PARAMS ((struct varobj * var));
static char *cplus_value_of_variable PARAMS ((struct varobj * var));
 
 
/* Java implementation */
/* Java implementation */
 
 
static int java_number_of_children PARAMS ((struct varobj * var));
static int java_number_of_children PARAMS ((struct varobj * var));
 
 
static char *java_name_of_variable PARAMS ((struct varobj * parent));
static char *java_name_of_variable PARAMS ((struct varobj * parent));
 
 
static char *java_name_of_child PARAMS ((struct varobj * parent, int index));
static char *java_name_of_child PARAMS ((struct varobj * parent, int index));
 
 
static value_ptr java_value_of_root PARAMS ((struct varobj ** var_handle));
static value_ptr java_value_of_root PARAMS ((struct varobj ** var_handle));
 
 
static value_ptr java_value_of_child PARAMS ((struct varobj * parent, int index));
static value_ptr java_value_of_child PARAMS ((struct varobj * parent, int index));
 
 
static struct type *java_type_of_child PARAMS ((struct varobj * parent, int index));
static struct type *java_type_of_child PARAMS ((struct varobj * parent, int index));
 
 
static int java_variable_editable PARAMS ((struct varobj * var));
static int java_variable_editable PARAMS ((struct varobj * var));
 
 
static char *java_value_of_variable PARAMS ((struct varobj * var));
static char *java_value_of_variable PARAMS ((struct varobj * var));
 
 
/* The language specific vector */
/* The language specific vector */
 
 
struct language_specific
struct language_specific
  {
  {
 
 
    /* The language of this variable */
    /* The language of this variable */
    enum varobj_languages language;
    enum varobj_languages language;
 
 
    /* The number of children of PARENT. */
    /* The number of children of PARENT. */
    int (*number_of_children) PARAMS ((struct varobj * parent));
    int (*number_of_children) PARAMS ((struct varobj * parent));
 
 
    /* The name (expression) of a root varobj. */
    /* The name (expression) of a root varobj. */
    char *(*name_of_variable) PARAMS ((struct varobj * parent));
    char *(*name_of_variable) PARAMS ((struct varobj * parent));
 
 
    /* The name of the INDEX'th child of PARENT. */
    /* The name of the INDEX'th child of PARENT. */
    char *(*name_of_child) PARAMS ((struct varobj * parent, int index));
    char *(*name_of_child) PARAMS ((struct varobj * parent, int index));
 
 
    /* The value_ptr of the root variable ROOT. */
    /* The value_ptr of the root variable ROOT. */
      value_ptr (*value_of_root) PARAMS ((struct varobj ** root_handle));
      value_ptr (*value_of_root) PARAMS ((struct varobj ** root_handle));
 
 
    /* The value_ptr of the INDEX'th child of PARENT. */
    /* The value_ptr of the INDEX'th child of PARENT. */
      value_ptr (*value_of_child) PARAMS ((struct varobj * parent, int index));
      value_ptr (*value_of_child) PARAMS ((struct varobj * parent, int index));
 
 
    /* The type of the INDEX'th child of PARENT. */
    /* The type of the INDEX'th child of PARENT. */
    struct type *(*type_of_child) PARAMS ((struct varobj * parent, int index));
    struct type *(*type_of_child) PARAMS ((struct varobj * parent, int index));
 
 
    /* Is VAR editable? */
    /* Is VAR editable? */
    int (*variable_editable) PARAMS ((struct varobj * var));
    int (*variable_editable) PARAMS ((struct varobj * var));
 
 
    /* The current value of VAR. */
    /* The current value of VAR. */
    char *(*value_of_variable) PARAMS ((struct varobj * var));
    char *(*value_of_variable) PARAMS ((struct varobj * var));
  };
  };
 
 
/* Array of known source language routines. */
/* Array of known source language routines. */
static struct language_specific
static struct language_specific
  languages[vlang_end][sizeof (struct language_specific)] =
  languages[vlang_end][sizeof (struct language_specific)] =
{
{
  /* Unknown (try treating as C */
  /* Unknown (try treating as C */
  {
  {
    vlang_unknown,
    vlang_unknown,
      c_number_of_children,
      c_number_of_children,
      c_name_of_variable,
      c_name_of_variable,
      c_name_of_child,
      c_name_of_child,
      c_value_of_root,
      c_value_of_root,
      c_value_of_child,
      c_value_of_child,
      c_type_of_child,
      c_type_of_child,
      c_variable_editable,
      c_variable_editable,
      c_value_of_variable
      c_value_of_variable
  }
  }
  ,
  ,
  /* C */
  /* C */
  {
  {
    vlang_c,
    vlang_c,
      c_number_of_children,
      c_number_of_children,
      c_name_of_variable,
      c_name_of_variable,
      c_name_of_child,
      c_name_of_child,
      c_value_of_root,
      c_value_of_root,
      c_value_of_child,
      c_value_of_child,
      c_type_of_child,
      c_type_of_child,
      c_variable_editable,
      c_variable_editable,
      c_value_of_variable
      c_value_of_variable
  }
  }
  ,
  ,
  /* C++ */
  /* C++ */
  {
  {
    vlang_cplus,
    vlang_cplus,
      cplus_number_of_children,
      cplus_number_of_children,
      cplus_name_of_variable,
      cplus_name_of_variable,
      cplus_name_of_child,
      cplus_name_of_child,
      cplus_value_of_root,
      cplus_value_of_root,
      cplus_value_of_child,
      cplus_value_of_child,
      cplus_type_of_child,
      cplus_type_of_child,
      cplus_variable_editable,
      cplus_variable_editable,
      cplus_value_of_variable
      cplus_value_of_variable
  }
  }
  ,
  ,
  /* Java */
  /* Java */
  {
  {
    vlang_java,
    vlang_java,
      java_number_of_children,
      java_number_of_children,
      java_name_of_variable,
      java_name_of_variable,
      java_name_of_child,
      java_name_of_child,
      java_value_of_root,
      java_value_of_root,
      java_value_of_child,
      java_value_of_child,
      java_type_of_child,
      java_type_of_child,
      java_variable_editable,
      java_variable_editable,
      java_value_of_variable
      java_value_of_variable
  }
  }
};
};
 
 
/* A little convenience enum for dealing with C++/Java */
/* A little convenience enum for dealing with C++/Java */
enum vsections
enum vsections
  {
  {
    v_public = 0, v_private, v_protected
    v_public = 0, v_private, v_protected
  };
  };
 
 
/* Private data */
/* Private data */
 
 
/* Mappings of varobj_display_formats enums to gdb's format codes */
/* Mappings of varobj_display_formats enums to gdb's format codes */
static int format_code[] =
static int format_code[] =
{0, 't', 'd', 'x', 'o'};
{0, 't', 'd', 'x', 'o'};
 
 
/* Header of the list of root variable objects */
/* Header of the list of root variable objects */
static struct varobj_root *rootlist;
static struct varobj_root *rootlist;
static int rootcount = 0;        /* number of root varobjs in the list */
static int rootcount = 0;        /* number of root varobjs in the list */
 
 
/* Prime number indicating the number of buckets in the hash table */
/* Prime number indicating the number of buckets in the hash table */
/* A prime large enough to avoid too many colisions */
/* A prime large enough to avoid too many colisions */
#define VAROBJ_TABLE_SIZE 227
#define VAROBJ_TABLE_SIZE 227
 
 
/* Pointer to the varobj hash table (built at run time) */
/* Pointer to the varobj hash table (built at run time) */
static struct vlist **varobj_table;
static struct vlist **varobj_table;
 
 
#if defined(FREEIF)
#if defined(FREEIF)
#undef FREEIF
#undef FREEIF
#endif
#endif
#define FREEIF(x) if (x != NULL) free((char *) (x))
#define FREEIF(x) if (x != NULL) free((char *) (x))
 
 
/* Is the variable X one of our "fake" children? */
/* Is the variable X one of our "fake" children? */
#define CPLUS_FAKE_CHILD(x) \
#define CPLUS_FAKE_CHILD(x) \
((x) != NULL && (x)->type == NULL && (x)->value == NULL)
((x) != NULL && (x)->type == NULL && (x)->value == NULL)


 
 
/* API Implementation */
/* API Implementation */
 
 
/* Creates a varobj (not its children) */
/* Creates a varobj (not its children) */
 
 
struct varobj *
struct varobj *
varobj_create (char *objname,
varobj_create (char *objname,
               char *expression, CORE_ADDR frame,
               char *expression, CORE_ADDR frame,
               enum varobj_type type)
               enum varobj_type type)
{
{
  struct varobj *var;
  struct varobj *var;
  struct frame_info *fi, *old_fi;
  struct frame_info *fi, *old_fi;
  struct block *block;
  struct block *block;
  struct cleanup *old_chain;
  struct cleanup *old_chain;
 
 
  /* Fill out a varobj structure for the (root) variable being constructed. */
  /* Fill out a varobj structure for the (root) variable being constructed. */
  var = new_root_variable ();
  var = new_root_variable ();
  old_chain = make_cleanup ((make_cleanup_func) free_variable, var);
  old_chain = make_cleanup ((make_cleanup_func) free_variable, var);
 
 
  if (expression != NULL)
  if (expression != NULL)
    {
    {
      char *p;
      char *p;
      enum varobj_languages lang;
      enum varobj_languages lang;
 
 
      /* Parse and evaluate the expression, filling in as much
      /* Parse and evaluate the expression, filling in as much
         of the variable's data as possible */
         of the variable's data as possible */
 
 
      /* Allow creator to specify context of variable */
      /* Allow creator to specify context of variable */
      if ((type == USE_CURRENT_FRAME)
      if ((type == USE_CURRENT_FRAME)
          || (type == USE_SELECTED_FRAME))
          || (type == USE_SELECTED_FRAME))
        fi = selected_frame;
        fi = selected_frame;
      else
      else
        fi = find_frame_addr_in_frame_chain (frame);
        fi = find_frame_addr_in_frame_chain (frame);
 
 
      /* frame = -2 means always use selected frame */
      /* frame = -2 means always use selected frame */
      if (type == USE_SELECTED_FRAME)
      if (type == USE_SELECTED_FRAME)
        var->root->use_selected_frame = 1;
        var->root->use_selected_frame = 1;
 
 
      block = NULL;
      block = NULL;
      if (fi != NULL)
      if (fi != NULL)
        block = get_frame_block (fi);
        block = get_frame_block (fi);
 
 
      p = expression;
      p = expression;
      innermost_block = NULL;
      innermost_block = NULL;
      /* Wrap the call to parse expression, so we can
      /* Wrap the call to parse expression, so we can
         return a sensible error. */
         return a sensible error. */
      if (!gdb_parse_exp_1 (&p, block, 0, &var->root->exp))
      if (!gdb_parse_exp_1 (&p, block, 0, &var->root->exp))
        {
        {
          return NULL;
          return NULL;
        }
        }
 
 
      /* Don't allow variables to be created for types. */
      /* Don't allow variables to be created for types. */
      if (var->root->exp->elts[0].opcode == OP_TYPE)
      if (var->root->exp->elts[0].opcode == OP_TYPE)
        {
        {
          do_cleanups (old_chain);
          do_cleanups (old_chain);
          fprintf_unfiltered (gdb_stderr,
          fprintf_unfiltered (gdb_stderr,
                            "Attempt to use a type name as an expression.");
                            "Attempt to use a type name as an expression.");
          return NULL;
          return NULL;
        }
        }
 
 
      var->format = variable_default_display (var);
      var->format = variable_default_display (var);
      var->root->valid_block = innermost_block;
      var->root->valid_block = innermost_block;
      var->name = savestring (expression, strlen (expression));
      var->name = savestring (expression, strlen (expression));
 
 
      /* When the frame is different from the current frame,
      /* When the frame is different from the current frame,
         we must select the appropriate frame before parsing
         we must select the appropriate frame before parsing
         the expression, otherwise the value will not be current.
         the expression, otherwise the value will not be current.
         Since select_frame is so benign, just call it for all cases. */
         Since select_frame is so benign, just call it for all cases. */
      if (fi != NULL)
      if (fi != NULL)
        {
        {
          var->root->frame = FRAME_FP (fi);
          var->root->frame = FRAME_FP (fi);
          old_fi = selected_frame;
          old_fi = selected_frame;
          select_frame (fi, -1);
          select_frame (fi, -1);
        }
        }
 
 
      /* We definitively need to catch errors here.
      /* We definitively need to catch errors here.
         If evaluate_expression succeeds we got the value we wanted.
         If evaluate_expression succeeds we got the value we wanted.
         But if it fails, we still go on with a call to evaluate_type()  */
         But if it fails, we still go on with a call to evaluate_type()  */
      if (gdb_evaluate_expression (var->root->exp, &var->value))
      if (gdb_evaluate_expression (var->root->exp, &var->value))
        {
        {
          /* no error */
          /* no error */
          release_value (var->value);
          release_value (var->value);
          if (VALUE_LAZY (var->value))
          if (VALUE_LAZY (var->value))
            gdb_value_fetch_lazy (var->value);
            gdb_value_fetch_lazy (var->value);
        }
        }
      else
      else
        var->value = evaluate_type (var->root->exp);
        var->value = evaluate_type (var->root->exp);
 
 
      var->type = VALUE_TYPE (var->value);
      var->type = VALUE_TYPE (var->value);
 
 
      /* Set language info */
      /* Set language info */
      lang = variable_language (var);
      lang = variable_language (var);
      var->root->lang = languages[lang];
      var->root->lang = languages[lang];
 
 
      /* Set ourselves as our root */
      /* Set ourselves as our root */
      var->root->rootvar = var;
      var->root->rootvar = var;
 
 
      /* Reset the selected frame */
      /* Reset the selected frame */
      if (fi != NULL)
      if (fi != NULL)
        select_frame (old_fi, -1);
        select_frame (old_fi, -1);
    }
    }
 
 
  /* If the variable object name is null, that means this
  /* If the variable object name is null, that means this
     is a temporary variable, so don't install it. */
     is a temporary variable, so don't install it. */
 
 
  if ((var != NULL) && (objname != NULL))
  if ((var != NULL) && (objname != NULL))
    {
    {
      var->obj_name = savestring (objname, strlen (objname));
      var->obj_name = savestring (objname, strlen (objname));
 
 
      /* If a varobj name is duplicated, the install will fail so
      /* If a varobj name is duplicated, the install will fail so
         we must clenup */
         we must clenup */
      if (!install_variable (var))
      if (!install_variable (var))
        {
        {
          do_cleanups (old_chain);
          do_cleanups (old_chain);
          return NULL;
          return NULL;
        }
        }
    }
    }
 
 
  discard_cleanups (old_chain);
  discard_cleanups (old_chain);
  return var;
  return var;
}
}
 
 
/* Generates an unique name that can be used for a varobj */
/* Generates an unique name that can be used for a varobj */
 
 
char *
char *
varobj_gen_name (void)
varobj_gen_name (void)
{
{
  static int id = 0;
  static int id = 0;
  char obj_name[31];
  char obj_name[31];
 
 
  /* generate a name for this object */
  /* generate a name for this object */
  id++;
  id++;
  sprintf (obj_name, "var%d", id);
  sprintf (obj_name, "var%d", id);
 
 
  return xstrdup (obj_name);
  return xstrdup (obj_name);
}
}
 
 
/* Given an "objname", returns the pointer to the corresponding varobj
/* Given an "objname", returns the pointer to the corresponding varobj
   or NULL if not found */
   or NULL if not found */
 
 
struct varobj *
struct varobj *
varobj_get_handle (char *objname)
varobj_get_handle (char *objname)
{
{
  struct vlist *cv;
  struct vlist *cv;
  const char *chp;
  const char *chp;
  unsigned int index = 0;
  unsigned int index = 0;
  unsigned int i = 1;
  unsigned int i = 1;
 
 
  for (chp = objname; *chp; chp++)
  for (chp = objname; *chp; chp++)
    {
    {
      index = (index + (i++ * (unsigned int) *chp)) % VAROBJ_TABLE_SIZE;
      index = (index + (i++ * (unsigned int) *chp)) % VAROBJ_TABLE_SIZE;
    }
    }
 
 
  cv = *(varobj_table + index);
  cv = *(varobj_table + index);
  while ((cv != NULL) && (strcmp (cv->var->obj_name, objname) != 0))
  while ((cv != NULL) && (strcmp (cv->var->obj_name, objname) != 0))
    cv = cv->next;
    cv = cv->next;
 
 
  if (cv == NULL)
  if (cv == NULL)
    error ("Variable object not found");
    error ("Variable object not found");
 
 
  return cv->var;
  return cv->var;
}
}
 
 
/* Given the handle, return the name of the object */
/* Given the handle, return the name of the object */
 
 
char *
char *
varobj_get_objname (struct varobj *var)
varobj_get_objname (struct varobj *var)
{
{
  return var->obj_name;
  return var->obj_name;
}
}
 
 
/* Given the handle, return the expression represented by the object */
/* Given the handle, return the expression represented by the object */
 
 
char *
char *
varobj_get_expression (struct varobj *var)
varobj_get_expression (struct varobj *var)
{
{
  return name_of_variable (var);
  return name_of_variable (var);
}
}
 
 
/* Deletes a varobj and all its children if only_children == 0,
/* Deletes a varobj and all its children if only_children == 0,
   otherwise deletes only the children; returns a malloc'ed list of all the
   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) */
   (malloc'ed) names of the variables that have been deleted (NULL terminated) */
 
 
int
int
varobj_delete (struct varobj *var, char ***dellist, int only_children)
varobj_delete (struct varobj *var, char ***dellist, int only_children)
{
{
  int delcount;
  int delcount;
  int mycount;
  int mycount;
  struct cpstack *result = NULL;
  struct cpstack *result = NULL;
  char **cp;
  char **cp;
 
 
  /* Initialize a stack for temporary results */
  /* Initialize a stack for temporary results */
  cppush (&result, NULL);
  cppush (&result, NULL);
 
 
  if (only_children)
  if (only_children)
    /* Delete only the variable children */
    /* Delete only the variable children */
    delcount = delete_variable (&result, var, 1 /* only the children */ );
    delcount = delete_variable (&result, var, 1 /* only the children */ );
  else
  else
    /* Delete the variable and all its children */
    /* Delete the variable and all its children */
    delcount = delete_variable (&result, var, 0 /* parent+children */ );
    delcount = delete_variable (&result, var, 0 /* parent+children */ );
 
 
  /* We may have been asked to return a list of what has been deleted */
  /* We may have been asked to return a list of what has been deleted */
  if (dellist != NULL)
  if (dellist != NULL)
    {
    {
      *dellist = xmalloc ((delcount + 1) * sizeof (char *));
      *dellist = xmalloc ((delcount + 1) * sizeof (char *));
 
 
      cp = *dellist;
      cp = *dellist;
      mycount = delcount;
      mycount = delcount;
      *cp = cppop (&result);
      *cp = cppop (&result);
      while ((*cp != NULL) && (mycount > 0))
      while ((*cp != NULL) && (mycount > 0))
        {
        {
          mycount--;
          mycount--;
          cp++;
          cp++;
          *cp = cppop (&result);
          *cp = cppop (&result);
        }
        }
 
 
      if (mycount || (*cp != NULL))
      if (mycount || (*cp != NULL))
        warning ("varobj_delete: assertion failed - mycount(=%d) <> 0", mycount);
        warning ("varobj_delete: assertion failed - mycount(=%d) <> 0", mycount);
    }
    }
 
 
  return delcount;
  return delcount;
}
}
 
 
/* Set/Get variable object display format */
/* Set/Get variable object display format */
 
 
enum varobj_display_formats
enum varobj_display_formats
varobj_set_display_format (struct varobj *var,
varobj_set_display_format (struct varobj *var,
                           enum varobj_display_formats format)
                           enum varobj_display_formats format)
{
{
  switch (format)
  switch (format)
    {
    {
    case FORMAT_NATURAL:
    case FORMAT_NATURAL:
    case FORMAT_BINARY:
    case FORMAT_BINARY:
    case FORMAT_DECIMAL:
    case FORMAT_DECIMAL:
    case FORMAT_HEXADECIMAL:
    case FORMAT_HEXADECIMAL:
    case FORMAT_OCTAL:
    case FORMAT_OCTAL:
      var->format = format;
      var->format = format;
      break;
      break;
 
 
    default:
    default:
      var->format = variable_default_display (var);
      var->format = variable_default_display (var);
    }
    }
 
 
  return var->format;
  return var->format;
}
}
 
 
enum varobj_display_formats
enum varobj_display_formats
varobj_get_display_format (struct varobj *var)
varobj_get_display_format (struct varobj *var)
{
{
  return var->format;
  return var->format;
}
}
 
 
int
int
varobj_get_num_children (struct varobj *var)
varobj_get_num_children (struct varobj *var)
{
{
  if (var->num_children == -1)
  if (var->num_children == -1)
    var->num_children = number_of_children (var);
    var->num_children = number_of_children (var);
 
 
  return var->num_children;
  return var->num_children;
}
}
 
 
/* Creates a list of the immediate children of a variable object;
/* Creates a list of the immediate children of a variable object;
   the return code is the number of such children or -1 on error */
   the return code is the number of such children or -1 on error */
 
 
int
int
varobj_list_children (struct varobj *var, struct varobj ***childlist)
varobj_list_children (struct varobj *var, struct varobj ***childlist)
{
{
  struct varobj *child;
  struct varobj *child;
  char *name;
  char *name;
  int i;
  int i;
 
 
  /* sanity check: have we been passed a pointer? */
  /* sanity check: have we been passed a pointer? */
  if (childlist == NULL)
  if (childlist == NULL)
    return -1;
    return -1;
 
 
  *childlist = NULL;
  *childlist = NULL;
 
 
  if (var->num_children == -1)
  if (var->num_children == -1)
    var->num_children = number_of_children (var);
    var->num_children = number_of_children (var);
 
 
  /* List of children */
  /* List of children */
  *childlist = xmalloc ((var->num_children + 1) * sizeof (struct varobj *));
  *childlist = xmalloc ((var->num_children + 1) * sizeof (struct varobj *));
 
 
  for (i = 0; i < var->num_children; i++)
  for (i = 0; i < var->num_children; i++)
    {
    {
      /* Mark as the end in case we bail out */
      /* Mark as the end in case we bail out */
      *((*childlist) + i) = NULL;
      *((*childlist) + i) = NULL;
 
 
      /* check if child exists, if not create */
      /* check if child exists, if not create */
      name = name_of_child (var, i);
      name = name_of_child (var, i);
      child = child_exists (var, name);
      child = child_exists (var, name);
      if (child == NULL)
      if (child == NULL)
        child = create_child (var, i, name);
        child = create_child (var, i, name);
 
 
      *((*childlist) + i) = child;
      *((*childlist) + i) = child;
    }
    }
 
 
  /* End of list is marked by a NULL pointer */
  /* End of list is marked by a NULL pointer */
  *((*childlist) + i) = NULL;
  *((*childlist) + i) = NULL;
 
 
  return var->num_children;
  return var->num_children;
}
}
 
 
/* Obtain the type of an object Variable as a string similar to the one gdb
/* Obtain the type of an object Variable as a string similar to the one gdb
   prints on the console */
   prints on the console */
 
 
char *
char *
varobj_get_type (struct varobj *var)
varobj_get_type (struct varobj *var)
{
{
  value_ptr val;
  value_ptr val;
  struct cleanup *old_chain;
  struct cleanup *old_chain;
  struct ui_file *stb;
  struct ui_file *stb;
  char *thetype;
  char *thetype;
  long length;
  long length;
 
 
  /* For the "fake" variables, do not return a type. (It's type is
  /* For the "fake" variables, do not return a type. (It's type is
     NULL, too.) */
     NULL, too.) */
  if (CPLUS_FAKE_CHILD (var))
  if (CPLUS_FAKE_CHILD (var))
    return NULL;
    return NULL;
 
 
  stb = mem_fileopen ();
  stb = mem_fileopen ();
  old_chain = make_cleanup_ui_file_delete (stb);
  old_chain = make_cleanup_ui_file_delete (stb);
 
 
  /* To print the type, we simply create a zero value_ptr and
  /* To print the type, we simply create a zero value_ptr and
     cast it to our type. We then typeprint this variable. */
     cast it to our type. We then typeprint this variable. */
  val = value_zero (var->type, not_lval);
  val = value_zero (var->type, not_lval);
  type_print (VALUE_TYPE (val), "", stb, -1);
  type_print (VALUE_TYPE (val), "", stb, -1);
 
 
  thetype = ui_file_xstrdup (stb, &length);
  thetype = ui_file_xstrdup (stb, &length);
  do_cleanups (old_chain);
  do_cleanups (old_chain);
  return thetype;
  return thetype;
}
}
 
 
enum varobj_languages
enum varobj_languages
varobj_get_language (struct varobj *var)
varobj_get_language (struct varobj *var)
{
{
  return variable_language (var);
  return variable_language (var);
}
}
 
 
int
int
varobj_get_attributes (struct varobj *var)
varobj_get_attributes (struct varobj *var)
{
{
  int attributes = 0;
  int attributes = 0;
 
 
  if (variable_editable (var))
  if (variable_editable (var))
    /* FIXME: define masks for attributes */
    /* FIXME: define masks for attributes */
    attributes |= 0x00000001;   /* Editable */
    attributes |= 0x00000001;   /* Editable */
 
 
  return attributes;
  return attributes;
}
}
 
 
char *
char *
varobj_get_value (struct varobj *var)
varobj_get_value (struct varobj *var)
{
{
  return my_value_of_variable (var);
  return my_value_of_variable (var);
}
}
 
 
/* Set the value of an object variable (if it is editable) to the
/* Set the value of an object variable (if it is editable) to the
   value of the given expression */
   value of the given expression */
/* Note: Invokes functions that can call error() */
/* Note: Invokes functions that can call error() */
 
 
int
int
varobj_set_value (struct varobj *var, char *expression)
varobj_set_value (struct varobj *var, char *expression)
{
{
  value_ptr val;
  value_ptr val;
  int offset = 0;
  int offset = 0;
 
 
  /* The argument "expression" contains the variable's new value.
  /* The argument "expression" contains the variable's new value.
     We need to first construct a legal expression for this -- ugh! */
     We need to first construct a legal expression for this -- ugh! */
  /* Does this cover all the bases? */
  /* Does this cover all the bases? */
  struct expression *exp;
  struct expression *exp;
  value_ptr value;
  value_ptr value;
  int saved_input_radix = input_radix;
  int saved_input_radix = input_radix;
 
 
  if (variable_editable (var) && !var->error)
  if (variable_editable (var) && !var->error)
    {
    {
      char *s = expression;
      char *s = expression;
      int i;
      int i;
      value_ptr temp;
      value_ptr temp;
 
 
      input_radix = 10;         /* ALWAYS reset to decimal temporarily */
      input_radix = 10;         /* ALWAYS reset to decimal temporarily */
      /* FIXME: Callee may longjump */
      /* FIXME: Callee may longjump */
      exp = parse_exp_1 (&s, 0, 0);
      exp = parse_exp_1 (&s, 0, 0);
      if (!gdb_evaluate_expression (exp, &value))
      if (!gdb_evaluate_expression (exp, &value))
        {
        {
          /* We cannot proceed without a valid expression. */
          /* We cannot proceed without a valid expression. */
          FREEIF (exp);
          FREEIF (exp);
          return 0;
          return 0;
        }
        }
 
 
      /* If our parent is "public", "private", or "protected", we could
      /* If our parent is "public", "private", or "protected", we could
         be asking to modify the value of a baseclass. If so, we need to
         be asking to modify the value of a baseclass. If so, we need to
         adjust our address by the offset of our baseclass in the subclass,
         adjust our address by the offset of our baseclass in the subclass,
         since VALUE_ADDRESS (var->value) points at the start of the subclass.
         since VALUE_ADDRESS (var->value) points at the start of the subclass.
         For some reason, value_cast doesn't take care of this properly. */
         For some reason, value_cast doesn't take care of this properly. */
      temp = var->value;
      temp = var->value;
      if (var->parent != NULL && CPLUS_FAKE_CHILD (var->parent))
      if (var->parent != NULL && CPLUS_FAKE_CHILD (var->parent))
        {
        {
          struct varobj *super, *sub;
          struct varobj *super, *sub;
          struct type *type;
          struct type *type;
          super = var->parent->parent;
          super = var->parent->parent;
          sub = super->parent;
          sub = super->parent;
          if (sub != NULL)
          if (sub != NULL)
            {
            {
              /* Yes, it is a baseclass */
              /* Yes, it is a baseclass */
              type = get_type_deref (sub);
              type = get_type_deref (sub);
 
 
              if (super->index < TYPE_N_BASECLASSES (type))
              if (super->index < TYPE_N_BASECLASSES (type))
                {
                {
                  temp = value_copy (var->value);
                  temp = value_copy (var->value);
                  for (i = 0; i < super->index; i++)
                  for (i = 0; i < super->index; i++)
                    offset += TYPE_LENGTH (TYPE_FIELD_TYPE (type, i));
                    offset += TYPE_LENGTH (TYPE_FIELD_TYPE (type, i));
                }
                }
            }
            }
        }
        }
 
 
      VALUE_ADDRESS (temp) += offset;
      VALUE_ADDRESS (temp) += offset;
      val = value_assign (temp, value);
      val = value_assign (temp, value);
      VALUE_ADDRESS (val) -= offset;
      VALUE_ADDRESS (val) -= offset;
      value_free (var->value);
      value_free (var->value);
      release_value (val);
      release_value (val);
      var->value = val;
      var->value = val;
      input_radix = saved_input_radix;
      input_radix = saved_input_radix;
      return 1;
      return 1;
    }
    }
 
 
  return 0;
  return 0;
}
}
 
 
/* Returns a malloc'ed list with all root variable objects */
/* Returns a malloc'ed list with all root variable objects */
int
int
varobj_list (struct varobj ***varlist)
varobj_list (struct varobj ***varlist)
{
{
  struct varobj **cv;
  struct varobj **cv;
  struct varobj_root *croot;
  struct varobj_root *croot;
  int mycount = rootcount;
  int mycount = rootcount;
 
 
  /* Alloc (rootcount + 1) entries for the result */
  /* Alloc (rootcount + 1) entries for the result */
  *varlist = xmalloc ((rootcount + 1) * sizeof (struct varobj *));
  *varlist = xmalloc ((rootcount + 1) * sizeof (struct varobj *));
 
 
  cv = *varlist;
  cv = *varlist;
  croot = rootlist;
  croot = rootlist;
  while ((croot != NULL) && (mycount > 0))
  while ((croot != NULL) && (mycount > 0))
    {
    {
      *cv = croot->rootvar;
      *cv = croot->rootvar;
      mycount--;
      mycount--;
      cv++;
      cv++;
      croot = croot->next;
      croot = croot->next;
    }
    }
  /* Mark the end of the list */
  /* Mark the end of the list */
  *cv = NULL;
  *cv = NULL;
 
 
  if (mycount || (croot != NULL))
  if (mycount || (croot != NULL))
    warning ("varobj_list: assertion failed - wrong tally of root vars (%d:%d)",
    warning ("varobj_list: assertion failed - wrong tally of root vars (%d:%d)",
             rootcount, mycount);
             rootcount, mycount);
 
 
  return rootcount;
  return rootcount;
}
}
 
 
/* Update the values for a variable and its children.  This is a
/* Update the values for a variable and its children.  This is a
   two-pronged attack.  First, re-parse the value for the root's
   two-pronged attack.  First, re-parse the value for the root's
   expression to see if it's changed.  Then go all the way
   expression to see if it's changed.  Then go all the way
   through its children, reconstructing them and noting if they've
   through its children, reconstructing them and noting if they've
   changed.
   changed.
   Return value:
   Return value:
    -1 if there was an error updating the varobj
    -1 if there was an error updating the varobj
    -2 if the type changed
    -2 if the type changed
    Otherwise it is the number of children + parent changed
    Otherwise it is the number of children + parent changed
 
 
   Only root variables can be updated... */
   Only root variables can be updated... */
 
 
int
int
varobj_update (struct varobj *var, struct varobj ***changelist)
varobj_update (struct varobj *var, struct varobj ***changelist)
{
{
  int changed = 0;
  int changed = 0;
  int type_changed;
  int type_changed;
  int i;
  int i;
  int vleft;
  int vleft;
  int error2;
  int error2;
  struct varobj *v;
  struct varobj *v;
  struct varobj **cv;
  struct varobj **cv;
  struct varobj **templist;
  struct varobj **templist;
  value_ptr new;
  value_ptr new;
  struct vstack *stack = NULL;
  struct vstack *stack = NULL;
  struct vstack *result = NULL;
  struct vstack *result = NULL;
  struct frame_info *old_fi;
  struct frame_info *old_fi;
 
 
  /* sanity check: have we been passed a pointer? */
  /* sanity check: have we been passed a pointer? */
  if (changelist == NULL)
  if (changelist == NULL)
    return -1;
    return -1;
 
 
  /*  Only root variables can be updated... */
  /*  Only root variables can be updated... */
  if (var->root->rootvar != var)
  if (var->root->rootvar != var)
    /* Not a root var */
    /* Not a root var */
    return -1;
    return -1;
 
 
  /* Save the selected stack frame, since we will need to change it
  /* Save the selected stack frame, since we will need to change it
     in order to evaluate expressions. */
     in order to evaluate expressions. */
  old_fi = selected_frame;
  old_fi = selected_frame;
 
 
  /* Update the root variable. value_of_root can return NULL
  /* Update the root variable. value_of_root can return NULL
     if the variable is no longer around, i.e. we stepped out of
     if the variable is no longer around, i.e. we stepped out of
     the frame in which a local existed. We are letting the
     the frame in which a local existed. We are letting the
     value_of_root variable dispose of the varobj if the type
     value_of_root variable dispose of the varobj if the type
     has changed. */
     has changed. */
  type_changed = 1;
  type_changed = 1;
  new = value_of_root (&var, &type_changed);
  new = value_of_root (&var, &type_changed);
  if (new == NULL)
  if (new == NULL)
    {
    {
      var->error = 1;
      var->error = 1;
      return -1;
      return -1;
    }
    }
 
 
  /* Initialize a stack for temporary results */
  /* Initialize a stack for temporary results */
  vpush (&result, NULL);
  vpush (&result, NULL);
 
 
  if (type_changed || !my_value_equal (var->value, new, &error2))
  if (type_changed || !my_value_equal (var->value, new, &error2))
    {
    {
      /* Note that it's changed   There a couple of exceptions here,
      /* Note that it's changed   There a couple of exceptions here,
         though. We don't want some types to be reported as
         though. We don't want some types to be reported as
         "changed". The exception to this is if this is a
         "changed". The exception to this is if this is a
         "use_selected_frame" varobj, and its type has changed. */
         "use_selected_frame" varobj, and its type has changed. */
      if (type_changed || type_changeable (var))
      if (type_changed || type_changeable (var))
        {
        {
          vpush (&result, var);
          vpush (&result, var);
          changed++;
          changed++;
        }
        }
    }
    }
  /* error2 replaces var->error since this new value
  /* error2 replaces var->error since this new value
     WILL replace the old one. */
     WILL replace the old one. */
  var->error = error2;
  var->error = error2;
 
 
  /* We must always keep around the new value for this root
  /* We must always keep around the new value for this root
     variable expression, or we lose the updated children! */
     variable expression, or we lose the updated children! */
  value_free (var->value);
  value_free (var->value);
  var->value = new;
  var->value = new;
 
 
  /* Initialize a stack */
  /* Initialize a stack */
  vpush (&stack, NULL);
  vpush (&stack, NULL);
 
 
  /* Push the root's children */
  /* Push the root's children */
  if (var->children != NULL)
  if (var->children != NULL)
    {
    {
      struct varobj_child *c;
      struct varobj_child *c;
      for (c = var->children; c != NULL; c = c->next)
      for (c = var->children; c != NULL; c = c->next)
        vpush (&stack, c->child);
        vpush (&stack, c->child);
    }
    }
 
 
  /* Walk through the children, reconstructing them all. */
  /* Walk through the children, reconstructing them all. */
  v = vpop (&stack);
  v = vpop (&stack);
  while (v != NULL)
  while (v != NULL)
    {
    {
      /* Push any children */
      /* Push any children */
      if (v->children != NULL)
      if (v->children != NULL)
        {
        {
          struct varobj_child *c;
          struct varobj_child *c;
          for (c = v->children; c != NULL; c = c->next)
          for (c = v->children; c != NULL; c = c->next)
            vpush (&stack, c->child);
            vpush (&stack, c->child);
        }
        }
 
 
      /* Update this variable */
      /* Update this variable */
      new = value_of_child (v->parent, v->index);
      new = value_of_child (v->parent, v->index);
      if (type_changeable (v) && !my_value_equal (v->value, new, &error2))
      if (type_changeable (v) && !my_value_equal (v->value, new, &error2))
        {
        {
          /* Note that it's changed */
          /* Note that it's changed */
          vpush (&result, v);
          vpush (&result, v);
          changed++;
          changed++;
        }
        }
      /* error2 replaces v->error since this new value
      /* error2 replaces v->error since this new value
         WILL replace the old one. */
         WILL replace the old one. */
      v->error = error2;
      v->error = error2;
 
 
      /* We must always keep new values, since children depend on it. */
      /* We must always keep new values, since children depend on it. */
      if (v->value != NULL)
      if (v->value != NULL)
        value_free (v->value);
        value_free (v->value);
      v->value = new;
      v->value = new;
 
 
      /* Get next child */
      /* Get next child */
      v = vpop (&stack);
      v = vpop (&stack);
    }
    }
 
 
  /* Alloc (changed + 1) list entries */
  /* Alloc (changed + 1) list entries */
  /* FIXME: add a cleanup for the allocated list(s)
  /* FIXME: add a cleanup for the allocated list(s)
     because one day the select_frame called below can longjump */
     because one day the select_frame called below can longjump */
  *changelist = xmalloc ((changed + 1) * sizeof (struct varobj *));
  *changelist = xmalloc ((changed + 1) * sizeof (struct varobj *));
  if (changed > 1)
  if (changed > 1)
    {
    {
      templist = xmalloc ((changed + 1) * sizeof (struct varobj *));
      templist = xmalloc ((changed + 1) * sizeof (struct varobj *));
      cv = templist;
      cv = templist;
    }
    }
  else
  else
    cv = *changelist;
    cv = *changelist;
 
 
  /* Copy from result stack to list */
  /* Copy from result stack to list */
  vleft = changed;
  vleft = changed;
  *cv = vpop (&result);
  *cv = vpop (&result);
  while ((*cv != NULL) && (vleft > 0))
  while ((*cv != NULL) && (vleft > 0))
    {
    {
      vleft--;
      vleft--;
      cv++;
      cv++;
      *cv = vpop (&result);
      *cv = vpop (&result);
    }
    }
  if (vleft)
  if (vleft)
    warning ("varobj_update: assertion failed - vleft <> 0");
    warning ("varobj_update: assertion failed - vleft <> 0");
 
 
  if (changed > 1)
  if (changed > 1)
    {
    {
      /* Now we revert the order. */
      /* Now we revert the order. */
      for (i=0; i < changed; i++)
      for (i=0; i < changed; i++)
        *(*changelist + i) = *(templist + changed -1 - i);
        *(*changelist + i) = *(templist + changed -1 - i);
      *(*changelist + changed) = NULL;
      *(*changelist + changed) = NULL;
    }
    }
 
 
  /* Restore selected frame */
  /* Restore selected frame */
  select_frame (old_fi, -1);
  select_frame (old_fi, -1);
 
 
  if (type_changed)
  if (type_changed)
    return -2;
    return -2;
  else
  else
    return changed;
    return changed;
}
}


 
 
/* Helper functions */
/* Helper functions */
 
 
/*
/*
 * Variable object construction/destruction
 * Variable object construction/destruction
 */
 */
 
 
static int
static int
delete_variable (resultp, var, only_children_p)
delete_variable (resultp, var, only_children_p)
     struct cpstack **resultp;
     struct cpstack **resultp;
     struct varobj *var;
     struct varobj *var;
     int only_children_p;
     int only_children_p;
{
{
  int delcount = 0;
  int delcount = 0;
 
 
  delete_variable_1 (resultp, &delcount, var,
  delete_variable_1 (resultp, &delcount, var,
                     only_children_p, 1 /* remove_from_parent_p */ );
                     only_children_p, 1 /* remove_from_parent_p */ );
 
 
  return delcount;
  return delcount;
}
}
 
 
/* Delete the variable object VAR and its children */
/* Delete the variable object VAR and its children */
/* IMPORTANT NOTE: If we delete a variable which is a child
/* IMPORTANT NOTE: If we delete a variable which is a child
   and the parent is not removed we dump core.  It must be always
   and the parent is not removed we dump core.  It must be always
   initially called with remove_from_parent_p set */
   initially called with remove_from_parent_p set */
static void
static void
delete_variable_1 (resultp, delcountp, var,
delete_variable_1 (resultp, delcountp, var,
                   only_children_p, remove_from_parent_p)
                   only_children_p, remove_from_parent_p)
     struct cpstack **resultp;
     struct cpstack **resultp;
     int *delcountp;
     int *delcountp;
     struct varobj *var;
     struct varobj *var;
     int only_children_p;
     int only_children_p;
     int remove_from_parent_p;
     int remove_from_parent_p;
{
{
  struct varobj_child *vc;
  struct varobj_child *vc;
  struct varobj_child *next;
  struct varobj_child *next;
 
 
  /* Delete any children of this variable, too. */
  /* Delete any children of this variable, too. */
  for (vc = var->children; vc != NULL; vc = next)
  for (vc = var->children; vc != NULL; vc = next)
    {
    {
      if (!remove_from_parent_p)
      if (!remove_from_parent_p)
        vc->child->parent = NULL;
        vc->child->parent = NULL;
      delete_variable_1 (resultp, delcountp, vc->child, 0, only_children_p);
      delete_variable_1 (resultp, delcountp, vc->child, 0, only_children_p);
      next = vc->next;
      next = vc->next;
      free (vc);
      free (vc);
    }
    }
 
 
  /* if we were called to delete only the children we are done here */
  /* if we were called to delete only the children we are done here */
  if (only_children_p)
  if (only_children_p)
    return;
    return;
 
 
  /* Otherwise, add it to the list of deleted ones and proceed to do so */
  /* Otherwise, add it to the list of deleted ones and proceed to do so */
  /* If the name is null, this is a temporary variable, that has not
  /* 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... */
     yet been installed, don't report it, it belongs to the caller... */
  if (var->obj_name != NULL)
  if (var->obj_name != NULL)
    {
    {
      cppush (resultp, strdup (var->obj_name));
      cppush (resultp, strdup (var->obj_name));
      *delcountp = *delcountp + 1;
      *delcountp = *delcountp + 1;
    }
    }
 
 
  /* If this variable has a parent, remove it from its parent's list */
  /* If this variable has a parent, remove it from its parent's list */
  /* OPTIMIZATION: if the parent of this variable is also being deleted,
  /* OPTIMIZATION: if the parent of this variable is also being deleted,
     (as indicated by remove_from_parent_p) we don't bother doing an
     (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
     expensive list search to find the element to remove when we are
     discarding the list afterwards */
     discarding the list afterwards */
  if ((remove_from_parent_p) &&
  if ((remove_from_parent_p) &&
      (var->parent != NULL))
      (var->parent != NULL))
    {
    {
      remove_child_from_parent (var->parent, var);
      remove_child_from_parent (var->parent, var);
    }
    }
 
 
  if (var->obj_name != NULL)
  if (var->obj_name != NULL)
    uninstall_variable (var);
    uninstall_variable (var);
 
 
  /* Free memory associated with this variable */
  /* Free memory associated with this variable */
  free_variable (var);
  free_variable (var);
}
}
 
 
/* Install the given variable VAR with the object name VAR->OBJ_NAME. */
/* Install the given variable VAR with the object name VAR->OBJ_NAME. */
static int
static int
install_variable (var)
install_variable (var)
     struct varobj *var;
     struct varobj *var;
{
{
  struct vlist *cv;
  struct vlist *cv;
  struct vlist *newvl;
  struct vlist *newvl;
  const char *chp;
  const char *chp;
  unsigned int index = 0;
  unsigned int index = 0;
  unsigned int i = 1;
  unsigned int i = 1;
 
 
  for (chp = var->obj_name; *chp; chp++)
  for (chp = var->obj_name; *chp; chp++)
    {
    {
      index = (index + (i++ * (unsigned int) *chp)) % VAROBJ_TABLE_SIZE;
      index = (index + (i++ * (unsigned int) *chp)) % VAROBJ_TABLE_SIZE;
    }
    }
 
 
  cv = *(varobj_table + index);
  cv = *(varobj_table + index);
  while ((cv != NULL) && (strcmp (cv->var->obj_name, var->obj_name) != 0))
  while ((cv != NULL) && (strcmp (cv->var->obj_name, var->obj_name) != 0))
    cv = cv->next;
    cv = cv->next;
 
 
  if (cv != NULL)
  if (cv != NULL)
    error ("Duplicate variable object name");
    error ("Duplicate variable object name");
 
 
  /* Add varobj to hash table */
  /* Add varobj to hash table */
  newvl = xmalloc (sizeof (struct vlist));
  newvl = xmalloc (sizeof (struct vlist));
  newvl->next = *(varobj_table + index);
  newvl->next = *(varobj_table + index);
  newvl->var = var;
  newvl->var = var;
  *(varobj_table + index) = newvl;
  *(varobj_table + index) = newvl;
 
 
  /* If root, add varobj to root list */
  /* If root, add varobj to root list */
  if (var->root->rootvar == var)
  if (var->root->rootvar == var)
    {
    {
      /* Add to list of root variables */
      /* Add to list of root variables */
      if (rootlist == NULL)
      if (rootlist == NULL)
        var->root->next = NULL;
        var->root->next = NULL;
      else
      else
        var->root->next = rootlist;
        var->root->next = rootlist;
      rootlist = var->root;
      rootlist = var->root;
      rootcount++;
      rootcount++;
    }
    }
 
 
  return 1;                     /* OK */
  return 1;                     /* OK */
}
}
 
 
/* Unistall the object VAR. */
/* Unistall the object VAR. */
static void
static void
uninstall_variable (var)
uninstall_variable (var)
     struct varobj *var;
     struct varobj *var;
{
{
  struct vlist *cv;
  struct vlist *cv;
  struct vlist *prev;
  struct vlist *prev;
  struct varobj_root *cr;
  struct varobj_root *cr;
  struct varobj_root *prer;
  struct varobj_root *prer;
  const char *chp;
  const char *chp;
  unsigned int index = 0;
  unsigned int index = 0;
  unsigned int i = 1;
  unsigned int i = 1;
 
 
  /* Remove varobj from hash table */
  /* Remove varobj from hash table */
  for (chp = var->obj_name; *chp; chp++)
  for (chp = var->obj_name; *chp; chp++)
    {
    {
      index = (index + (i++ * (unsigned int) *chp)) % VAROBJ_TABLE_SIZE;
      index = (index + (i++ * (unsigned int) *chp)) % VAROBJ_TABLE_SIZE;
    }
    }
 
 
  cv = *(varobj_table + index);
  cv = *(varobj_table + index);
  prev = NULL;
  prev = NULL;
  while ((cv != NULL) && (strcmp (cv->var->obj_name, var->obj_name) != 0))
  while ((cv != NULL) && (strcmp (cv->var->obj_name, var->obj_name) != 0))
    {
    {
      prev = cv;
      prev = cv;
      cv = cv->next;
      cv = cv->next;
    }
    }
 
 
  if (varobjdebug)
  if (varobjdebug)
    fprintf_unfiltered (gdb_stdlog, "Deleting %s\n", var->obj_name);
    fprintf_unfiltered (gdb_stdlog, "Deleting %s\n", var->obj_name);
 
 
  if (cv == NULL)
  if (cv == NULL)
    {
    {
      warning ("Assertion failed: Could not find variable object \"%s\" to delete", var->obj_name);
      warning ("Assertion failed: Could not find variable object \"%s\" to delete", var->obj_name);
      return;
      return;
    }
    }
 
 
  if (prev == NULL)
  if (prev == NULL)
    *(varobj_table + index) = cv->next;
    *(varobj_table + index) = cv->next;
  else
  else
    prev->next = cv->next;
    prev->next = cv->next;
 
 
  free (cv);
  free (cv);
 
 
  /* If root, remove varobj from root list */
  /* If root, remove varobj from root list */
  if (var->root->rootvar == var)
  if (var->root->rootvar == var)
    {
    {
      /* Remove from list of root variables */
      /* Remove from list of root variables */
      if (rootlist == var->root)
      if (rootlist == var->root)
        rootlist = var->root->next;
        rootlist = var->root->next;
      else
      else
        {
        {
          prer = NULL;
          prer = NULL;
          cr = rootlist;
          cr = rootlist;
          while ((cr != NULL) && (cr->rootvar != var))
          while ((cr != NULL) && (cr->rootvar != var))
            {
            {
              prer = cr;
              prer = cr;
              cr = cr->next;
              cr = cr->next;
            }
            }
          if (cr == NULL)
          if (cr == NULL)
            {
            {
              warning ("Assertion failed: Could not find varobj \"%s\" in root list", var->obj_name);
              warning ("Assertion failed: Could not find varobj \"%s\" in root list", var->obj_name);
              return;
              return;
            }
            }
          if (prer == NULL)
          if (prer == NULL)
            rootlist = NULL;
            rootlist = NULL;
          else
          else
            prer->next = cr->next;
            prer->next = cr->next;
        }
        }
      rootcount--;
      rootcount--;
    }
    }
 
 
}
}
 
 
/* Does a child with the name NAME exist in VAR? If so, return its data.
/* Does a child with the name NAME exist in VAR? If so, return its data.
   If not, return NULL. */
   If not, return NULL. */
static struct varobj *
static struct varobj *
child_exists (var, name)
child_exists (var, name)
     struct varobj *var;        /* Parent */
     struct varobj *var;        /* Parent */
     char *name;                /* name of child */
     char *name;                /* name of child */
{
{
  struct varobj_child *vc;
  struct varobj_child *vc;
 
 
  for (vc = var->children; vc != NULL; vc = vc->next)
  for (vc = var->children; vc != NULL; vc = vc->next)
    {
    {
      if (STREQ (vc->child->name, name))
      if (STREQ (vc->child->name, name))
        return vc->child;
        return vc->child;
    }
    }
 
 
  return NULL;
  return NULL;
}
}
 
 
/* Create and install a child of the parent of the given name */
/* Create and install a child of the parent of the given name */
static struct varobj *
static struct varobj *
create_child (parent, index, name)
create_child (parent, index, name)
     struct varobj *parent;
     struct varobj *parent;
     int index;
     int index;
     char *name;
     char *name;
{
{
  struct varobj *child;
  struct varobj *child;
  char *childs_name;
  char *childs_name;
 
 
  child = new_variable ();
  child = new_variable ();
 
 
  /* name is allocated by name_of_child */
  /* name is allocated by name_of_child */
  child->name = name;
  child->name = name;
  child->index = index;
  child->index = index;
  child->value = value_of_child (parent, index);
  child->value = value_of_child (parent, index);
  if (child->value == NULL || parent->error)
  if (child->value == NULL || parent->error)
    child->error = 1;
    child->error = 1;
  child->parent = parent;
  child->parent = parent;
  child->root = parent->root;
  child->root = parent->root;
  childs_name = (char *) xmalloc ((strlen (parent->obj_name) + strlen (name) + 2)
  childs_name = (char *) xmalloc ((strlen (parent->obj_name) + strlen (name) + 2)
                                  * sizeof (char));
                                  * sizeof (char));
  sprintf (childs_name, "%s.%s", parent->obj_name, name);
  sprintf (childs_name, "%s.%s", parent->obj_name, name);
  child->obj_name = childs_name;
  child->obj_name = childs_name;
  install_variable (child);
  install_variable (child);
 
 
  /* Save a pointer to this child in the parent */
  /* Save a pointer to this child in the parent */
  save_child_in_parent (parent, child);
  save_child_in_parent (parent, child);
 
 
  /* Note the type of this child */
  /* Note the type of this child */
  child->type = type_of_child (child);
  child->type = type_of_child (child);
 
 
  return child;
  return child;
}
}
 
 
/* FIXME: This should be a generic add to list */
/* FIXME: This should be a generic add to list */
/* Save CHILD in the PARENT's data. */
/* Save CHILD in the PARENT's data. */
static void
static void
save_child_in_parent (parent, child)
save_child_in_parent (parent, child)
     struct varobj *parent;
     struct varobj *parent;
     struct varobj *child;
     struct varobj *child;
{
{
  struct varobj_child *vc;
  struct varobj_child *vc;
 
 
  /* Insert the child at the top */
  /* Insert the child at the top */
  vc = parent->children;
  vc = parent->children;
  parent->children =
  parent->children =
    (struct varobj_child *) xmalloc (sizeof (struct varobj_child));
    (struct varobj_child *) xmalloc (sizeof (struct varobj_child));
 
 
  parent->children->next = vc;
  parent->children->next = vc;
  parent->children->child = child;
  parent->children->child = child;
}
}
 
 
/* FIXME: This should be a generic remove from list */
/* FIXME: This should be a generic remove from list */
/* Remove the CHILD from the PARENT's list of children. */
/* Remove the CHILD from the PARENT's list of children. */
static void
static void
remove_child_from_parent (parent, child)
remove_child_from_parent (parent, child)
     struct varobj *parent;
     struct varobj *parent;
     struct varobj *child;
     struct varobj *child;
{
{
  struct varobj_child *vc, *prev;
  struct varobj_child *vc, *prev;
 
 
  /* Find the child in the parent's list */
  /* Find the child in the parent's list */
  prev = NULL;
  prev = NULL;
  for (vc = parent->children; vc != NULL;)
  for (vc = parent->children; vc != NULL;)
    {
    {
      if (vc->child == child)
      if (vc->child == child)
        break;
        break;
      prev = vc;
      prev = vc;
      vc = vc->next;
      vc = vc->next;
    }
    }
 
 
  if (prev == NULL)
  if (prev == NULL)
    parent->children = vc->next;
    parent->children = vc->next;
  else
  else
    prev->next = vc->next;
    prev->next = vc->next;
 
 
}
}


 
 
/*
/*
 * Miscellaneous utility functions.
 * Miscellaneous utility functions.
 */
 */
 
 
/* Allocate memory and initialize a new variable */
/* Allocate memory and initialize a new variable */
static struct varobj *
static struct varobj *
new_variable (void)
new_variable (void)
{
{
  struct varobj *var;
  struct varobj *var;
 
 
  var = (struct varobj *) xmalloc (sizeof (struct varobj));
  var = (struct varobj *) xmalloc (sizeof (struct varobj));
  var->name = NULL;
  var->name = NULL;
  var->obj_name = NULL;
  var->obj_name = NULL;
  var->index = -1;
  var->index = -1;
  var->type = NULL;
  var->type = NULL;
  var->value = NULL;
  var->value = NULL;
  var->error = 0;
  var->error = 0;
  var->num_children = -1;
  var->num_children = -1;
  var->parent = NULL;
  var->parent = NULL;
  var->children = NULL;
  var->children = NULL;
  var->format = 0;
  var->format = 0;
  var->root = NULL;
  var->root = NULL;
 
 
  return var;
  return var;
}
}
 
 
/* Allocate memory and initialize a new root variable */
/* Allocate memory and initialize a new root variable */
static struct varobj *
static struct varobj *
new_root_variable (void)
new_root_variable (void)
{
{
  struct varobj *var = new_variable ();
  struct varobj *var = new_variable ();
  var->root = (struct varobj_root *) xmalloc (sizeof (struct varobj_root));;
  var->root = (struct varobj_root *) xmalloc (sizeof (struct varobj_root));;
  var->root->lang = NULL;
  var->root->lang = NULL;
  var->root->exp = NULL;
  var->root->exp = NULL;
  var->root->valid_block = NULL;
  var->root->valid_block = NULL;
  var->root->frame = (CORE_ADDR) -1;
  var->root->frame = (CORE_ADDR) -1;
  var->root->use_selected_frame = 0;
  var->root->use_selected_frame = 0;
  var->root->rootvar = NULL;
  var->root->rootvar = NULL;
 
 
  return var;
  return var;
}
}
 
 
/* Free any allocated memory associated with VAR. */
/* Free any allocated memory associated with VAR. */
static void
static void
free_variable (var)
free_variable (var)
     struct varobj *var;
     struct varobj *var;
{
{
  /* Free the expression if this is a root variable. */
  /* Free the expression if this is a root variable. */
  if (var->root->rootvar == var)
  if (var->root->rootvar == var)
    {
    {
      free_current_contents ((char **) &var->root->exp);
      free_current_contents ((char **) &var->root->exp);
      FREEIF (var->root);
      FREEIF (var->root);
    }
    }
 
 
  FREEIF (var->name);
  FREEIF (var->name);
  FREEIF (var->obj_name);
  FREEIF (var->obj_name);
  FREEIF (var);
  FREEIF (var);
}
}
 
 
/* This returns the type of the variable. This skips past typedefs
/* This returns the type of the variable. This skips past typedefs
   and returns the real type of the variable. It also dereferences
   and returns the real type of the variable. It also dereferences
   pointers and references. */
   pointers and references. */
static struct type *
static struct type *
get_type (var)
get_type (var)
     struct varobj *var;
     struct varobj *var;
{
{
  struct type *type;
  struct type *type;
  type = var->type;
  type = var->type;
 
 
  while (type != NULL && TYPE_CODE (type) == TYPE_CODE_TYPEDEF)
  while (type != NULL && TYPE_CODE (type) == TYPE_CODE_TYPEDEF)
    type = TYPE_TARGET_TYPE (type);
    type = TYPE_TARGET_TYPE (type);
 
 
  return type;
  return type;
}
}
 
 
/* This returns the type of the variable, dereferencing pointers, too. */
/* This returns the type of the variable, dereferencing pointers, too. */
static struct type *
static struct type *
get_type_deref (var)
get_type_deref (var)
     struct varobj *var;
     struct varobj *var;
{
{
  struct type *type;
  struct type *type;
 
 
  type = get_type (var);
  type = get_type (var);
 
 
  if (type != NULL && (TYPE_CODE (type) == TYPE_CODE_PTR
  if (type != NULL && (TYPE_CODE (type) == TYPE_CODE_PTR
                       || TYPE_CODE (type) == TYPE_CODE_REF))
                       || TYPE_CODE (type) == TYPE_CODE_REF))
    type = get_target_type (type);
    type = get_target_type (type);
 
 
  return type;
  return type;
}
}
 
 
/* This returns the target type (or NULL) of TYPE, also skipping
/* This returns the target type (or NULL) of TYPE, also skipping
   past typedefs, just like get_type (). */
   past typedefs, just like get_type (). */
static struct type *
static struct type *
get_target_type (type)
get_target_type (type)
     struct type *type;
     struct type *type;
{
{
  if (type != NULL)
  if (type != NULL)
    {
    {
      type = TYPE_TARGET_TYPE (type);
      type = TYPE_TARGET_TYPE (type);
      while (type != NULL && TYPE_CODE (type) == TYPE_CODE_TYPEDEF)
      while (type != NULL && TYPE_CODE (type) == TYPE_CODE_TYPEDEF)
        type = TYPE_TARGET_TYPE (type);
        type = TYPE_TARGET_TYPE (type);
    }
    }
 
 
  return type;
  return type;
}
}
 
 
/* What is the default display for this variable? We assume that
/* What is the default display for this variable? We assume that
   everything is "natural". Any exceptions? */
   everything is "natural". Any exceptions? */
static enum varobj_display_formats
static enum varobj_display_formats
variable_default_display (var)
variable_default_display (var)
     struct varobj *var;
     struct varobj *var;
{
{
  return FORMAT_NATURAL;
  return FORMAT_NATURAL;
}
}
 
 
/* This function is similar to gdb's value_equal, except that this
/* This function is similar to gdb's value_equal, except that this
   one is "safe" -- it NEVER longjmps. It determines if the VAR's
   one is "safe" -- it NEVER longjmps. It determines if the VAR's
   value is the same as VAL2. */
   value is the same as VAL2. */
static int
static int
my_value_equal (val1, val2, error2)
my_value_equal (val1, val2, error2)
     value_ptr val1;
     value_ptr val1;
     value_ptr val2;
     value_ptr val2;
     int *error2;
     int *error2;
{
{
  int r, err1, err2;
  int r, err1, err2;
 
 
  *error2 = 0;
  *error2 = 0;
  /* Special case: NULL values. If both are null, say
  /* Special case: NULL values. If both are null, say
     they're equal. */
     they're equal. */
  if (val1 == NULL && val2 == NULL)
  if (val1 == NULL && val2 == NULL)
    return 1;
    return 1;
  else if (val1 == NULL || val2 == NULL)
  else if (val1 == NULL || val2 == NULL)
    return 0;
    return 0;
 
 
  /* This is bogus, but unfortunately necessary. We must know
  /* This is bogus, but unfortunately necessary. We must know
     exactly what caused an error -- reading val1 or val2 --  so
     exactly what caused an error -- reading val1 or val2 --  so
     that we can really determine if we think that something has changed. */
     that we can really determine if we think that something has changed. */
  err1 = 0;
  err1 = 0;
  err2 = 0;
  err2 = 0;
  /* We do need to catch errors here because the whole purpose
  /* We do need to catch errors here because the whole purpose
     is to test if value_equal() has errored */
     is to test if value_equal() has errored */
  if (!gdb_value_equal (val1, val1, &r))
  if (!gdb_value_equal (val1, val1, &r))
    err1 = 1;
    err1 = 1;
 
 
  if (!gdb_value_equal (val2, val2, &r))
  if (!gdb_value_equal (val2, val2, &r))
    *error2 = err2 = 1;
    *error2 = err2 = 1;
 
 
  if (err1 != err2)
  if (err1 != err2)
    return 0;
    return 0;
 
 
  if (!gdb_value_equal (val1, val2, &r))
  if (!gdb_value_equal (val1, val2, &r))
    {
    {
      /* An error occurred, this could have happened if
      /* An error occurred, this could have happened if
         either val1 or val2 errored. ERR1 and ERR2 tell
         either val1 or val2 errored. ERR1 and ERR2 tell
         us which of these it is. If both errored, then
         us which of these it is. If both errored, then
         we assume nothing has changed. If one of them is
         we assume nothing has changed. If one of them is
         valid, though, then something has changed. */
         valid, though, then something has changed. */
      if (err1 == err2)
      if (err1 == err2)
        {
        {
          /* both the old and new values caused errors, so
          /* both the old and new values caused errors, so
             we say the value did not change */
             we say the value did not change */
          /* This is indeterminate, though. Perhaps we should
          /* This is indeterminate, though. Perhaps we should
             be safe and say, yes, it changed anyway?? */
             be safe and say, yes, it changed anyway?? */
          return 1;
          return 1;
        }
        }
      else
      else
        {
        {
          return 0;
          return 0;
        }
        }
    }
    }
 
 
  return r;
  return r;
}
}
 
 
/* FIXME: The following should be generic for any pointer */
/* FIXME: The following should be generic for any pointer */
static void
static void
vpush (pstack, var)
vpush (pstack, var)
     struct vstack **pstack;
     struct vstack **pstack;
     struct varobj *var;
     struct varobj *var;
{
{
  struct vstack *s;
  struct vstack *s;
 
 
  s = (struct vstack *) xmalloc (sizeof (struct vstack));
  s = (struct vstack *) xmalloc (sizeof (struct vstack));
  s->var = var;
  s->var = var;
  s->next = *pstack;
  s->next = *pstack;
  *pstack = s;
  *pstack = s;
}
}
 
 
/* FIXME: The following should be generic for any pointer */
/* FIXME: The following should be generic for any pointer */
static struct varobj *
static struct varobj *
vpop (pstack)
vpop (pstack)
     struct vstack **pstack;
     struct vstack **pstack;
{
{
  struct vstack *s;
  struct vstack *s;
  struct varobj *v;
  struct varobj *v;
 
 
  if ((*pstack)->var == NULL && (*pstack)->next == NULL)
  if ((*pstack)->var == NULL && (*pstack)->next == NULL)
    return NULL;
    return NULL;
 
 
  s = *pstack;
  s = *pstack;
  v = s->var;
  v = s->var;
  *pstack = (*pstack)->next;
  *pstack = (*pstack)->next;
  free (s);
  free (s);
 
 
  return v;
  return v;
}
}
 
 
/* FIXME: The following should be generic for any pointer */
/* FIXME: The following should be generic for any pointer */
static void
static void
cppush (pstack, name)
cppush (pstack, name)
     struct cpstack **pstack;
     struct cpstack **pstack;
     char *name;
     char *name;
{
{
  struct cpstack *s;
  struct cpstack *s;
 
 
  s = (struct cpstack *) xmalloc (sizeof (struct cpstack));
  s = (struct cpstack *) xmalloc (sizeof (struct cpstack));
  s->name = name;
  s->name = name;
  s->next = *pstack;
  s->next = *pstack;
  *pstack = s;
  *pstack = s;
}
}
 
 
/* FIXME: The following should be generic for any pointer */
/* FIXME: The following should be generic for any pointer */
static char *
static char *
cppop (pstack)
cppop (pstack)
     struct cpstack **pstack;
     struct cpstack **pstack;
{
{
  struct cpstack *s;
  struct cpstack *s;
  char *v;
  char *v;
 
 
  if ((*pstack)->name == NULL && (*pstack)->next == NULL)
  if ((*pstack)->name == NULL && (*pstack)->next == NULL)
    return NULL;
    return NULL;
 
 
  s = *pstack;
  s = *pstack;
  v = s->name;
  v = s->name;
  *pstack = (*pstack)->next;
  *pstack = (*pstack)->next;
  free (s);
  free (s);
 
 
  return v;
  return v;
}
}


/*
/*
 * Language-dependencies
 * Language-dependencies
 */
 */
 
 
/* Common entry points */
/* Common entry points */
 
 
/* Get the language of variable VAR. */
/* Get the language of variable VAR. */
static enum varobj_languages
static enum varobj_languages
variable_language (var)
variable_language (var)
     struct varobj *var;
     struct varobj *var;
{
{
  enum varobj_languages lang;
  enum varobj_languages lang;
 
 
  switch (var->root->exp->language_defn->la_language)
  switch (var->root->exp->language_defn->la_language)
    {
    {
    default:
    default:
    case language_c:
    case language_c:
      lang = vlang_c;
      lang = vlang_c;
      break;
      break;
    case language_cplus:
    case language_cplus:
      lang = vlang_cplus;
      lang = vlang_cplus;
      break;
      break;
    case language_java:
    case language_java:
      lang = vlang_java;
      lang = vlang_java;
      break;
      break;
    }
    }
 
 
  return lang;
  return lang;
}
}
 
 
/* Return the number of children for a given variable.
/* Return the number of children for a given variable.
   The result of this function is defined by the language
   The result of this function is defined by the language
   implementation. The number of children returned by this function
   implementation. The number of children returned by this function
   is the number of children that the user will see in the variable
   is the number of children that the user will see in the variable
   display. */
   display. */
static int
static int
number_of_children (var)
number_of_children (var)
     struct varobj *var;
     struct varobj *var;
{
{
  return (*var->root->lang->number_of_children) (var);;
  return (*var->root->lang->number_of_children) (var);;
}
}
 
 
/* What is the expression for the root varobj VAR? Returns a malloc'd string. */
/* What is the expression for the root varobj VAR? Returns a malloc'd string. */
static char *
static char *
name_of_variable (var)
name_of_variable (var)
     struct varobj *var;
     struct varobj *var;
{
{
  return (*var->root->lang->name_of_variable) (var);
  return (*var->root->lang->name_of_variable) (var);
}
}
 
 
/* What is the name of the INDEX'th child of VAR? Returns a malloc'd string. */
/* What is the name of the INDEX'th child of VAR? Returns a malloc'd string. */
static char *
static char *
name_of_child (var, index)
name_of_child (var, index)
     struct varobj *var;
     struct varobj *var;
     int index;
     int index;
{
{
  return (*var->root->lang->name_of_child) (var, index);
  return (*var->root->lang->name_of_child) (var, index);
}
}
 
 
/* What is the value_ptr of the root variable VAR?
/* What is the value_ptr of the root variable VAR?
   TYPE_CHANGED controls what to do if the type of a
   TYPE_CHANGED controls what to do if the type of a
   use_selected_frame = 1 variable changes.  On input,
   use_selected_frame = 1 variable changes.  On input,
   TYPE_CHANGED = 1 means discard the old varobj, and replace
   TYPE_CHANGED = 1 means discard the old varobj, and replace
   it with this one.  TYPE_CHANGED = 0 means leave it around.
   it with this one.  TYPE_CHANGED = 0 means leave it around.
   NB: In both cases, var_handle will point to the new varobj,
   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
   so if you use TYPE_CHANGED = 0, you will have to stash the
   old varobj pointer away somewhere before calling this.
   old varobj pointer away somewhere before calling this.
   On return, TYPE_CHANGED will be 1 if the type has changed, and
   On return, TYPE_CHANGED will be 1 if the type has changed, and
   0 otherwise. */
   0 otherwise. */
static value_ptr
static value_ptr
value_of_root (var_handle, type_changed)
value_of_root (var_handle, type_changed)
     struct varobj ** var_handle;
     struct varobj ** var_handle;
     int *type_changed;
     int *type_changed;
{
{
  struct varobj *var;
  struct varobj *var;
 
 
  if (var_handle == NULL)
  if (var_handle == NULL)
    return NULL;
    return NULL;
 
 
  var = *var_handle;
  var = *var_handle;
 
 
  /* This should really be an exception, since this should
  /* This should really be an exception, since this should
     only get called with a root variable. */
     only get called with a root variable. */
 
 
  if (var->root->rootvar != var)
  if (var->root->rootvar != var)
    return NULL;
    return NULL;
 
 
  if (var->root->use_selected_frame)
  if (var->root->use_selected_frame)
    {
    {
      struct varobj *tmp_var;
      struct varobj *tmp_var;
      char *old_type, *new_type;
      char *old_type, *new_type;
      old_type = varobj_get_type (var);
      old_type = varobj_get_type (var);
      tmp_var = varobj_create (NULL, var->name, (CORE_ADDR) 0,
      tmp_var = varobj_create (NULL, var->name, (CORE_ADDR) 0,
                               USE_SELECTED_FRAME);
                               USE_SELECTED_FRAME);
      if (tmp_var == NULL)
      if (tmp_var == NULL)
        {
        {
          return NULL;
          return NULL;
        }
        }
      new_type = varobj_get_type (tmp_var);
      new_type = varobj_get_type (tmp_var);
      if (strcmp(old_type, new_type) == 0)
      if (strcmp(old_type, new_type) == 0)
        {
        {
          varobj_delete (tmp_var, NULL, 0);
          varobj_delete (tmp_var, NULL, 0);
          *type_changed = 0;
          *type_changed = 0;
        }
        }
      else
      else
        {
        {
          if (*type_changed)
          if (*type_changed)
            {
            {
              tmp_var->obj_name =
              tmp_var->obj_name =
                savestring (var->obj_name, strlen (var->obj_name));
                savestring (var->obj_name, strlen (var->obj_name));
              uninstall_variable (var);
              uninstall_variable (var);
            }
            }
          else
          else
            {
            {
              tmp_var->obj_name = varobj_gen_name ();
              tmp_var->obj_name = varobj_gen_name ();
            }
            }
          install_variable (tmp_var);
          install_variable (tmp_var);
          *var_handle = tmp_var;
          *var_handle = tmp_var;
          *type_changed = 1;
          *type_changed = 1;
        }
        }
    }
    }
  else
  else
    {
    {
      *type_changed = 0;
      *type_changed = 0;
    }
    }
 
 
  return (*var->root->lang->value_of_root) (var_handle);
  return (*var->root->lang->value_of_root) (var_handle);
}
}
 
 
/* What is the value_ptr for the INDEX'th child of PARENT? */
/* What is the value_ptr for the INDEX'th child of PARENT? */
static value_ptr
static value_ptr
value_of_child (parent, index)
value_of_child (parent, index)
     struct varobj *parent;
     struct varobj *parent;
     int index;
     int index;
{
{
  value_ptr value;
  value_ptr value;
 
 
  value = (*parent->root->lang->value_of_child) (parent, index);
  value = (*parent->root->lang->value_of_child) (parent, index);
 
 
  /* If we're being lazy, fetch the real value of the variable. */
  /* If we're being lazy, fetch the real value of the variable. */
  if (value != NULL && VALUE_LAZY (value))
  if (value != NULL && VALUE_LAZY (value))
    gdb_value_fetch_lazy (value);
    gdb_value_fetch_lazy (value);
 
 
  return value;
  return value;
}
}
 
 
/* What is the type of VAR? */
/* What is the type of VAR? */
static struct type *
static struct type *
type_of_child (var)
type_of_child (var)
     struct varobj *var;
     struct varobj *var;
{
{
 
 
  /* If the child had no evaluation errors, var->value
  /* If the child had no evaluation errors, var->value
     will be non-NULL and contain a valid type. */
     will be non-NULL and contain a valid type. */
  if (var->value != NULL)
  if (var->value != NULL)
    return VALUE_TYPE (var->value);
    return VALUE_TYPE (var->value);
 
 
  /* Otherwise, we must compute the type. */
  /* Otherwise, we must compute the type. */
  return (*var->root->lang->type_of_child) (var->parent, var->index);
  return (*var->root->lang->type_of_child) (var->parent, var->index);
}
}
 
 
/* Is this variable editable? Use the variable's type to make
/* Is this variable editable? Use the variable's type to make
   this determination. */
   this determination. */
static int
static int
variable_editable (var)
variable_editable (var)
     struct varobj *var;
     struct varobj *var;
{
{
  return (*var->root->lang->variable_editable) (var);
  return (*var->root->lang->variable_editable) (var);
}
}
 
 
/* GDB already has a command called "value_of_variable". Sigh. */
/* GDB already has a command called "value_of_variable". Sigh. */
static char *
static char *
my_value_of_variable (var)
my_value_of_variable (var)
     struct varobj *var;
     struct varobj *var;
{
{
  return (*var->root->lang->value_of_variable) (var);
  return (*var->root->lang->value_of_variable) (var);
}
}
 
 
/* Is VAR something that can change? Depending on language,
/* Is VAR something that can change? Depending on language,
   some variable's values never change. For example,
   some variable's values never change. For example,
   struct and unions never change values. */
   struct and unions never change values. */
static int
static int
type_changeable (var)
type_changeable (var)
     struct varobj *var;
     struct varobj *var;
{
{
  int r;
  int r;
  struct type *type;
  struct type *type;
 
 
  if (CPLUS_FAKE_CHILD (var))
  if (CPLUS_FAKE_CHILD (var))
    return 0;
    return 0;
 
 
  type = get_type (var);
  type = get_type (var);
 
 
  switch (TYPE_CODE (type))
  switch (TYPE_CODE (type))
    {
    {
      case TYPE_CODE_STRUCT:
      case TYPE_CODE_STRUCT:
      case TYPE_CODE_UNION:
      case TYPE_CODE_UNION:
        r = 0;
        r = 0;
        break;
        break;
 
 
      default:
      default:
        r = 1;
        r = 1;
    }
    }
 
 
  return r;
  return r;
}
}
 
 
/* C */
/* C */
static int
static int
c_number_of_children (var)
c_number_of_children (var)
     struct varobj *var;
     struct varobj *var;
{
{
  struct type *type;
  struct type *type;
  struct type *target;
  struct type *target;
  int children;
  int children;
 
 
  type = get_type (var);
  type = get_type (var);
  target = get_target_type (type);
  target = get_target_type (type);
  children = 0;
  children = 0;
 
 
  switch (TYPE_CODE (type))
  switch (TYPE_CODE (type))
    {
    {
    case TYPE_CODE_ARRAY:
    case TYPE_CODE_ARRAY:
      if (TYPE_LENGTH (type) > 0 && TYPE_LENGTH (target) > 0
      if (TYPE_LENGTH (type) > 0 && TYPE_LENGTH (target) > 0
        && TYPE_ARRAY_UPPER_BOUND_TYPE (type) != BOUND_CANNOT_BE_DETERMINED)
        && TYPE_ARRAY_UPPER_BOUND_TYPE (type) != BOUND_CANNOT_BE_DETERMINED)
        children = TYPE_LENGTH (type) / TYPE_LENGTH (target);
        children = TYPE_LENGTH (type) / TYPE_LENGTH (target);
      else
      else
        children = -1;
        children = -1;
      break;
      break;
 
 
    case TYPE_CODE_STRUCT:
    case TYPE_CODE_STRUCT:
    case TYPE_CODE_UNION:
    case TYPE_CODE_UNION:
      children = TYPE_NFIELDS (type);
      children = TYPE_NFIELDS (type);
      break;
      break;
 
 
    case TYPE_CODE_PTR:
    case TYPE_CODE_PTR:
      /* This is where things get compilcated. All pointers have one child.
      /* This is where things get compilcated. All pointers have one child.
         Except, of course, for struct and union ptr, which we automagically
         Except, of course, for struct and union ptr, which we automagically
         dereference for the user and function ptrs, which have no children. */
         dereference for the user and function ptrs, which have no children. */
      switch (TYPE_CODE (target))
      switch (TYPE_CODE (target))
        {
        {
        case TYPE_CODE_STRUCT:
        case TYPE_CODE_STRUCT:
        case TYPE_CODE_UNION:
        case TYPE_CODE_UNION:
          children = TYPE_NFIELDS (target);
          children = TYPE_NFIELDS (target);
          break;
          break;
 
 
        case TYPE_CODE_FUNC:
        case TYPE_CODE_FUNC:
          children = 0;
          children = 0;
          break;
          break;
 
 
        default:
        default:
          /* Don't dereference char* or void*. */
          /* Don't dereference char* or void*. */
          if (TYPE_NAME (target) != NULL
          if (TYPE_NAME (target) != NULL
              && (STREQ (TYPE_NAME (target), "char")
              && (STREQ (TYPE_NAME (target), "char")
                  || STREQ (TYPE_NAME (target), "void")))
                  || STREQ (TYPE_NAME (target), "void")))
            children = 0;
            children = 0;
          else
          else
            children = 1;
            children = 1;
        }
        }
      break;
      break;
 
 
    default:
    default:
      /* Other types have no children */
      /* Other types have no children */
      break;
      break;
    }
    }
 
 
  return children;
  return children;
}
}
 
 
static char *
static char *
c_name_of_variable (parent)
c_name_of_variable (parent)
     struct varobj *parent;
     struct varobj *parent;
{
{
  return savestring (parent->name, strlen (parent->name));
  return savestring (parent->name, strlen (parent->name));
}
}
 
 
static char *
static char *
c_name_of_child (parent, index)
c_name_of_child (parent, index)
     struct varobj *parent;
     struct varobj *parent;
     int index;
     int index;
{
{
  struct type *type;
  struct type *type;
  struct type *target;
  struct type *target;
  char *name;
  char *name;
  char *string;
  char *string;
 
 
  type = get_type (parent);
  type = get_type (parent);
  target = get_target_type (type);
  target = get_target_type (type);
 
 
  switch (TYPE_CODE (type))
  switch (TYPE_CODE (type))
    {
    {
    case TYPE_CODE_ARRAY:
    case TYPE_CODE_ARRAY:
      {
      {
        /* We never get here unless parent->num_children is greater than 0... */
        /* We never get here unless parent->num_children is greater than 0... */
        int len = 1;
        int len = 1;
        while ((int) pow ((double) 10, (double) len) < index)
        while ((int) pow ((double) 10, (double) len) < index)
          len++;
          len++;
        name = (char *) xmalloc (1 + len * sizeof (char));
        name = (char *) xmalloc (1 + len * sizeof (char));
        sprintf (name, "%d", index);
        sprintf (name, "%d", index);
      }
      }
      break;
      break;
 
 
    case TYPE_CODE_STRUCT:
    case TYPE_CODE_STRUCT:
    case TYPE_CODE_UNION:
    case TYPE_CODE_UNION:
      string = TYPE_FIELD_NAME (type, index);
      string = TYPE_FIELD_NAME (type, index);
      name = savestring (string, strlen (string));
      name = savestring (string, strlen (string));
      break;
      break;
 
 
    case TYPE_CODE_PTR:
    case TYPE_CODE_PTR:
      switch (TYPE_CODE (target))
      switch (TYPE_CODE (target))
        {
        {
        case TYPE_CODE_STRUCT:
        case TYPE_CODE_STRUCT:
        case TYPE_CODE_UNION:
        case TYPE_CODE_UNION:
          string = TYPE_FIELD_NAME (target, index);
          string = TYPE_FIELD_NAME (target, index);
          name = savestring (string, strlen (string));
          name = savestring (string, strlen (string));
          break;
          break;
 
 
        default:
        default:
          name = (char *) xmalloc ((strlen (parent->name) + 2) * sizeof (char));
          name = (char *) xmalloc ((strlen (parent->name) + 2) * sizeof (char));
          sprintf (name, "*%s", parent->name);
          sprintf (name, "*%s", parent->name);
          break;
          break;
        }
        }
      break;
      break;
 
 
    default:
    default:
      /* This should not happen */
      /* This should not happen */
      name = xstrdup ("???");
      name = xstrdup ("???");
    }
    }
 
 
  return name;
  return name;
}
}
 
 
static value_ptr
static value_ptr
c_value_of_root (var_handle)
c_value_of_root (var_handle)
     struct varobj **var_handle;
     struct varobj **var_handle;
{
{
  value_ptr new_val;
  value_ptr new_val;
  struct varobj *var = *var_handle;
  struct varobj *var = *var_handle;
  struct frame_info *fi;
  struct frame_info *fi;
  int within_scope;
  int within_scope;
 
 
  /*  Only root variables can be updated... */
  /*  Only root variables can be updated... */
  if (var->root->rootvar != var)
  if (var->root->rootvar != var)
    /* Not a root var */
    /* Not a root var */
    return NULL;
    return NULL;
 
 
 
 
  /* Determine whether the variable is still around. */
  /* Determine whether the variable is still around. */
  if (var->root->valid_block == NULL)
  if (var->root->valid_block == NULL)
    within_scope = 1;
    within_scope = 1;
  else
  else
    {
    {
      reinit_frame_cache ();
      reinit_frame_cache ();
 
 
 
 
      fi = find_frame_addr_in_frame_chain (var->root->frame);
      fi = find_frame_addr_in_frame_chain (var->root->frame);
 
 
      within_scope = fi != NULL;
      within_scope = fi != NULL;
      /* FIXME: select_frame could fail */
      /* FIXME: select_frame could fail */
      if (within_scope)
      if (within_scope)
        select_frame (fi, -1);
        select_frame (fi, -1);
    }
    }
 
 
  if (within_scope)
  if (within_scope)
    {
    {
      /* We need to catch errors here, because if evaluate
      /* We need to catch errors here, because if evaluate
         expression fails we just want to make val->error = 1 and
         expression fails we just want to make val->error = 1 and
         go on */
         go on */
      if (gdb_evaluate_expression (var->root->exp, &new_val))
      if (gdb_evaluate_expression (var->root->exp, &new_val))
        {
        {
          if (VALUE_LAZY (new_val))
          if (VALUE_LAZY (new_val))
            {
            {
              /* We need to catch errors because if
              /* We need to catch errors because if
                 value_fetch_lazy fails we still want to continue
                 value_fetch_lazy fails we still want to continue
                 (after making val->error = 1) */
                 (after making val->error = 1) */
              /* FIXME: Shouldn't be using VALUE_CONTENTS?  The
              /* FIXME: Shouldn't be using VALUE_CONTENTS?  The
                 comment on value_fetch_lazy() says it is only
                 comment on value_fetch_lazy() says it is only
                 called from the macro... */
                 called from the macro... */
              if (!gdb_value_fetch_lazy (new_val))
              if (!gdb_value_fetch_lazy (new_val))
                var->error = 1;
                var->error = 1;
              else
              else
                var->error = 0;
                var->error = 0;
            }
            }
        }
        }
      else
      else
        var->error = 1;
        var->error = 1;
 
 
      release_value (new_val);
      release_value (new_val);
      return new_val;
      return new_val;
    }
    }
 
 
  return NULL;
  return NULL;
}
}
 
 
static value_ptr
static value_ptr
c_value_of_child (parent, index)
c_value_of_child (parent, index)
     struct varobj *parent;
     struct varobj *parent;
     int index;
     int index;
{
{
  value_ptr value, temp, indval;
  value_ptr value, temp, indval;
  struct type *type, *target;
  struct type *type, *target;
  char *name;
  char *name;
 
 
  type = get_type (parent);
  type = get_type (parent);
  target = get_target_type (type);
  target = get_target_type (type);
  name = name_of_child (parent, index);
  name = name_of_child (parent, index);
  temp = parent->value;
  temp = parent->value;
  value = NULL;
  value = NULL;
 
 
  if (temp != NULL)
  if (temp != NULL)
    {
    {
      switch (TYPE_CODE (type))
      switch (TYPE_CODE (type))
        {
        {
        case TYPE_CODE_ARRAY:
        case TYPE_CODE_ARRAY:
#if 0
#if 0
          /* This breaks if the array lives in a (vector) register. */
          /* This breaks if the array lives in a (vector) register. */
          value = value_slice (temp, index, 1);
          value = value_slice (temp, index, 1);
          temp = value_coerce_array (value);
          temp = value_coerce_array (value);
          gdb_value_ind (temp, &value);
          gdb_value_ind (temp, &value);
#else
#else
          indval = value_from_longest (builtin_type_int, (LONGEST) index);
          indval = value_from_longest (builtin_type_int, (LONGEST) index);
          gdb_value_subscript (temp, indval, &value);
          gdb_value_subscript (temp, indval, &value);
#endif
#endif
          break;
          break;
 
 
        case TYPE_CODE_STRUCT:
        case TYPE_CODE_STRUCT:
        case TYPE_CODE_UNION:
        case TYPE_CODE_UNION:
          value = value_struct_elt (&temp, NULL, name, NULL, "vstructure");
          value = value_struct_elt (&temp, NULL, name, NULL, "vstructure");
          break;
          break;
 
 
        case TYPE_CODE_PTR:
        case TYPE_CODE_PTR:
          switch (TYPE_CODE (target))
          switch (TYPE_CODE (target))
            {
            {
            case TYPE_CODE_STRUCT:
            case TYPE_CODE_STRUCT:
            case TYPE_CODE_UNION:
            case TYPE_CODE_UNION:
              value = value_struct_elt (&temp, NULL, name, NULL, "vstructure");
              value = value_struct_elt (&temp, NULL, name, NULL, "vstructure");
              break;
              break;
 
 
            default:
            default:
              gdb_value_ind (temp, &value);
              gdb_value_ind (temp, &value);
              break;
              break;
            }
            }
          break;
          break;
 
 
        default:
        default:
          break;
          break;
        }
        }
    }
    }
 
 
  if (value != NULL)
  if (value != NULL)
    release_value (value);
    release_value (value);
 
 
  return value;
  return value;
}
}
 
 
static struct type *
static struct type *
c_type_of_child (parent, index)
c_type_of_child (parent, index)
     struct varobj *parent;
     struct varobj *parent;
     int index;
     int index;
{
{
  struct type *type;
  struct type *type;
  char *name = name_of_child (parent, index);
  char *name = name_of_child (parent, index);
 
 
  switch (TYPE_CODE (parent->type))
  switch (TYPE_CODE (parent->type))
    {
    {
    case TYPE_CODE_ARRAY:
    case TYPE_CODE_ARRAY:
      type = TYPE_TARGET_TYPE (parent->type);
      type = TYPE_TARGET_TYPE (parent->type);
      break;
      break;
 
 
    case TYPE_CODE_STRUCT:
    case TYPE_CODE_STRUCT:
    case TYPE_CODE_UNION:
    case TYPE_CODE_UNION:
      type = lookup_struct_elt_type (parent->type, name, 0);
      type = lookup_struct_elt_type (parent->type, name, 0);
      break;
      break;
 
 
    case TYPE_CODE_PTR:
    case TYPE_CODE_PTR:
      switch (TYPE_CODE (TYPE_TARGET_TYPE (parent->type)))
      switch (TYPE_CODE (TYPE_TARGET_TYPE (parent->type)))
        {
        {
        case TYPE_CODE_STRUCT:
        case TYPE_CODE_STRUCT:
        case TYPE_CODE_UNION:
        case TYPE_CODE_UNION:
          type = lookup_struct_elt_type (parent->type, name, 0);
          type = lookup_struct_elt_type (parent->type, name, 0);
          break;
          break;
 
 
        default:
        default:
          type = TYPE_TARGET_TYPE (parent->type);
          type = TYPE_TARGET_TYPE (parent->type);
          break;
          break;
        }
        }
      break;
      break;
 
 
    default:
    default:
      /* This should not happen as only the above types have children */
      /* This should not happen as only the above types have children */
      warning ("Child of parent whose type does not allow children");
      warning ("Child of parent whose type does not allow children");
      /* FIXME: Can we still go on? */
      /* FIXME: Can we still go on? */
      type = NULL;
      type = NULL;
      break;
      break;
    }
    }
 
 
  return type;
  return type;
}
}
 
 
static int
static int
c_variable_editable (var)
c_variable_editable (var)
     struct varobj *var;
     struct varobj *var;
{
{
  switch (TYPE_CODE (get_type (var)))
  switch (TYPE_CODE (get_type (var)))
    {
    {
    case TYPE_CODE_STRUCT:
    case TYPE_CODE_STRUCT:
    case TYPE_CODE_UNION:
    case TYPE_CODE_UNION:
    case TYPE_CODE_ARRAY:
    case TYPE_CODE_ARRAY:
    case TYPE_CODE_FUNC:
    case TYPE_CODE_FUNC:
    case TYPE_CODE_MEMBER:
    case TYPE_CODE_MEMBER:
    case TYPE_CODE_METHOD:
    case TYPE_CODE_METHOD:
      return 0;
      return 0;
      break;
      break;
 
 
    default:
    default:
      return 1;
      return 1;
      break;
      break;
    }
    }
}
}
 
 
static char *
static char *
c_value_of_variable (var)
c_value_of_variable (var)
     struct varobj *var;
     struct varobj *var;
{
{
  struct type *type;
  struct type *type;
  value_ptr val;
  value_ptr val;
 
 
  if (var->value != NULL)
  if (var->value != NULL)
    val = var->value;
    val = var->value;
  else
  else
    {
    {
      /* This can happen if we attempt to get the value of a struct
      /* This can happen if we attempt to get the value of a struct
         member when the parent is an invalid pointer. */
         member when the parent is an invalid pointer. */
      return xstrdup ("???");
      return xstrdup ("???");
    }
    }
 
 
  /* BOGUS: if val_print sees a struct/class, it will print out its
  /* BOGUS: if val_print sees a struct/class, it will print out its
     children instead of "{...}" */
     children instead of "{...}" */
  type = get_type (var);
  type = get_type (var);
  switch (TYPE_CODE (type))
  switch (TYPE_CODE (type))
    {
    {
    case TYPE_CODE_STRUCT:
    case TYPE_CODE_STRUCT:
    case TYPE_CODE_UNION:
    case TYPE_CODE_UNION:
      return xstrdup ("{...}");
      return xstrdup ("{...}");
      /* break; */
      /* break; */
 
 
    case TYPE_CODE_ARRAY:
    case TYPE_CODE_ARRAY:
      {
      {
        char number[18];
        char number[18];
        sprintf (number, "[%d]", var->num_children);
        sprintf (number, "[%d]", var->num_children);
        return xstrdup (number);
        return xstrdup (number);
      }
      }
      /* break; */
      /* break; */
 
 
    default:
    default:
      {
      {
        long dummy;
        long dummy;
        struct ui_file *stb = mem_fileopen ();
        struct ui_file *stb = mem_fileopen ();
        struct cleanup *old_chain = make_cleanup_ui_file_delete (stb);
        struct cleanup *old_chain = make_cleanup_ui_file_delete (stb);
        char *thevalue;
        char *thevalue;
 
 
        if (VALUE_LAZY (val))
        if (VALUE_LAZY (val))
          gdb_value_fetch_lazy (val);
          gdb_value_fetch_lazy (val);
        val_print (VALUE_TYPE (val), VALUE_CONTENTS_RAW (val), 0,
        val_print (VALUE_TYPE (val), VALUE_CONTENTS_RAW (val), 0,
                   VALUE_ADDRESS (val),
                   VALUE_ADDRESS (val),
                   stb, format_code[(int) var->format], 1, 0, 0);
                   stb, format_code[(int) var->format], 1, 0, 0);
        thevalue = ui_file_xstrdup (stb, &dummy);
        thevalue = ui_file_xstrdup (stb, &dummy);
        do_cleanups (old_chain);
        do_cleanups (old_chain);
        return thevalue;
        return thevalue;
      }
      }
      /* break; */
      /* break; */
    }
    }
}
}


 
 
/* C++ */
/* C++ */
 
 
static int
static int
cplus_number_of_children (var)
cplus_number_of_children (var)
     struct varobj *var;
     struct varobj *var;
{
{
  struct type *type;
  struct type *type;
  int children, dont_know;
  int children, dont_know;
 
 
  dont_know = 1;
  dont_know = 1;
  children = 0;
  children = 0;
 
 
  if (!CPLUS_FAKE_CHILD (var))
  if (!CPLUS_FAKE_CHILD (var))
    {
    {
      type = get_type_deref (var);
      type = get_type_deref (var);
 
 
      if (((TYPE_CODE (type)) == TYPE_CODE_STRUCT) ||
      if (((TYPE_CODE (type)) == TYPE_CODE_STRUCT) ||
          ((TYPE_CODE (type)) == TYPE_CODE_UNION))
          ((TYPE_CODE (type)) == TYPE_CODE_UNION))
        {
        {
          int kids[3];
          int kids[3];
 
 
          cplus_class_num_children (type, kids);
          cplus_class_num_children (type, kids);
          if (kids[v_public] != 0)
          if (kids[v_public] != 0)
            children++;
            children++;
          if (kids[v_private] != 0)
          if (kids[v_private] != 0)
            children++;
            children++;
          if (kids[v_protected] != 0)
          if (kids[v_protected] != 0)
            children++;
            children++;
 
 
          /* Add any baseclasses */
          /* Add any baseclasses */
          children += TYPE_N_BASECLASSES (type);
          children += TYPE_N_BASECLASSES (type);
          dont_know = 0;
          dont_know = 0;
 
 
          /* FIXME: save children in var */
          /* FIXME: save children in var */
        }
        }
    }
    }
  else
  else
    {
    {
      int kids[3];
      int kids[3];
 
 
      type = get_type_deref (var->parent);
      type = get_type_deref (var->parent);
 
 
      cplus_class_num_children (type, kids);
      cplus_class_num_children (type, kids);
      if (STREQ (var->name, "public"))
      if (STREQ (var->name, "public"))
        children = kids[v_public];
        children = kids[v_public];
      else if (STREQ (var->name, "private"))
      else if (STREQ (var->name, "private"))
        children = kids[v_private];
        children = kids[v_private];
      else
      else
        children = kids[v_protected];
        children = kids[v_protected];
      dont_know = 0;
      dont_know = 0;
    }
    }
 
 
  if (dont_know)
  if (dont_know)
    children = c_number_of_children (var);
    children = c_number_of_children (var);
 
 
  return children;
  return children;
}
}
 
 
/* Compute # of public, private, and protected variables in this class.
/* Compute # of public, private, and protected variables in this class.
   That means we need to descend into all baseclasses and find out
   That means we need to descend into all baseclasses and find out
   how many are there, too. */
   how many are there, too. */
static void
static void
cplus_class_num_children (type, children)
cplus_class_num_children (type, children)
     struct type *type;
     struct type *type;
     int children[3];
     int children[3];
{
{
  int i;
  int i;
 
 
  children[v_public] = 0;
  children[v_public] = 0;
  children[v_private] = 0;
  children[v_private] = 0;
  children[v_protected] = 0;
  children[v_protected] = 0;
 
 
  for (i = TYPE_N_BASECLASSES (type); i < TYPE_NFIELDS (type); i++)
  for (i = TYPE_N_BASECLASSES (type); i < TYPE_NFIELDS (type); i++)
    {
    {
      /* If we have a virtual table pointer, omit it. */
      /* If we have a virtual table pointer, omit it. */
      if (TYPE_VPTR_BASETYPE (type) == type
      if (TYPE_VPTR_BASETYPE (type) == type
          && TYPE_VPTR_FIELDNO (type) == i)
          && TYPE_VPTR_FIELDNO (type) == i)
        continue;
        continue;
 
 
      if (TYPE_FIELD_PROTECTED (type, i))
      if (TYPE_FIELD_PROTECTED (type, i))
        children[v_protected]++;
        children[v_protected]++;
      else if (TYPE_FIELD_PRIVATE (type, i))
      else if (TYPE_FIELD_PRIVATE (type, i))
        children[v_private]++;
        children[v_private]++;
      else
      else
        children[v_public]++;
        children[v_public]++;
    }
    }
}
}
 
 
static char *
static char *
cplus_name_of_variable (parent)
cplus_name_of_variable (parent)
     struct varobj *parent;
     struct varobj *parent;
{
{
  return c_name_of_variable (parent);
  return c_name_of_variable (parent);
}
}
 
 
static char *
static char *
cplus_name_of_child (parent, index)
cplus_name_of_child (parent, index)
     struct varobj *parent;
     struct varobj *parent;
     int index;
     int index;
{
{
  char *name;
  char *name;
  struct type *type;
  struct type *type;
  int children[3];
  int children[3];
 
 
  if (CPLUS_FAKE_CHILD (parent))
  if (CPLUS_FAKE_CHILD (parent))
    {
    {
      /* Looking for children of public, private, or protected. */
      /* Looking for children of public, private, or protected. */
      type = get_type_deref (parent->parent);
      type = get_type_deref (parent->parent);
    }
    }
  else
  else
    type = get_type_deref (parent);
    type = get_type_deref (parent);
 
 
  name = NULL;
  name = NULL;
  switch (TYPE_CODE (type))
  switch (TYPE_CODE (type))
    {
    {
    case TYPE_CODE_STRUCT:
    case TYPE_CODE_STRUCT:
    case TYPE_CODE_UNION:
    case TYPE_CODE_UNION:
      cplus_class_num_children (type, children);
      cplus_class_num_children (type, children);
 
 
      if (CPLUS_FAKE_CHILD (parent))
      if (CPLUS_FAKE_CHILD (parent))
        {
        {
          /* FIXME: This assumes that type orders
          /* FIXME: This assumes that type orders
             inherited, public, private, protected */
             inherited, public, private, protected */
          int i = index + TYPE_N_BASECLASSES (type);
          int i = index + TYPE_N_BASECLASSES (type);
          if (STREQ (parent->name, "private") || STREQ (parent->name, "protected"))
          if (STREQ (parent->name, "private") || STREQ (parent->name, "protected"))
            i += children[v_public];
            i += children[v_public];
          if (STREQ (parent->name, "protected"))
          if (STREQ (parent->name, "protected"))
            i += children[v_private];
            i += children[v_private];
 
 
          name = TYPE_FIELD_NAME (type, i);
          name = TYPE_FIELD_NAME (type, i);
        }
        }
      else if (index < TYPE_N_BASECLASSES (type))
      else if (index < TYPE_N_BASECLASSES (type))
        name = TYPE_FIELD_NAME (type, index);
        name = TYPE_FIELD_NAME (type, index);
      else
      else
        {
        {
          /* Everything beyond the baseclasses can
          /* Everything beyond the baseclasses can
             only be "public", "private", or "protected" */
             only be "public", "private", or "protected" */
          index -= TYPE_N_BASECLASSES (type);
          index -= TYPE_N_BASECLASSES (type);
          switch (index)
          switch (index)
            {
            {
            case 0:
            case 0:
              if (children[v_public] != 0)
              if (children[v_public] != 0)
                {
                {
                  name = "public";
                  name = "public";
                  break;
                  break;
                }
                }
            case 1:
            case 1:
              if (children[v_private] != 0)
              if (children[v_private] != 0)
                {
                {
                  name = "private";
                  name = "private";
                  break;
                  break;
                }
                }
            case 2:
            case 2:
              if (children[v_protected] != 0)
              if (children[v_protected] != 0)
                {
                {
                  name = "protected";
                  name = "protected";
                  break;
                  break;
                }
                }
            default:
            default:
              /* error! */
              /* error! */
              break;
              break;
            }
            }
        }
        }
      break;
      break;
 
 
    default:
    default:
      break;
      break;
    }
    }
 
 
  if (name == NULL)
  if (name == NULL)
    return c_name_of_child (parent, index);
    return c_name_of_child (parent, index);
  else
  else
    {
    {
      if (name != NULL)
      if (name != NULL)
        name = savestring (name, strlen (name));
        name = savestring (name, strlen (name));
    }
    }
 
 
  return name;
  return name;
}
}
 
 
static value_ptr
static value_ptr
cplus_value_of_root (var_handle)
cplus_value_of_root (var_handle)
     struct varobj **var_handle;
     struct varobj **var_handle;
{
{
  return c_value_of_root (var_handle);
  return c_value_of_root (var_handle);
}
}
 
 
static value_ptr
static value_ptr
cplus_value_of_child (parent, index)
cplus_value_of_child (parent, index)
     struct varobj *parent;
     struct varobj *parent;
     int index;
     int index;
{
{
  struct type *type;
  struct type *type;
  value_ptr value;
  value_ptr value;
  char *name;
  char *name;
 
 
  if (CPLUS_FAKE_CHILD (parent))
  if (CPLUS_FAKE_CHILD (parent))
    type = get_type_deref (parent->parent);
    type = get_type_deref (parent->parent);
  else
  else
    type = get_type_deref (parent);
    type = get_type_deref (parent);
 
 
  value = NULL;
  value = NULL;
  name = name_of_child (parent, index);
  name = name_of_child (parent, index);
 
 
  if (((TYPE_CODE (type)) == TYPE_CODE_STRUCT) ||
  if (((TYPE_CODE (type)) == TYPE_CODE_STRUCT) ||
      ((TYPE_CODE (type)) == TYPE_CODE_UNION))
      ((TYPE_CODE (type)) == TYPE_CODE_UNION))
    {
    {
      if (CPLUS_FAKE_CHILD (parent))
      if (CPLUS_FAKE_CHILD (parent))
        {
        {
          value_ptr temp = parent->parent->value;
          value_ptr temp = parent->parent->value;
          value = value_struct_elt (&temp, NULL, name,
          value = value_struct_elt (&temp, NULL, name,
                                    NULL, "cplus_structure");
                                    NULL, "cplus_structure");
          release_value (value);
          release_value (value);
        }
        }
      else if (index >= TYPE_N_BASECLASSES (type))
      else if (index >= TYPE_N_BASECLASSES (type))
        {
        {
          /* public, private, or protected */
          /* public, private, or protected */
          return NULL;
          return NULL;
        }
        }
      else
      else
        {
        {
          /* Baseclass */
          /* Baseclass */
          if (parent->value != NULL)
          if (parent->value != NULL)
            {
            {
              value_ptr temp;
              value_ptr temp;
 
 
              if (TYPE_CODE (VALUE_TYPE (parent->value)) == TYPE_CODE_PTR
              if (TYPE_CODE (VALUE_TYPE (parent->value)) == TYPE_CODE_PTR
                  || TYPE_CODE (VALUE_TYPE (parent->value)) == TYPE_CODE_REF)
                  || TYPE_CODE (VALUE_TYPE (parent->value)) == TYPE_CODE_REF)
                gdb_value_ind (parent->value, &temp);
                gdb_value_ind (parent->value, &temp);
              else
              else
                temp = parent->value;
                temp = parent->value;
 
 
              value = value_cast (TYPE_FIELD_TYPE (type, index), temp);
              value = value_cast (TYPE_FIELD_TYPE (type, index), temp);
              release_value (value);
              release_value (value);
            }
            }
        }
        }
    }
    }
 
 
  if (value == NULL)
  if (value == NULL)
    return c_value_of_child (parent, index);
    return c_value_of_child (parent, index);
 
 
  return value;
  return value;
}
}
 
 
static struct type *
static struct type *
cplus_type_of_child (parent, index)
cplus_type_of_child (parent, index)
     struct varobj *parent;
     struct varobj *parent;
     int index;
     int index;
{
{
  struct type *type, *t;
  struct type *type, *t;
 
 
  t = get_type_deref (parent);
  t = get_type_deref (parent);
  type = NULL;
  type = NULL;
  switch (TYPE_CODE (t))
  switch (TYPE_CODE (t))
    {
    {
    case TYPE_CODE_STRUCT:
    case TYPE_CODE_STRUCT:
    case TYPE_CODE_UNION:
    case TYPE_CODE_UNION:
      if (index >= TYPE_N_BASECLASSES (t))
      if (index >= TYPE_N_BASECLASSES (t))
        {
        {
          /* special */
          /* special */
          return NULL;
          return NULL;
        }
        }
      else
      else
        {
        {
          /* Baseclass */
          /* Baseclass */
          type = TYPE_FIELD_TYPE (t, index);
          type = TYPE_FIELD_TYPE (t, index);
        }
        }
      break;
      break;
 
 
    default:
    default:
      break;
      break;
    }
    }
 
 
  if (type == NULL)
  if (type == NULL)
    return c_type_of_child (parent, index);
    return c_type_of_child (parent, index);
 
 
  return type;
  return type;
}
}
 
 
static int
static int
cplus_variable_editable (var)
cplus_variable_editable (var)
     struct varobj *var;
     struct varobj *var;
{
{
  if (CPLUS_FAKE_CHILD (var))
  if (CPLUS_FAKE_CHILD (var))
    return 0;
    return 0;
 
 
  return c_variable_editable (var);
  return c_variable_editable (var);
}
}
 
 
static char *
static char *
cplus_value_of_variable (var)
cplus_value_of_variable (var)
     struct varobj *var;
     struct varobj *var;
{
{
 
 
  /* If we have one of our special types, don't print out
  /* If we have one of our special types, don't print out
     any value. */
     any value. */
  if (CPLUS_FAKE_CHILD (var))
  if (CPLUS_FAKE_CHILD (var))
    return xstrdup ("");
    return xstrdup ("");
 
 
  return c_value_of_variable (var);
  return c_value_of_variable (var);
}
}


/* Java */
/* Java */
 
 
static int
static int
java_number_of_children (var)
java_number_of_children (var)
     struct varobj *var;
     struct varobj *var;
{
{
  return cplus_number_of_children (var);
  return cplus_number_of_children (var);
}
}
 
 
static char *
static char *
java_name_of_variable (parent)
java_name_of_variable (parent)
     struct varobj *parent;
     struct varobj *parent;
{
{
  char *p, *name;
  char *p, *name;
 
 
  name = cplus_name_of_variable (parent);
  name = cplus_name_of_variable (parent);
  /* If  the name has "-" in it, it is because we
  /* If  the name has "-" in it, it is because we
     needed to escape periods in the name... */
     needed to escape periods in the name... */
  p = name;
  p = name;
 
 
  while (*p != '\000')
  while (*p != '\000')
    {
    {
      if (*p == '-')
      if (*p == '-')
        *p = '.';
        *p = '.';
      p++;
      p++;
    }
    }
 
 
  return name;
  return name;
}
}
 
 
static char *
static char *
java_name_of_child (parent, index)
java_name_of_child (parent, index)
     struct varobj *parent;
     struct varobj *parent;
     int index;
     int index;
{
{
  char *name, *p;
  char *name, *p;
 
 
  name = cplus_name_of_child (parent, index);
  name = cplus_name_of_child (parent, index);
  /* Escape any periods in the name... */
  /* Escape any periods in the name... */
  p = name;
  p = name;
 
 
  while (*p != '\000')
  while (*p != '\000')
    {
    {
      if (*p == '.')
      if (*p == '.')
        *p = '-';
        *p = '-';
      p++;
      p++;
    }
    }
 
 
  return name;
  return name;
}
}
 
 
static value_ptr
static value_ptr
java_value_of_root (var_handle)
java_value_of_root (var_handle)
     struct varobj **var_handle;
     struct varobj **var_handle;
{
{
  return cplus_value_of_root (var_handle);
  return cplus_value_of_root (var_handle);
}
}
 
 
static value_ptr
static value_ptr
java_value_of_child (parent, index)
java_value_of_child (parent, index)
     struct varobj *parent;
     struct varobj *parent;
     int index;
     int index;
{
{
  return cplus_value_of_child (parent, index);
  return cplus_value_of_child (parent, index);
}
}
 
 
static struct type *
static struct type *
java_type_of_child (parent, index)
java_type_of_child (parent, index)
     struct varobj *parent;
     struct varobj *parent;
     int index;
     int index;
{
{
  return cplus_type_of_child (parent, index);
  return cplus_type_of_child (parent, index);
}
}
 
 
static int
static int
java_variable_editable (var)
java_variable_editable (var)
     struct varobj *var;
     struct varobj *var;
{
{
  return cplus_variable_editable (var);
  return cplus_variable_editable (var);
}
}
 
 
static char *
static char *
java_value_of_variable (var)
java_value_of_variable (var)
     struct varobj *var;
     struct varobj *var;
{
{
  return cplus_value_of_variable (var);
  return cplus_value_of_variable (var);
}
}


extern void _initialize_varobj (void);
extern void _initialize_varobj (void);
void
void
_initialize_varobj (void)
_initialize_varobj (void)
{
{
  int sizeof_table = sizeof (struct vlist *) * VAROBJ_TABLE_SIZE;
  int sizeof_table = sizeof (struct vlist *) * VAROBJ_TABLE_SIZE;
 
 
  varobj_table = xmalloc (sizeof_table);
  varobj_table = xmalloc (sizeof_table);
  memset (varobj_table, 0, sizeof_table);
  memset (varobj_table, 0, sizeof_table);
 
 
  add_show_from_set (
  add_show_from_set (
                add_set_cmd ("debugvarobj", class_maintenance, var_zinteger,
                add_set_cmd ("debugvarobj", class_maintenance, var_zinteger,
                             (char *) &varobjdebug,
                             (char *) &varobjdebug,
                             "Set varobj debugging.\n\
                             "Set varobj debugging.\n\
When non-zero, varobj debugging is enabled.", &setlist),
When non-zero, varobj debugging is enabled.", &setlist),
                      &showlist);
                      &showlist);
}
}
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.