]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.mi/mi-condbreak-call-thr-state.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.mi / mi-condbreak-call-thr-state.exp
1 # Copyright (C) 2013-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 # Regression test for PR15693. A breakpoint with a condition that
17 # calls a function that evaluates false would result in a spurious
18 # *running event sent to the frontend each time the breakpoint is hit
19 # (and the target re-resumed). Like:
20 #
21 # -exec-continue
22 # ^running
23 # *running,thread-id="all"
24 # (gdb)
25 # *running,thread-id="all"
26 # *running,thread-id="all"
27 # *running,thread-id="all"
28 # *running,thread-id="all"
29 # *running,thread-id="all"
30 # ...
31
32 load_lib mi-support.exp
33 set MIFLAGS "-i=mi"
34
35 # Run either the multi-threaded or the single-threaded variant of the
36 # test, as determined by VARIANT.
37 proc test { variant } {
38 global gdb_test_file_name
39 global testfile srcdir subdir srcfile srcfile2 binfile
40 global mi_gdb_prompt async
41
42 with_test_prefix "$variant" {
43 set options {debug}
44 if {$variant == "mt" } {
45 lappend options "pthreads"
46 }
47
48 # Don't use standard_testfile as we need a different binary
49 # for each variant.
50 set testfile $gdb_test_file_name-$variant
51 set binfile [standard_output_file ${testfile}]
52 set srcfile $testfile.c
53 set srcfile2 $gdb_test_file_name.c
54
55 if {[build_executable "failed to prepare" \
56 $testfile \
57 "${srcfile} ${srcfile2}" \
58 $options] == -1} {
59 return -1
60 }
61
62 if {[mi_clean_restart $binfile]} {
63 return
64 }
65
66 mi_runto test
67
68 # Leave the breakpoint at 'test' set, on purpose. The next
69 # resume shall emit a single '*running,thread-id="all"', even
70 # if GDB needs to step over a breakpoint (that is, even if GDB
71 # needs to run only one thread for a little bit).
72
73 set bp_location [gdb_get_line_number "set breakpoint here" $srcfile2]
74 set bp_location_end [gdb_get_line_number "set end breakpoint here" $srcfile2]
75
76 mi_gdb_test "-break-insert -c return_false() $srcfile2:$bp_location" ".*" \
77 "insert conditional breakpoint"
78
79 mi_gdb_test "-break-insert $srcfile2:$bp_location_end" ".*" \
80 "insert end breakpoint"
81
82 set msg "no spurious *running notifications"
83 send_gdb "-exec-continue\n"
84 gdb_expect {
85 -re "\\*running.*\\*running.*\\*stopped" {
86 fail $msg
87 }
88 -re "\\^running\r\n\\*running,thread-id=\"all\"\r\n${mi_gdb_prompt}.*\\*stopped" {
89 pass $msg
90 }
91 timeout {
92 fail "$msg (timeout)"
93 }
94 }
95
96 # In sync mode, there's an extra prompt after *stopped. Consume it.
97 if {!$async} {
98 gdb_expect {
99 -re "$mi_gdb_prompt" {
100 }
101 }
102 }
103 }
104 }
105
106 # Single-threaded.
107 test "st"
108
109 # Multi-threaded.
110 test "mt"