1 # step2.exp -- Expect script to test gdb step.c
2 # Copyright (C) 1992, 1997, 2007, 2008, 2009, 2010
3 # Free Software Foundation, Inc.
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18 # This file was written by Jeff Law. (law@cygnus.com)
28 # A simple and crude test to see that we can step two threads independently
29 proc test_multi_threaded_stepping {} {
35 # Set breakpoints in code that we know is executed in only
37 gdb_test "break thread1" \
38 "Break.* at $hex: file .*$srcfile, line $decimal\\."
39 gdb_test "break thread2" \
40 "Break.* at $hex: file .*$srcfile, line $decimal\\."
42 # the order in which things happen is indeterminate. So we basically
43 # look for a set of events and note that each one happens and that
44 # all of the required events have happened when we're done.
46 # Right now we only verify that both threads start and that they
47 # both call pthread_cond_wait twice.
55 -re "The program .* has been started already.*y or n. $" {
59 -re ".*Breakpoint \[0-9\]+,.*thread1.* at .*$srcfile:.*\[\t \].*$gdb_prompt $" {
60 if { $thread1started != 0 } then {
61 fail "thread1 started"
65 pass "thread1 started"
70 -re ".*Breakpoint \[0-9\]+,.*thread2.* at .*$srcfile:.*\[\t \].*$gdb_prompt $" {
71 if { $thread2started != 0 } then {
72 fail "thread2 started"
76 pass "thread2 started"
81 -re ".*pthread_cond_wait.*cv_a.*$gdb_prompt" {
82 if { $thread1started == 0 } then {
83 fail "thread1 condwait"
86 if { $thread1condwait < 2 } then {
87 pass "thread1 condwait"
90 if { $thread2condwait == 2 } then {
91 pass "multi threaded stepping"
98 -re ".*pthread_cond_wait.*cv_b.*$gdb_prompt" {
99 if { $thread2started == 0 } then {
100 fail "thread2 condwait"
103 if { $thread2condwait < 2 } then {
104 pass "thread2 condwait"
107 if { $thread1condwait == 2 } then {
108 pass "multi threaded stepping"
119 default { fail "multi threaded stepping" }
123 # Check to see if we have an executable to test. If not, then either we
124 # haven't tried to compile one, or the compilation failed for some reason.
125 # In either case, just notify the user and skip the tests in this file.
130 if ![file exists $objdir/$subdir/$binfile] then {
132 warning "$binfile does not exist; tests suppressed."
138 # Start with a fresh gdb.
142 gdb_reinitialize_dir $srcdir/$subdir
143 gdb_load $objdir/$subdir/$binfile
145 test_multi_threaded_stepping