1 # more-steps.exp -- Expect script to test gdb's ability to step threaded pgms
2 # Copyright (C) 1992 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 2 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, write to the Free Software
16 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
18 # Please email any bugs, comments, and/or additions to this file to:
19 # bug-gdb@prep.ai.mit.edu
29 if { [skip_hp_tests] } then { continue }
31 #if { ![istarget "hppa*-*-hpux10.30"] && ![istarget "hppa*-*-hpux11.*"] } {
32 # verbose "HPUX thread test ignored for non-hppa or pre-HP/UX-10.30 targets."
36 set testfile more-steps
37 set srcfile ${srcdir}/${subdir}/${testfile}.c
38 set binfile ${objdir}/${subdir}/${testfile}
40 if [get_compiler_info ${binfile}] {
44 # To build the executable we need to link against the thread library.
46 # cc -Ae -g -o more-steps -lpthread more-steps.c
48 #compile "${srcfile} -Ae -g -lpthread -o ${binfile}"
50 if {$gcc_compiled == 0} {
51 set additional_flags "additional_flags=-Ae"
53 set additional_flags ""
56 if { [gdb_compile "${srcdir}/${subdir}/${testfile}.c" "${binfile}.o" object [list debug $additional_flags]] != "" } {
57 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
60 if { ![istarget "hppa*-*-hpux10.30"] && ![istarget "hppa*-*-hpux11.*"] } {
61 if { [gdb_compile "${binfile}.o" "${binfile}" executable {debug "additional_flags=-lpthread"}] != ""} {
62 gdb_suppress_entire_file "Testcase link failed, so all tests in this file will automatically fail."
65 remote_exec build "ld /usr/ccs/lib/crt0.o ${binfile}.o -lcl -lpthread -lc /opt/langtools/lib/end.o -o ${binfile}"
67 #remote_exec build "ld /usr/ccs/lib/crt0.o ${binfile}.o -lcl -lpthread -lc /opt/langtools/lib/end.o -o ${binfile}"
71 # Thread stuff is _slow_; prepare for long waits.
73 set oldtimeout $timeout
74 set timeout [expr "$timeout + 300"]
75 set oldverbose $verbose
78 # Further, this test has some "null" lines designed
79 # to consume output from gdb that was too late to be
80 # matched (sequence is "gdb_test" sends; timeout and
81 # on to next send; result finally comes in; mismatch).
83 # The null command is 'gdb_test "p \$pc" ".*" ""'
85 # NOTE: to pass a literal "$", "/" or "*" (etc.) to gdb_test,
86 # remember that the pattern will be escaped once and
93 gdb_test "p \$pc" ".*" ""
96 #=========================
98 # Simple sanity test first.
102 gdb_reinitialize_dir $srcdir/$subdir
105 # First, step in the main thread.
107 gdb_test "b do_pass" ".*Breakpoint 1.*" ""
108 gdb_test "r" ".*Breakpoint 1.*do_pass.*" ""
110 # Breaks as well as nexts to make
111 # sure we can handle simultaneous hit
112 # of bpt and step, as well as stepping
115 gdb_test "tb 87" ".*Breakpoint 2.*" ""
116 gdb_test "tb 91" ".*Breakpoint 3.*" ""
117 gdb_test "tb 96" ".*Breakpoint 4.*" ""
118 gdb_test "tb 113" ".*Breakpoint 5.*" ""
119 gdb_test "c" ".*do_pass.*87.*" "87"
120 gdb_test "n" ".*do_pass.*91.*" "n"
122 # This only gets a number, as it doesn't
125 gdb_test "n" ".*95.*" "n"
127 gdb_test "n" ".*do_pass.*96.*" "n"
128 gdb_test "c" ".*do_pass.*113.*" "c"
129 gdb_test "c" ".*Program exited normally.*" "c"
131 # Now step in a thread
133 gdb_test "r" ".*Breakpoint.*do_pass.*" "do_pass"
134 gdb_test "until 87" ".*do_pass.*87.*" "until"
135 gdb_test "thr 4" ".*Switching to thread 4.*spin.*56.*" "switch"
136 gdb_test "tb 60 thr 4" ".*Breakpoint.*" ""
138 # If we do "next" now, all the other threads
141 gdb_test "n" ".*spin.*60.*" ""
142 gdb_test "i th" ".*\\\* 4 sys.*spin.*1 sys.*do_pass.*" "still in 4"
148 set timeout $oldtimeout
149 set verbose $oldverbose
151 # execute_anywhere "rm -f ${binfile}"