Simplify tui_gen_win_info::make_visible
[deliverable/binutils-gdb.git] / gdb / c-varobj.c
index e3b097b227578d208f6a5098a147a01f39281662..21db8cdde980d5d529c1d19312d8a28a00977e64 100644 (file)
@@ -1,6 +1,6 @@
 /* varobj support for C and C++.
 
-   Copyright (C) 1999-2017 Free Software Foundation, Inc.
+   Copyright (C) 1999-2019 Free Software Foundation, Inc.
 
    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
@@ -34,7 +34,7 @@ static void cplus_class_num_children (struct type *type, int children[3]);
    This has already been determined by *_describe_child. The easiest
    thing to do is to compare the child's name with ANONYMOUS_*_NAME.  */
 
-int
+bool
 varobj_is_anonymous_child (const struct varobj *child)
 {
   return (child->name == ANONYMOUS_STRUCT_NAME
@@ -92,16 +92,15 @@ adjust_value_for_child_access (struct value **value,
          if (value && *value)
            {
 
-             TRY
+             try
                {
                  *value = value_ind (*value);
                }
 
-             CATCH (except, RETURN_MASK_ERROR)
+             catch (const gdb_exception_error &except)
                {
                  *value = NULL;
                }
-             END_CATCH
            }
          *type = target_type;
          if (was_ptr)
@@ -131,22 +130,21 @@ adjust_value_for_child_access (struct value **value,
 /* Is VAR a path expression parent, i.e., can it be used to construct
    a valid path expression?  */
 
-static int
+static bool
 c_is_path_expr_parent (const struct varobj *var)
 {
   struct type *type;
 
   /* "Fake" children are not path_expr parents.  */
   if (CPLUS_FAKE_CHILD (var))
-    return 0;
+    return false;
 
   type = varobj_get_gdb_type (var);
 
   /* Anonymous unions and structs are also not path_expr parents.  */
   if ((TYPE_CODE (type) == TYPE_CODE_STRUCT
        || TYPE_CODE (type) == TYPE_CODE_UNION)
-      && TYPE_NAME (type) == NULL
-      && TYPE_TAG_NAME (type) == NULL)
+      && TYPE_NAME (type) == NULL)
     {
       const struct varobj *parent = var->parent;
 
@@ -172,10 +170,10 @@ c_is_path_expr_parent (const struct varobj *var)
            }
        }
 
-      return 0;
+      return false;
     }
 
-  return 1;
+  return true;
 }
 
 /* C */
@@ -254,18 +252,17 @@ value_struct_element_index (struct value *value, int type_index)
   gdb_assert (TYPE_CODE (type) == TYPE_CODE_STRUCT
              || TYPE_CODE (type) == TYPE_CODE_UNION);
 
-  TRY
+  try
     {
       if (field_is_static (&TYPE_FIELD (type, type_index)))
        result = value_static_field (type, type_index);
       else
        result = value_primitive_field (value, 0, type_index, type);
     }
-  CATCH (e, RETURN_MASK_ERROR)
+  catch (const gdb_exception_error &e)
     {
       return NULL;
     }
-  END_CATCH
 
   return result;
 }
@@ -286,7 +283,7 @@ c_describe_child (const struct varobj *parent, int index,
                  std::string *cname, struct value **cvalue,
                  struct type **ctype, std::string *cfull_expression)
 {
-  struct value *value = parent->value;
+  struct value *value = parent->value.get ();
   struct type *type = varobj_get_value_type (parent);
   std::string parent_expression;
   int was_ptr;
@@ -317,14 +314,13 @@ c_describe_child (const struct varobj *parent, int index,
        {
          int real_index = index + TYPE_LOW_BOUND (TYPE_INDEX_TYPE (type));
 
-         TRY
+         try
            {
              *cvalue = value_subscript (value, real_index);
            }
-         CATCH (except, RETURN_MASK_ERROR)
+         catch (const gdb_exception_error &except)
            {
            }
-         END_CATCH
        }
 
       if (ctype)
@@ -394,16 +390,15 @@ c_describe_child (const struct varobj *parent, int index,
 
       if (cvalue && value)
        {
-         TRY
+         try
            {
              *cvalue = value_ind (value);
            }
 
-         CATCH (except, RETURN_MASK_ERROR)
+         catch (const gdb_exception_error &except)
            {
              *cvalue = NULL;
            }
-         END_CATCH
        }
 
       /* Don't use get_target_type because it calls
@@ -513,21 +508,22 @@ c_value_of_variable (const struct varobj *var,
          }
        else
          {
-           if (var->not_fetched && value_lazy (var->value))
+           if (var->not_fetched && value_lazy (var->value.get ()))
              /* Frozen variable and no value yet.  We don't
                 implicitly fetch the value.  MI response will
                 use empty string for the value, which is OK.  */
              return std::string ();
 
            gdb_assert (varobj_value_is_changeable_p (var));
-           gdb_assert (!value_lazy (var->value));
+           gdb_assert (!value_lazy (var->value.get ()));
            
            /* If the specified format is the current one,
               we can reuse print_value.  */
            if (format == var->format)
              return var->print_value;
            else
-             return varobj_value_get_print_value (var->value, format, var);
+             return varobj_value_get_print_value (var->value.get (), format,
+                                                  var);
          }
       }
     }
@@ -579,7 +575,7 @@ cplus_number_of_children (const struct varobj *var)
       /* It is necessary to access a real type (via RTTI).  */
       if (opts.objectprint)
         {
-          value = var->value;
+          value = var->value.get ();
           lookup_actual_type = (TYPE_IS_REFERENCE (var->type)
                                || TYPE_CODE (var->type) == TYPE_CODE_PTR);
         }
@@ -616,7 +612,7 @@ cplus_number_of_children (const struct varobj *var)
         {
          const struct varobj *parent = var->parent;
 
-         value = parent->value;
+         value = parent->value.get ();
          lookup_actual_type = (TYPE_IS_REFERENCE (parent->type)
                                || TYPE_CODE (parent->type) == TYPE_CODE_PTR);
         }
@@ -724,7 +720,7 @@ cplus_describe_child (const struct varobj *parent, int index,
   if (opts.objectprint)
     lookup_actual_type = (TYPE_IS_REFERENCE (var->type)
                          || TYPE_CODE (var->type) == TYPE_CODE_PTR);
-  value = var->value;
+  value = var->value.get ();
   type = varobj_get_value_type (var);
   if (cfull_expression)
     parent_expression
This page took 0.028333 seconds and 4 git commands to generate.