Handle the static link in FrameDecorator
[binutils-gdb.git] / gdb / testsuite / gdb.dap / ada-nested.exp
1 # Copyright 2023 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 # Check the scope of a nested function.
17
18 load_lib ada.exp
19 load_lib dap-support.exp
20
21 require allow_ada_tests allow_dap_tests
22
23 standard_ada_testfile prog
24
25 if {[gdb_compile_ada "${srcfile}" "${binfile}" executable \
26 {debug additional_flags=-gnata}] != ""} {
27 return -1
28 }
29
30 if {[dap_launch $binfile] == ""} {
31 return
32 }
33
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]
41
42 dap_check_request_and_response "start inferior" configurationDone
43
44 dap_wait_for_event_and_check "stopped at breakpoint" stopped \
45 "body reason" breakpoint \
46 "body hitBreakpointIds" $fn_bpno
47
48 set bt [lindex [dap_check_request_and_response "backtrace" stackTrace \
49 {o threadId [i 1]}] \
50 0]
51 set frame_id [dict get [lindex [dict get $bt body stackFrames] 0] id]
52
53 set scopes [dap_check_request_and_response "get scopes" scopes \
54 [format {o frameId [i %d]} $frame_id]]
55 set scopes [dict get [lindex $scopes 0] body scopes]
56
57 # This is what the implementation does, so we can assume it, but check
58 # just in case something changes.
59 lassign $scopes args locals _ignore
60 gdb_assert {[dict get $args name] == "Arguments"} "argument scope"
61 gdb_assert {[dict get $locals name] == "Locals"} "local scope"
62
63 gdb_assert {[dict get $locals namedVariables] == 3} "two locals"
64
65 set num [dict get $locals variablesReference]
66 set refs [lindex [dap_check_request_and_response "fetch variables" \
67 "variables" \
68 [format {o variablesReference [i %d] count [i 3]} \
69 $num]] \
70 0]
71
72 foreach var [dict get $refs body variables] {
73 set name [dict get $var name]
74
75 switch $name {
76 "i" {
77 gdb_assert {[dict get $var value] == "1"} "check value of i"
78 }
79 "x" {
80 gdb_assert {[dict get $var value] == "12"} "check value of x"
81 }
82 "outer_arg" {
83 gdb_assert {[dict get $var value] == "1"} "check value of outer_arg"
84 }
85 default {
86 fail "unknown variable $name"
87 }
88 }
89 }
90
91 dap_shutdown