Automatic date update in version.in
[binutils-gdb/blckswan.git] / gdb / testsuite / gdb.mi / mi-condbreak-call-thr-state.exp
blob7f9cb086623c5bdd8c0146075b24d59c70eda7fc
1 # Copyright (C) 2013-2022 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 # 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:
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 # ...
32 load_lib mi-support.exp
33 set MIFLAGS "-i=mi"
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
42 with_test_prefix "$variant" {
43 gdb_exit
44 if [mi_gdb_start] {
45 return
48 set options {debug}
49 if {$variant == "mt" } {
50 lappend options "pthreads"
53 # Don't use standard_testfile as we need a different binary
54 # for each variant.
55 set testfile $gdb_test_file_name-$variant
56 set binfile [standard_output_file ${testfile}]
57 set srcfile $testfile.c
58 set srcfile2 $gdb_test_file_name.c
60 if {[build_executable "failed to prepare" \
61 $testfile \
62 "${srcfile} ${srcfile2}" \
63 $options] == -1} {
64 return -1
67 mi_delete_breakpoints
68 mi_gdb_reinitialize_dir $srcdir/$subdir
69 mi_gdb_reinitialize_dir $srcdir/$subdir
70 mi_gdb_load ${binfile}
72 mi_runto test
74 # Leave the breakpoint at 'test' set, on purpose. The next
75 # resume shall emit a single '*running,thread-id="all"', even
76 # if GDB needs to step over a breakpoint (that is, even if GDB
77 # needs to run only one thread for a little bit).
79 set bp_location [gdb_get_line_number "set breakpoint here" $srcfile2]
80 set bp_location_end [gdb_get_line_number "set end breakpoint here" $srcfile2]
82 mi_gdb_test "-break-insert -c return_false() $srcfile2:$bp_location" ".*" \
83 "insert conditional breakpoint"
85 mi_gdb_test "-break-insert $srcfile2:$bp_location_end" ".*" \
86 "insert end breakpoint"
88 set msg "no spurious *running notifications"
89 send_gdb "-exec-continue\n"
90 gdb_expect {
91 -re "\\*running.*\\*running.*\\*stopped" {
92 fail $msg
94 -re "\\^running\r\n\\*running,thread-id=\"all\"\r\n${mi_gdb_prompt}.*\\*stopped" {
95 pass $msg
97 timeout {
98 fail "$msg (timeout)"
102 # In sync mode, there's an extra prompt after *stopped. Consume it.
103 if {!$async} {
104 gdb_expect {
105 -re "$mi_gdb_prompt" {
112 # Single-threaded.
113 test "st"
115 # Multi-threaded.
116 test "mt"