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