+2020-09-02  Tom Tromey  <tromey@adacore.com>
+
+       * ada-varobj.c (ada_varobj_get_ptr_number_of_children): Return 0
+       for null pointers.
+       (ada_varobj_adjust_for_child_access): Special-case null pointers.
+
 2020-09-01  Simon Marchi  <simon.marchi@polymtl.ca>
 
        * bcache.h (struct bcache) <insert>: Change type of `added` to
 
   if ((*type)->code () == TYPE_CODE_PTR
       && (TYPE_TARGET_TYPE (*type)->code () == TYPE_CODE_STRUCT
           || 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);
       || 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;
 }
 
+2020-09-02  Tom Tromey  <tromey@adacore.com>
+
+       * gdb.ada/mi_var_access.exp: Test children of access variable.
+       * gdb.ada/mi_var_access/mi_access.adb: Add new stop markers.
+       * gdb.ada/mi_var_array.exp: Update.
+
 2020-08-31  Kevin Buettner  <kevinb@redhat.com>
 
        * gdb.base/corefile.exp (warning-free): XFAIL test when running
 
 mi_gdb_test "-var-create A_String_Access * A_String_Access" \
     "\\^done,name=\"A_String_Access\",numchild=\"1\",.*" \
     "Create varobj"
+
+set bp_location [gdb_get_line_number "STOP2" ${testdir}/mi_access.adb]
+mi_continue_to_line \
+    "mi_access.adb:$bp_location" \
+    "stop at stop 2"
+
+mi_gdb_test "-var-update A_String_Access" \
+    [string_to_regexp {^done,changelist=[{name="A_String_Access",in_scope="true",type_changed="false",has_more="0"}]}] \
+    "update at stop 2"
+
+mi_gdb_test "-var-list-children A_String_Access" \
+    [string_to_regexp {^done,numchild="1",children=[child={name="A_String_Access.A_String_Access.all",exp="A_String_Access.all",numchild="3",type="array (3 .. 5) of character",thread-id="1"}],has_more="0"}] \
+    "list children at stop 2"
+
+set bp_location [gdb_get_line_number "STOP3" ${testdir}/mi_access.adb]
+mi_continue_to_line \
+    "mi_access.adb:$bp_location" \
+    "stop at stop 3"
+
+mi_gdb_test "-var-update A_String_Access" \
+    [string_to_regexp {^done,changelist=[{name="A_String_Access",in_scope="true",type_changed="true",new_type="pck.string_access",new_num_children="0",has_more="0"}]}] \
+    "update at stop 3"
 
    A_String (4) := '6';
    A_String_Access := Copy (A_String);
    A_Pointer.P := A_String_Access;
-   Do_Nothing (A_String_Access'Address);
+   Do_Nothing (A_String_Access'Address); -- STOP2
    A_String_Access (4) := 'a';
    Do_Nothing (A_Pointer'Address);
    A_String_Access := Copy("Hi");
    Do_Nothing (A_String_Access'Address);
    A_String_Access := null;
    A_Pointer.P := null;
-   Do_Nothing (A_Pointer'Address);
+   Do_Nothing (A_Pointer'Address); -- STOP3
    Do_Nothing (A_String'Address);
 end Mi_Access;
 
        "stop at start of main Ada procedure"
 
     mi_gdb_test "-var-create vta * vta" \
-       "\\^done,name=\"vta\",numchild=\"2\",.*" \
+       "\\^done,name=\"vta\",numchild=\"0\",.*" \
        "create bt varobj"
-
-    # In the "minimal" mode, we don't currently have the ability to
-    # print the subrange type properly.  So, we just allow anything
-    # for the array range here.  The correct result would be to fix
-    # this to read "(1 .. n)".
-    mi_gdb_test "-var-list-children vta" \
-       "\\^done,numchild=\"2\",children=\\\[child={name=\"vta.n\",exp=\"n\",numchild=\"0\",type=\"bar\\.int\",thread-id=\"$decimal\"},child={name=\"vta.f\",exp=\"f\",numchild=\"0\",type=\"array .* of character\",thread-id=\"$decimal\"}\\\],.*" \
-       "list vta's children"
 }