1 # Copyright 2012-2024 Free Software Foundation, Inc.
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.
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.
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/>.
18 require allow_ada_tests
20 standard_ada_testfile foo
22 foreach_gnat_encoding scenario flags {all minimal} {
25 if {[gdb_compile_ada "${srcfile}" "${binfile}-${scenario}" executable $flags] != ""} {
29 clean_restart ${testfile}-${scenario}
31 set bp_location [gdb_get_line_number "STOP1" ${testdir}/foo.adb]
32 runto "foo.adb:$bp_location"
34 # Print My_Object and My_Object.Ptr when Ptr is null...
36 gdb_test "print my_object" \
37 "= \\(n => 3, ptr => 0x0, data => \\(3, 5, 8\\)\\)" \
38 "print My_Object with null Ptr"
40 gdb_test "print my_object.ptr" \
41 "= \\(foo.table_access\\) 0x0" \
42 "print My_Object.Ptr when null"
44 # Same for My_P_Object...
46 gdb_test "print my_p_object" \
47 "= \\(n => 3, ptr => 0x0, data => \\(3, 5, 8\\)\\)" \
48 "print My_P_Object with null Ptr"
50 gdb_test "print my_p_object.ptr" \
51 "\\(foo.p_table_access\\) 0x0" \
52 "print My_P_Object.Ptr when null"
54 # Continue until the Ptr component of both objects get allocated.
56 set bp_location [gdb_get_line_number "STOP2" ${testdir}/foo.adb]
58 gdb_breakpoint "foo.adb:$bp_location"
61 "Breakpoint $decimal, foo \\(\\) at .*foo.adb:$decimal.*" \
64 # Inspect My_Object again...
66 gdb_test "print my_object" \
67 "= \\(n => 3, ptr => $hex, data => \\(3, 5, 8\\)\\)" \
68 "print my_object after setting Ptr"
70 gdb_test "print my_object.ptr" \
71 "\\(foo.table_access\\) $hex" \
72 "print my_object.ptr when no longer null"
74 gdb_test "print my_object.ptr.all" \
77 # Same with My_P_Object...
79 gdb_test "print my_p_object" \
80 "= \\(n => 3, ptr => $hex, data => \\(3, 5, 8\\)\\)" \
81 "print my_p_object after setting Ptr"
83 gdb_test "print my_p_object.ptr" \
84 "= \\(foo.p_table_access\\) $hex" \
85 "print My_P_Object.Ptr when no longer null"
87 gdb_test "print my_p_object.ptr.all" \