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 { ![istarget "hppa*-*-hpux10.30"] && ![istarget "hppa*-*-hpux11.*"] } {
30 # verbose "HPUX thread test ignored for non-hppa or pre-HP/UX-10.30 targets."
34 set testfile more-steps
35 set srcfile ${srcdir}/${subdir}/${testfile}.c
36 set binfile ${objdir}/${subdir}/${testfile}
38 if [get_compiler_info ${binfile}] {
42 # To build the executable we need to link against the thread library.
44 # cc -Ae -g -o more-steps -lpthread more-steps.c
46 #compile "${srcfile} -Ae -g -lpthread -o ${binfile}"
48 if {$gcc_compiled == 0} {
49 set additional_flags "additional_flags=-Ae"
51 set additional_flags ""
54 if { [gdb_compile "${srcdir}/${subdir}/${testfile}.c" "${binfile}.o" object [list debug $additional_flags]] != "" } {
55 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
58 if { ![istarget "hppa*-*-hpux10.30"] && ![istarget "hppa*-*-hpux11.*"] } {
59 if { [gdb_compile "${binfile}.o" "${binfile}" executable {debug "additional_flags=-lpthread"}] != ""} {
60 gdb_suppress_entire_file "Testcase link failed, so all tests in this file will automatically fail."
63 remote_exec build "ld /usr/ccs/lib/crt0.o ${binfile}.o -lcl -lpthread -lc /opt/langtools/lib/end.o -o ${binfile}"
65 #remote_exec build "ld /usr/ccs/lib/crt0.o ${binfile}.o -lcl -lpthread -lc /opt/langtools/lib/end.o -o ${binfile}"
69 # Thread stuff is _slow_; prepare for long waits.
71 set oldtimeout $timeout
72 set timeout [expr "$timeout + 300"]
73 set oldverbose $verbose
76 # Further, this test has some "null" lines designed
77 # to consume output from gdb that was too late to be
78 # matched (sequence is "gdb_test" sends; timeout and
79 # on to next send; result finally comes in; mismatch).
81 # The null command is 'gdb_test "p \$pc" ".*" ""'
83 # NOTE: to pass a literal "$", "/" or "*" (etc.) to gdb_test,
84 # remember that the pattern will be escaped once and
91 gdb_test "p \$pc" ".*" ""
94 #=========================
96 # Simple sanity test first.
100 gdb_reinitialize_dir $srcdir/$subdir
103 # First, step in the main thread.
105 gdb_test "b do_pass" ".*Breakpoint 1.*" ""
106 gdb_test "r" ".*Breakpoint 1.*do_pass.*" ""
108 # Breaks as well as nexts to make
109 # sure we can handle simultaneous hit
110 # of bpt and step, as well as stepping
113 gdb_test "tb 87" ".*Breakpoint 2.*" ""
114 gdb_test "tb 91" ".*Breakpoint 3.*" ""
115 gdb_test "tb 96" ".*Breakpoint 4.*" ""
116 gdb_test "tb 113" ".*Breakpoint 5.*" ""
117 gdb_test "c" ".*do_pass.*87.*" "87"
118 gdb_test "n" ".*do_pass.*91.*" "n"
120 # This only gets a number, as it doesn't
123 gdb_test "n" ".*95.*" "n"
125 gdb_test "n" ".*do_pass.*96.*" "n"
126 gdb_test "c" ".*do_pass.*113.*" "c"
127 gdb_test "c" ".*Program exited normally.*" "c"
129 # Now step in a thread
131 gdb_test "r" ".*Breakpoint.*do_pass.*" "do_pass"
132 gdb_test "until 87" ".*do_pass.*87.*" "until"
133 gdb_test "thr 4" ".*Switching to thread 4.*spin.*56.*" "switch"
134 gdb_test "tb 60 thr 4" ".*Breakpoint.*" ""
136 # If we do "next" now, all the other threads
139 gdb_test "n" ".*spin.*60.*" ""
140 gdb_test "i th" ".*\\\* 4 sys.*spin.*1 sys.*do_pass.*" "still in 4"
146 set timeout $oldtimeout
147 set verbose $oldverbose
149 # execute_anywhere "rm -f ${binfile}"