]>
Commit | Line | Data |
---|---|---|
1d506c26 | 1 | # Copyright 2023-2024 Free Software Foundation, Inc. |
ee81567c TT |
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 | # Test printing of gdb.LazyString objects. | |
17 | ||
18 | require allow_dap_tests | |
19 | ||
20 | load_lib dap-support.exp | |
21 | ||
22 | standard_testfile | |
23 | ||
24 | if {[build_executable ${testfile}.exp $testfile] == -1} { | |
25 | return | |
26 | } | |
27 | ||
28 | set remote_python_file [gdb_remote_download host \ | |
29 | ${srcdir}/${subdir}/${testfile}.py] | |
30 | ||
31 | save_vars GDBFLAGS { | |
32 | append GDBFLAGS " -iex \"source $remote_python_file\"" | |
33 | ||
34 | if {[dap_launch $testfile] == ""} { | |
35 | return | |
36 | } | |
37 | } | |
38 | ||
39 | set line [gdb_get_line_number "STOP"] | |
40 | set obj [dap_check_request_and_response "set breakpoint by line number" \ | |
41 | setBreakpoints \ | |
42 | [format {o source [o path [%s]] breakpoints [a [o line [i %d]]]} \ | |
43 | [list s $srcfile] $line]] | |
44 | set line_bpno [dap_get_breakpoint_number $obj] | |
45 | ||
46 | dap_check_request_and_response "start inferior" configurationDone | |
47 | ||
48 | dap_wait_for_event_and_check "stopped at line breakpoint" stopped \ | |
49 | "body reason" breakpoint \ | |
50 | "body hitBreakpointIds" $line_bpno | |
51 | ||
52 | set bt [lindex [dap_check_request_and_response "backtrace" stackTrace \ | |
53 | {o threadId [i 1]}] \ | |
54 | 0] | |
55 | set frame_id [dict get [lindex [dict get $bt body stackFrames] 0] id] | |
56 | ||
57 | set scopes [dap_check_request_and_response "get scopes" scopes \ | |
58 | [format {o frameId [i %d]} $frame_id]] | |
59 | set scopes [dict get [lindex $scopes 0] body scopes] | |
60 | ||
61 | lassign $scopes scope reg_scope | |
62 | gdb_assert {[dict get $scope name] == "Locals"} "scope is locals" | |
63 | gdb_assert {[dict get $scope namedVariables] == 1} "one var in scope" | |
64 | ||
65 | set num [dict get $scope variablesReference] | |
66 | set refs [lindex [dap_check_request_and_response "fetch variable" \ | |
67 | "variables" \ | |
68 | [format {o variablesReference [i %d] count [i 1]} \ | |
69 | $num]] \ | |
70 | 0] | |
71 | ||
72 | foreach var [dict get $refs body variables] { | |
73 | gdb_assert {[dict get $var name] == "the_string"} "variable name" | |
74 | # The result looks strange here, but only because TON does not | |
75 | # handle the backslash-quote sequence properly when decoding the | |
76 | # JSON. The actual JSON is: "value": "\"DEI\"". | |
77 | gdb_assert {[dict get $var value] == "\\\"DEI\\\""} "variable value" | |
78 | } | |
79 | ||
80 | dap_shutdown |