GDB/MI: Document support for -exec-run --start in -list-features
[deliverable/binutils-gdb.git] / gdb / varobj.c
index 01cf3d2a1d0a48ffcd1fc107e6b46e7ab1d370f8..b78969a89ec3657ad733913d4597ba038f0583f4 100644 (file)
@@ -26,7 +26,7 @@
 #include "valprint.h"
 
 #include "gdb_assert.h"
-#include "gdb_string.h"
+#include <string.h>
 #include "gdb_regex.h"
 
 #include "varobj.h"
@@ -55,9 +55,6 @@ show_varobjdebug (struct ui_file *file, int from_tty,
 char *varobj_format_string[] =
   { "natural", "binary", "decimal", "hexadecimal", "octal" };
 
-/* String representations of gdb's known languages.  */
-char *varobj_language_string[] = { "C", "C++", "Java" };
-
 /* True if we want to allow Python-based pretty-printing.  */
 static int pretty_printing = 0;
 
@@ -102,7 +99,7 @@ struct varobj_root
 
   /* Language-related operations for this variable and its
      children.  */
-  const struct lang_varobj_ops *lang;
+  const struct lang_varobj_ops *lang_ops;
 
   /* The varobj for this root node.  */
   struct varobj *rootvar;
@@ -199,8 +196,6 @@ static int install_new_value (struct varobj *var, struct value *value,
 
 /* Language-specific routines.  */
 
-static enum varobj_languages variable_language (struct varobj *var);
-
 static int number_of_children (struct varobj *);
 
 static char *name_of_variable (struct varobj *);
@@ -224,14 +219,6 @@ static struct varobj *varobj_add_child (struct varobj *var,
 
 #endif /* HAVE_PYTHON */
 
-/* Array of known source language routines.  */
-static const struct lang_varobj_ops *languages[vlang_end] = {
-  &c_varobj_ops,
-  &cplus_varobj_ops,
-  &java_varobj_ops,
-  &ada_varobj_ops,
-};
-
 /* Private data */
 
 /* Mappings of varobj_display_formats enums to gdb's format codes.  */
@@ -318,7 +305,6 @@ varobj_create (char *objname,
       struct frame_id old_id = null_frame_id;
       struct block *block;
       const char *p;
-      enum varobj_languages lang;
       struct value *value = NULL;
       volatile struct gdb_exception except;
       CORE_ADDR pc;
@@ -433,8 +419,7 @@ varobj_create (char *objname,
          }
 
       /* Set language info */
-      lang = variable_language (var);
-      var->root->lang = languages[lang];
+      var->root->lang_ops = var->root->exp->language_defn->la_varobj_ops;
 
       install_new_value (var, value, 1 /* Initial assignment */);
 
@@ -1061,7 +1046,7 @@ varobj_add_child (struct varobj *var, char *name, struct value *value)
 char *
 varobj_get_type (struct varobj *var)
 {
-  /* For the "fake" variables, do not return a type.  (It's type is
+  /* For the "fake" variables, do not return a type.  (Its type is
      NULL, too.)
      Do not return a type for invalid variables as well.  */
   if (CPLUS_FAKE_CHILD (var) || !var->root->is_valid)
@@ -1124,14 +1109,14 @@ varobj_get_path_expr (struct varobj *var)
         when creating varobj, so here it should be
         child varobj.  */
       gdb_assert (!is_root_p (var));
-      return (*var->root->lang->path_expr_of_child) (var);
+      return (*var->root->lang_ops->path_expr_of_child) (var);
     }
 }
 
-enum varobj_languages
+const struct language_defn *
 varobj_get_language (struct varobj *var)
 {
-  return variable_language (var);
+  return var->root->exp->language_defn;
 }
 
 int
@@ -1663,8 +1648,8 @@ varobj_value_has_mutated (struct varobj *var, struct value *new_value,
   if (var->num_children < 0)
     return 0;
 
-  if (var->root->lang->value_has_mutated)
-    return var->root->lang->value_has_mutated (var, new_value, new_type);
+  if (var->root->lang_ops->value_has_mutated)
+    return var->root->lang_ops->value_has_mutated (var, new_value, new_type);
   else
     return 0;
 }
@@ -1772,7 +1757,7 @@ varobj_update (struct varobj **varp, int explicit)
          if (new)
            new_type = value_type (new);
          else
-           new_type = v->root->lang->type_of_child (v->parent, v->index);
+           new_type = v->root->lang_ops->type_of_child (v->parent, v->index);
 
          if (varobj_value_has_mutated (v, new, new_type))
            {
@@ -2148,8 +2133,8 @@ create_child_with_value (struct varobj *parent, int index, char *name,
     child->type = value_actual_type (value, 0, NULL);
   else
     /* Otherwise, we must compute the type.  */
-    child->type = (*child->root->lang->type_of_child) (child->parent, 
-                                                      child->index);
+    child->type = (*child->root->lang_ops->type_of_child) (child->parent,
+                                                          child->index);
   install_new_value (child, value, 1);
 
   return child;
@@ -2202,7 +2187,7 @@ new_root_variable (void)
   struct varobj *var = new_variable ();
 
   var->root = (struct varobj_root *) xmalloc (sizeof (struct varobj_root));
-  var->root->lang = NULL;
+  var->root->lang_ops = NULL;
   var->root->exp = NULL;
   var->root->valid_block = NULL;
   var->root->frame = null_frame_id;
@@ -2334,32 +2319,6 @@ cppop (struct cpstack **pstack)
 
 /* Common entry points */
 
-/* Get the language of variable VAR.  */
-static enum varobj_languages
-variable_language (struct varobj *var)
-{
-  enum varobj_languages lang;
-
-  switch (var->root->exp->language_defn->la_language)
-    {
-    default:
-    case language_c:
-      lang = vlang_c;
-      break;
-    case language_cplus:
-      lang = vlang_cplus;
-      break;
-    case language_java:
-      lang = vlang_java;
-      break;
-    case language_ada:
-      lang = vlang_ada;
-      break;
-    }
-
-  return lang;
-}
-
 /* Return the number of children for a given variable.
    The result of this function is defined by the language
    implementation.  The number of children returned by this function
@@ -2368,7 +2327,7 @@ variable_language (struct varobj *var)
 static int
 number_of_children (struct varobj *var)
 {
-  return (*var->root->lang->number_of_children) (var);
+  return (*var->root->lang_ops->number_of_children) (var);
 }
 
 /* What is the expression for the root varobj VAR? Returns a malloc'd
@@ -2376,7 +2335,7 @@ number_of_children (struct varobj *var)
 static char *
 name_of_variable (struct varobj *var)
 {
-  return (*var->root->lang->name_of_variable) (var);
+  return (*var->root->lang_ops->name_of_variable) (var);
 }
 
 /* What is the name of the INDEX'th child of VAR? Returns a malloc'd
@@ -2384,7 +2343,7 @@ name_of_variable (struct varobj *var)
 static char *
 name_of_child (struct varobj *var, int index)
 {
-  return (*var->root->lang->name_of_child) (var, index);
+  return (*var->root->lang_ops->name_of_child) (var, index);
 }
 
 /* If frame associated with VAR can be found, switch
@@ -2571,7 +2530,7 @@ value_of_child (struct varobj *parent, int index)
 {
   struct value *value;
 
-  value = (*parent->root->lang->value_of_child) (parent, index);
+  value = (*parent->root->lang_ops->value_of_child) (parent, index);
 
   return value;
 }
@@ -2584,7 +2543,7 @@ my_value_of_variable (struct varobj *var, enum varobj_display_formats format)
     {
       if (var->dynamic->pretty_printer != NULL)
        return varobj_value_get_print_value (var->value, var->format, var);
-      return (*var->root->lang->value_of_variable) (var, format);
+      return (*var->root->lang_ops->value_of_variable) (var, format);
     }
   else
     return NULL;
@@ -2763,7 +2722,7 @@ varobj_editable_p (struct varobj *var)
 int
 varobj_value_is_changeable_p (struct varobj *var)
 {
-  return var->root->lang->value_is_changeable_p (var);
+  return var->root->lang_ops->value_is_changeable_p (var);
 }
 
 /* Return 1 if that varobj is floating, that is is always evaluated in the
This page took 0.027464 seconds and 4 git commands to generate.