SHF_GNU_RETAIN 7a and 7b tests
[binutils-gdb.git] / gdb / ada-varobj.c
index d28beffc9619ad0c4a089a838d891725f3a607f0..39dc9488d5c7480ce39bffaaa4e136b2ef905455 100644 (file)
@@ -63,10 +63,10 @@ static void
 ada_varobj_decode_var (struct value **value_ptr, struct type **type_ptr)
 {
   if (*value_ptr)
-    {
-      *value_ptr = ada_get_decoded_value (*value_ptr);
-      *type_ptr = ada_check_typedef (value_type (*value_ptr));
-    }
+    *value_ptr = ada_get_decoded_value (*value_ptr);
+
+  if (*value_ptr != nullptr)
+    *type_ptr = ada_check_typedef (value_type (*value_ptr));
   else
     *type_ptr = ada_get_decoded_type (*type_ptr);
 }
@@ -105,7 +105,7 @@ ada_varobj_struct_elt (struct value *parent_value,
       type = value_type (value);
     }
   else
-    type = TYPE_FIELD_TYPE (parent_type, fieldno);
+    type = parent_type->field (fieldno).type ();
 
   if (child_value)
     *child_value = value;
@@ -208,7 +208,9 @@ ada_varobj_adjust_for_child_access (struct value **value,
       the (value, type) couple.  */
   if ((*type)->code () == TYPE_CODE_PTR
       && (TYPE_TARGET_TYPE (*type)->code () == TYPE_CODE_STRUCT
-          || TYPE_TARGET_TYPE (*type)->code () == TYPE_CODE_UNION)
+         || TYPE_TARGET_TYPE (*type)->code () == TYPE_CODE_UNION)
+      && *value != nullptr
+      && value_as_address (*value) != 0
       && !ada_is_array_descriptor_type (TYPE_TARGET_TYPE (*type))
       && !ada_is_constrained_packed_array_type (TYPE_TARGET_TYPE (*type)))
     ada_varobj_ind (*value, *type, value, type);
@@ -333,6 +335,10 @@ ada_varobj_get_ptr_number_of_children (struct value *parent_value,
       || child_type->code () == TYPE_CODE_VOID)
     return 0;
 
+  /* Only show children for non-null pointers.  */
+  if (parent_value == nullptr || value_as_address (parent_value) == 0)
+    return 0;
+
   /* All other types have 1 child.  */
   return 1;
 }