1# Copyright 2020 Free Software Foundation, Inc.
2#
3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by
5# the Free Software Foundation; either version 3 of the License, or
6# (at your option) any later version.
7#
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11# GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License
14# along with this program.  If not, see <http://www.gnu.org/licenses/>.
15
16load_lib "ada.exp"
17
18if {[skip_ada_tests]} {
19    return -1
20}
21
22standard_ada_testfile mi_access
23
24load_lib mi-support.exp
25set MIFLAGS "-i=mi"
26
27if {[gdb_compile_ada "${srcfile}" "${binfile}" executable debug] != "" } {
28    return -1
29}
30
31if {[mi_gdb_start]} {
32    continue
33}
34
35mi_delete_breakpoints
36mi_gdb_reinitialize_dir $srcdir/$subdir
37mi_gdb_load ${binfile}
38
39if ![mi_run_to_main] then {
40    fail "cannot run to main, testcase aborted"
41    return 0
42}
43
44set bp_location [gdb_get_line_number "STOP" ${testdir}/mi_access.adb]
45mi_continue_to_line \
46    "mi_access.adb:$bp_location" \
47    "stop at start of mi_access"
48
49# The bug was that creating a varobj for A_String_Access would crash.
50mi_gdb_test "-var-create A_String_Access * A_String_Access" \
51    "\\^done,name=\"A_String_Access\",numchild=\"1\",.*" \
52    "Create varobj"
53
54set bp_location [gdb_get_line_number "STOP2" ${testdir}/mi_access.adb]
55mi_continue_to_line \
56    "mi_access.adb:$bp_location" \
57    "stop at stop 2"
58
59mi_gdb_test "-var-update A_String_Access" \
60    [string_to_regexp {^done,changelist=[{name="A_String_Access",in_scope="true",type_changed="false",has_more="0"}]}] \
61    "update at stop 2"
62
63mi_gdb_test "-var-list-children A_String_Access" \
64    [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"}] \
65    "list children at stop 2"
66
67set bp_location [gdb_get_line_number "STOP3" ${testdir}/mi_access.adb]
68mi_continue_to_line \
69    "mi_access.adb:$bp_location" \
70    "stop at stop 3"
71
72mi_gdb_test "-var-update A_String_Access" \
73    [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"}]}] \
74    "update at stop 3"
75