gdb: avoid double stop after failed breakpoint condition check
[binutils-gdb.git] / gdb / testsuite / gdb.mi / mi-condbreak-fail.exp
1 # Copyright (C) 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 that when GDB fails to evaluate the condition of a conditional
17 # breakpoint we only get one *stopped notification.
18
19 load_lib mi-support.exp
20 set MIFLAGS "-i=mi"
21
22 standard_testfile
23
24 if [build_executable ${testfile}.exp ${binfile} ${srcfile}] {
25 return -1
26 }
27
28 if {[mi_clean_restart $binfile]} {
29 return
30 }
31
32 if {[mi_runto_main] == -1} {
33 return
34 }
35
36 # Create the conditional breakpoint.
37 set bp_location [gdb_get_line_number "Set breakpoint here"]
38 mi_create_breakpoint "-c \"cond_fail ()\" $srcfile:$bp_location" \
39 "insert conditional breakpoint" \
40 -func foo -file ".*$srcfile" -line "$bp_location" \
41 -cond "cond_fail \\(\\)"
42
43 # Number of the previous breakpoint.
44 set bpnum [mi_get_valueof "/d" "\$bpnum" "INVALID" \
45 "get number for breakpoint"]
46
47 # The line where we expect the inferior to crash.
48 set crash_linenum [gdb_get_line_number "Crash here"]
49
50 # Run the inferior and wait for it to stop.
51 mi_send_resuming_command "exec-continue" "continue the inferior"
52 mi_gdb_test "" \
53 [multi_line \
54 "~\"\\\\nProgram\"" \
55 "~\" received signal SIGSEGV, Segmentation fault\\.\\\\n\"" \
56 "~\"$hex in cond_fail \\(\\) at \[^\r\n\]+\"" \
57 "~\"${crash_linenum}\\\\t\\s+return \\*p;\[^\r\n\]+\\\\n\"" \
58 "\\*stopped,reason=\"signal-received\",signal-name=\"SIGSEGV\"\[^\r\n\]+" \
59 "&\"Error in testing condition for breakpoint $bpnum:\\\\n\"" \
60 "&\"The program being debugged was signaled while in a function called from GDB\\.\\\\n\"" \
61 "&\"GDB remains in the frame where the signal was received\\.\\\\n\"" \
62 "&\"To change this behavior use \\\\\"set unwindonsignal on\\\\\"\\.\\\\n\"" \
63 "&\"Evaluation of the expression containing the function\\\\n\"" \
64 "&\"\\(cond_fail\\) will be abandoned\\.\\\\n\"" \
65 "&\"When the function is done executing, GDB will silently stop\\.\\\\n\"" \
66 "=breakpoint-modified,bkpt={number=\"$bpnum\",type=\"breakpoint\",\[^\r\n\]+times=\"1\",\[^\r\n\]+}"] \
67 "wait for stop"