]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.dap/cond-bp.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.dap / cond-bp.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 # Test DAP breakpoint conditions.
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 if {[dap_launch $testfile] == ""} {
29 return
30 }
31
32 set line [gdb_get_line_number "STOP"]
33
34 # Test some breakpoint-setting failure modes.
35 set obj [dap_check_request_and_response "set invalid breakpoints" \
36 setBreakpoints \
37 [format {o source [o path [%s]] \
38 breakpoints \
39 [a [o line [i %d] condition [s "DEI@@++"]] \
40 [o line [i %d] hitCondition [s "DEI@@++"]]]} \
41 [list s $srcfile] $line $line]]
42
43 set i 1
44 foreach bp [dict get [lindex $obj 0] body breakpoints] {
45 gdb_assert {[dict get $bp verified] == "false"} \
46 "breakpoint $i invalid"
47 gdb_assert {[dict get $bp message] != ""} \
48 "breakpoint $i has message"
49 incr i
50 }
51
52 set obj [dap_check_request_and_response "set conditional breakpoint" \
53 setBreakpoints \
54 [format {o source [o path [%s]] \
55 breakpoints [a [o line [i %d] \
56 condition [s "i == 3"] \
57 hitCondition [s 3]]]} \
58 [list s $srcfile] $line]]
59 set fn_bpno [dap_get_breakpoint_number $obj]
60
61 dap_check_request_and_response "start inferior" configurationDone
62
63 dap_wait_for_event_and_check "stopped at function breakpoint" stopped \
64 "body reason" breakpoint \
65 "body hitBreakpointIds" $fn_bpno
66
67 set bt [lindex [dap_check_request_and_response "backtrace" stackTrace \
68 {o threadId [i 1]}] \
69 0]
70 set frame_id [dict get [lindex [dict get $bt body stackFrames] 0] id]
71
72 set obj [dap_check_request_and_response "evaluate i" \
73 evaluate \
74 [format {o expression [s i] frameId [i %s]} $frame_id]]
75 dap_match_values "value of i" [lindex $obj 0] \
76 "body result" 3
77
78 set obj [dap_check_request_and_response "evaluate j" \
79 evaluate \
80 [format {o expression [s j] frameId [i %s]} $frame_id]]
81 dap_match_values "value of j" [lindex $obj 0] \
82 "body result" 3
83
84 dap_shutdown