]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.dap/ada-scopes.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.dap / ada-scopes.exp
1 # Copyright 2023-2024 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
16 load_lib ada.exp
17 load_lib dap-support.exp
18
19 require allow_ada_tests allow_dap_tests
20
21 standard_ada_testfile prog
22
23 if {[gdb_compile_ada "${srcfile}" "${binfile}" executable \
24 {debug additional_flags=-gnata}] != ""} {
25 return -1
26 }
27
28 if {[dap_launch $binfile] == ""} {
29 return
30 }
31
32 set line [gdb_get_line_number "STOP"]
33 set obj [dap_check_request_and_response "set breakpoint" \
34 setBreakpoints \
35 [format {o source [o path [%s]] \
36 breakpoints [a [o line [i %d]]]} \
37 [list s $srcfile] $line]]
38 set fn_bpno [dap_get_breakpoint_number $obj]
39
40 dap_check_request_and_response "start inferior" configurationDone
41
42 dap_wait_for_event_and_check "stopped at breakpoint" stopped \
43 "body reason" breakpoint \
44 "body hitBreakpointIds" $fn_bpno
45
46 set bt [lindex [dap_check_request_and_response "backtrace" stackTrace \
47 {o threadId [i 1]}] \
48 0]
49 set frame_id [dict get [lindex [dict get $bt body stackFrames] 0] id]
50
51 set scopes [dap_check_request_and_response "get scopes" scopes \
52 [format {o frameId [i %d]} $frame_id]]
53 set scopes [dict get [lindex $scopes 0] body scopes]
54
55 # This is what the implementation does, so we can assume it, but check
56 # just in case something changes.
57 lassign $scopes scope _ignore
58 gdb_assert {[dict get $scope name] == "Locals"} "scope is locals"
59
60 gdb_assert {[dict get $scope namedVariables] == 2} "two vars in scope"
61
62 set num [dict get $scope variablesReference]
63 set refs [lindex [dap_check_request_and_response "fetch variables" \
64 "variables" \
65 [format {o variablesReference [i %d] count [i 2]} \
66 $num]] \
67 0]
68
69 foreach var [dict get $refs body variables] {
70 set name [dict get $var name]
71
72 switch $name {
73 "value" {
74 gdb_assert {[dict get $var value] == "three"} "check value of value"
75 }
76 "my_string" {
77 }
78 default {
79 fail "unknown variable $name"
80 }
81 }
82 }
83
84 dap_shutdown