Automatic Copyright Year update after running gdb/copyright.py
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.mi / mi-pending.exp
CommitLineData
88b9d363 1# Copyright 2007-2022 Free Software Foundation, Inc.
afe8ab22
VP
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
16load_lib mi-support.exp
17set MIFLAGS "-i=mi"
18
afe8ab22
VP
19#
20# test running programs
21#
afe8ab22
VP
22
23if {[skip_shlib_tests]} {
24 return 0
25}
26
15630549 27standard_testfile mi-pending.c
afe8ab22 28
15630549
AT
29set libfile1 "mi-pendshr"
30set libfile2 "mi-pendshr2"
31set libsrc1 $srcdir/$subdir/$libfile1.c
32set libsrc2 $srcdir/$subdir/$libfile2.c
33set lib_sl1 [standard_output_file $libfile1.sl]
34set lib_sl2 [standard_output_file $libfile2.sl]
35set lib_opts debug
36set exec_opts [list debug shlib=$lib_sl1 shlib_load]
afe8ab22 37
4c93b1db 38if [get_compiler_info] {
afe8ab22
VP
39 return -1
40}
41
15630549
AT
42if { [gdb_compile_shlib $libsrc1 $lib_sl1 $lib_opts] != ""
43 || [gdb_compile_shlib $libsrc2 $lib_sl2 $lib_opts] != ""} {
84c93cd5 44 untested "failed to compile shared library"
afe8ab22
VP
45 return -1
46}
47
15630549 48if { [gdb_compile_pthreads $srcdir/$subdir/$srcfile $binfile executable $exec_opts] != ""} {
84c93cd5 49 untested "failed to compile"
15630549
AT
50 return -1
51}
afe8ab22 52
15630549 53# Start with a fresh gdb.
afe8ab22
VP
54gdb_exit
55mi_gdb_start
56mi_gdb_reinitialize_dir $srcdir/$subdir
57mi_gdb_load ${binfile}
15630549
AT
58mi_load_shlibs $lib_sl1
59mi_load_shlibs $lib_sl2
afe8ab22 60
ea5ca7b5 61# Set pending breakpoint via MI.
afe8ab22 62mi_gdb_test "-break-insert -f pendfunc1" \
d24317b4 63 ".*\\^done,bkpt=\{number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"<PENDING>\",pending=\"pendfunc1\",times=\"0\",original-location=\"pendfunc1\"\}"\
afe8ab22
VP
64 "MI pending breakpoint on pendfunc1"
65
ea5ca7b5 66# Set pending breakpoint with a condition via MI.
79dc332b
SL
67mi_gdb_test "-break-insert -f -c x==4 ${libfile1}.c:pendfunc2" \
68 ".*\\^done,bkpt=\{number=\"2\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"<PENDING>\",pending=\"${libfile1}.c:pendfunc2\",cond=\"x==4\",times=\"0\",original-location=\"${libfile1}.c:pendfunc2\"\}"\
ad235a41 69 "MI pending breakpoint on ${libfile1}.c:pendfunc2 if x==4"
15630549
AT
70
71# Set breakpoint so that we can stop when the thread is created
72mi_gdb_test "-break-insert -f thread_func" \
73 ".*\\^done,bkpt=\{number=\"3\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"${hex}\",func=\"thread_func\".*\}"\
74 "MI pending breakpoint on thread_func"
ea5ca7b5 75
afe8ab22 76mi_run_cmd
15630549 77
18ac113b
AR
78mi_expect_stop "breakpoint-hit" "pendfunc1" ".*" ".*" ".*" \
79 { "" "disp=\"keep\"" } \
80 "Run till MI pending breakpoint on pendfunc1"
ea5ca7b5
MK
81
82mi_send_resuming_command "exec-continue" "continuing execution to skip conditional bp"
15630549 83
ea5ca7b5
MK
84# We should not stop on the conditional breakpoint yet, but we stop on the original bp.
85mi_expect_stop "breakpoint-hit" "pendfunc1" ".*" ".*" ".*" \
86 { "" "disp=\"keep\"" } \
87 "Run till MI pending breakpoint on pendfunc1 a second time"
88
89mi_send_resuming_command "exec-continue" "continuing execution to conditional bp"
15630549 90
ea5ca7b5
MK
91# Now we should stop on the conditional breakpoint.
92mi_expect_stop "breakpoint-hit" "pendfunc2" "\{name=\"x\",value=\"4\"\}" ".*" ".*" \
93 { "" "disp=\"keep\"" } \
94 "Run till MI pending breakpoint on pendfunc2 with x==4"
15630549
AT
95
96mi_send_resuming_command "exec-continue" "continuing execution to thread creation"
97
98# Stop on thread creation so we can set a pending breakpoint with a thread cond.
99mi_expect_stop "breakpoint-hit" "thread_func" ".*" ".*" ".*" \
100 { "" "disp=\"keep\"" } \
101 "Run till MI pending breakpoint on thread_func"
102
103# Delete thread creation breakpoint to enable more than 1 thread to be created.
cdc7edd7 104mi_gdb_test "-break-delete 3" "\\^done" "delete breakpoint 3"
15630549
AT
105
106# Set pending breakpoint with a thread via MI.
107mi_gdb_test "-break-insert -p 2 -f pendfunc3" \
108 ".*\\^done,bkpt=\{number=\"4\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"<PENDING>\",pending=\"pendfunc3\",thread=\"2\",thread=\"2\",times=\"0\",original-location=\"pendfunc3\"\}"\
109 "MI pending breakpoint on pendfunc3"
110
111mi_send_resuming_command "exec-continue" "continuing execution to thread condition"
112
113# Check if we stopped in thread 2 like we should.
bc6c7af4 114set testname "run till MI pending breakpoint on pendfunc3 on thread 2"
79dc332b 115gdb_expect {
15630549
AT
116 -re "\\*stopped,reason=\"breakpoint-hit\",disp=\"keep\",bkptno=\"4\",frame=\{addr=\"$hex\",func=\"pendfunc3\".*thread-id=\"2\".*" {
117 pass $testname
118 return 0
119 }
120 timeout {
121 fail "$testname (timeout)"
122 return -1
123 }
124}
This page took 1.942249 seconds and 4 git commands to generate.