Add translations for various sub-directories
[binutils-gdb.git] / gdb / testsuite / gdb.dap / ada-scopes.exp
blobef1302e0644dfe1435f453fd72ece3548d14dff4
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/>.
16 load_lib ada.exp
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}] != ""} {
25     return -1
28 if {[dap_initialize] == ""} {
29     return
32 set launch_id [dap_launch $testfile]
34 set line [gdb_get_line_number "STOP"]
35 set obj [dap_check_request_and_response "set breakpoint" \
36              setBreakpoints \
37              [format {o source [o path [%s]] \
38                           breakpoints [a [o line [i %d]]]} \
39                   [list s $srcfile] $line]]
40 set fn_bpno [dap_get_breakpoint_number $obj]
42 dap_check_request_and_response "configurationDone" configurationDone
44 dap_check_response "launch response" launch $launch_id
46 dap_wait_for_event_and_check "stopped at breakpoint" stopped \
47     "body reason" breakpoint \
48     "body hitBreakpointIds" $fn_bpno
50 set bt [lindex [dap_check_request_and_response "backtrace" stackTrace \
51                     {o threadId [i 1]}] \
52             0]
53 set frame_id [dict get [lindex [dict get $bt body stackFrames] 0] id]
55 set scopes [dap_check_request_and_response "get scopes" scopes \
56                 [format {o frameId [i %d]} $frame_id]]
57 set scopes [dict get [lindex $scopes 0] body scopes]
59 # This is what the implementation does, so we can assume it, but check
60 # just in case something changes.
61 lassign $scopes scope _ignore
62 gdb_assert {[dict get $scope name] == "Locals"} "scope is locals"
63 gdb_assert {[dict get $scope source name] == "prog.adb"} "scope has source"
65 gdb_assert {[dict get $scope namedVariables] == 2} "two vars in scope"
67 set num [dict get $scope variablesReference]
68 set refs [lindex [dap_check_request_and_response "fetch variables" \
69                       "variables" \
70                       [format {o variablesReference [i %d] count [i 2]} \
71                            $num]] \
72               0]
74 foreach var [dict get $refs body variables] {
75     set name [dict get $var name]
77     switch $name {
78         "value" {
79             gdb_assert {[dict get $var value] == "three"} "check value of value"
80         }
81         "my_string" {
82         }
83         default {
84             fail "unknown variable $name"
85         }
86     }
89 dap_shutdown