1 # Copyright 2023-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/>.
17 load_lib dap-support.exp
19 require allow_ada_tests allow_dap_tests
21 standard_ada_testfile prog
23 if {[gdb_compile_ada "${srcfile}" "${binfile}" executable \
24 {debug additional_flags=-gnata}] != ""} {
28 if {[dap_launch $binfile] == ""} {
32 set line [gdb_get_line_number "STOP"]
33 set obj [dap_check_request_and_response "set breakpoint" \
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]
40 dap_check_request_and_response "start inferior" configurationDone
42 dap_wait_for_event_and_check "stopped at breakpoint" stopped \
43 "body reason" breakpoint \
44 "body hitBreakpointIds" $fn_bpno
46 set bt [lindex [dap_check_request_and_response "backtrace" stackTrace \
49 set frame_id [dict get [lindex [dict get $bt body stackFrames] 0] id]
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]
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"
60 gdb_assert {[dict get $scope namedVariables] == 2} "two vars in scope"
62 set num [dict get $scope variablesReference]
63 set refs [lindex [dap_check_request_and_response "fetch variables" \
65 [format {o variablesReference [i %d] count [i 2]} \
69 foreach var [dict get $refs body variables] {
70 set name [dict get $var name]
74 gdb_assert {[dict get $var value] == "three"} "check value of value"
79 fail "unknown variable $name"