Automatic Copyright Year update after running gdb/copyright.py
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.mi / mi-pending.exp
1 # Copyright 2007-2022 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 load_lib mi-support.exp
17 set MIFLAGS "-i=mi"
18
19 #
20 # test running programs
21 #
22
23 if {[skip_shlib_tests]} {
24 return 0
25 }
26
27 standard_testfile mi-pending.c
28
29 set libfile1 "mi-pendshr"
30 set libfile2 "mi-pendshr2"
31 set libsrc1 $srcdir/$subdir/$libfile1.c
32 set libsrc2 $srcdir/$subdir/$libfile2.c
33 set lib_sl1 [standard_output_file $libfile1.sl]
34 set lib_sl2 [standard_output_file $libfile2.sl]
35 set lib_opts debug
36 set exec_opts [list debug shlib=$lib_sl1 shlib_load]
37
38 if [get_compiler_info] {
39 return -1
40 }
41
42 if { [gdb_compile_shlib $libsrc1 $lib_sl1 $lib_opts] != ""
43 || [gdb_compile_shlib $libsrc2 $lib_sl2 $lib_opts] != ""} {
44 untested "failed to compile shared library"
45 return -1
46 }
47
48 if { [gdb_compile_pthreads $srcdir/$subdir/$srcfile $binfile executable $exec_opts] != ""} {
49 untested "failed to compile"
50 return -1
51 }
52
53 # Start with a fresh gdb.
54 gdb_exit
55 mi_gdb_start
56 mi_gdb_reinitialize_dir $srcdir/$subdir
57 mi_gdb_load ${binfile}
58 mi_load_shlibs $lib_sl1
59 mi_load_shlibs $lib_sl2
60
61 # Set pending breakpoint via MI.
62 mi_gdb_test "-break-insert -f pendfunc1" \
63 ".*\\^done,bkpt=\{number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"<PENDING>\",pending=\"pendfunc1\",times=\"0\",original-location=\"pendfunc1\"\}"\
64 "MI pending breakpoint on pendfunc1"
65
66 # Set pending breakpoint with a condition via MI.
67 mi_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\"\}"\
69 "MI pending breakpoint on ${libfile1}.c:pendfunc2 if x==4"
70
71 # Set breakpoint so that we can stop when the thread is created
72 mi_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"
75
76 mi_run_cmd
77
78 mi_expect_stop "breakpoint-hit" "pendfunc1" ".*" ".*" ".*" \
79 { "" "disp=\"keep\"" } \
80 "Run till MI pending breakpoint on pendfunc1"
81
82 mi_send_resuming_command "exec-continue" "continuing execution to skip conditional bp"
83
84 # We should not stop on the conditional breakpoint yet, but we stop on the original bp.
85 mi_expect_stop "breakpoint-hit" "pendfunc1" ".*" ".*" ".*" \
86 { "" "disp=\"keep\"" } \
87 "Run till MI pending breakpoint on pendfunc1 a second time"
88
89 mi_send_resuming_command "exec-continue" "continuing execution to conditional bp"
90
91 # Now we should stop on the conditional breakpoint.
92 mi_expect_stop "breakpoint-hit" "pendfunc2" "\{name=\"x\",value=\"4\"\}" ".*" ".*" \
93 { "" "disp=\"keep\"" } \
94 "Run till MI pending breakpoint on pendfunc2 with x==4"
95
96 mi_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.
99 mi_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.
104 mi_gdb_test "-break-delete 3" "\\^done" "delete breakpoint 3"
105
106 # Set pending breakpoint with a thread via MI.
107 mi_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
111 mi_send_resuming_command "exec-continue" "continuing execution to thread condition"
112
113 # Check if we stopped in thread 2 like we should.
114 set testname "run till MI pending breakpoint on pendfunc3 on thread 2"
115 gdb_expect {
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 0.031385 seconds and 4 git commands to generate.