1 # Copyright (C) 1997, 1998, 1999 Free Software Foundation, Inc.
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 2 of the License, or
6 # (at your option) any later version.
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.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
17 # Please email any bugs, comments, and/or additions to this file to:
18 # bug-gdb@prep.ai.mit.edu
24 # ending-run.exp -- Expect script to test ending a test run in gdb
30 set testfile ending-run
31 set srcfile ${testfile}.c
32 set binfile ${objdir}/${subdir}/${testfile}
34 remote_exec build "rm -f ${binfile}"
35 remote_exec build "rm -f core"
38 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
39 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
46 gdb_reinitialize_dir $srcdir/$subdir
49 # CHFts23469: Test that you can "clear" a bp set at
50 # a line _before_ the routine (which will default to the
51 # first line in the routine, which turns out to correspond
52 # to the prolog--that's another bug...)
54 gdb_test "b 1" ".*Breakpoint.*line 1.*" "bpt at line before routine"
55 gdb_test "b 13" ".*Note.*also.*Breakpoint.*2.*"
57 # Set up to go to the next-to-last line of the program
59 gdb_test "b 31" ".*Breakpoint.*3.*"
61 # Expect to hit the bp at line "1", but symbolize this
62 # as line "13". Then try to clear it--this should work.
64 if [target_info exists use_gdb_stub] {
65 gdb_test "continue" ".*Breakpoint.*1.*callee.*13.*"
67 gdb_test "r" ".*Breakpoint.*1.*callee.*13.*"
69 gdb_test "cle" ".*Deleted breakpoints 2 1.*" "clear worked"
72 -re ".*breakpoint.*breakpoint.*$gdb_prompt $" { fail "clear bp" }
73 -re ".*3.*main.*31.*$gdb_prompt $" { pass "cleared bp at line before routine" }
74 -re ".*$gdb_prompt $" { fail "info b" }
77 # Test some other "clear" combinations
79 gdb_test "b 1" ".*Breakpoint.*4.*"
80 gdb_test "b 13" ".*Note.*also.*Breakpoint.*5.*"
81 gdb_test "cle 13" ".*Deleted breakpoint 5.*" "Only cleared 1 by line"
83 send_gdb "inf line 13\n"
85 -re ".*address (0x\[0-9a-fA-F]*).*$gdb_prompt $" {
86 set line_eight $expect_out(1,string)
87 gdb_test "b 13" ".*Breakpoint.*6.*"
88 gdb_test "cle *$line_eight" ".*Deleted breakpoints 6 4.*" "Clear 2 by address"
90 -re ".*$gdb_prompt $" {
91 fail "need to fix test for new compile outcome"
95 send_gdb "inf line 14\n"
97 -re ".*address (0x\[0-9a-fA-F]*).*$gdb_prompt $" {
98 set line_nine $expect_out(1,string)
99 gdb_test "b 14" ".*Breakpoint.*7.*"
100 gdb_test "b *$line_nine" ".*Note.*also.*Breakpoint.*8.*"
101 gdb_test "c" ".*Breakpoint.*7.*callee.*14.*"
102 gdb_test "cle" ".*Deleted breakpoints 8 7.*" "Clear 2 by default"
104 -re ".*$gdb_prompt $" {
105 fail "need to fix test for new compile outcome"
111 -re ".*breakpoint.*breakpoint.*$gdb_prompt $" {
112 fail "didn't clear bps"
114 -re ".*3.*main.*31.*$gdb_prompt $" {
115 pass "all set to continue"
117 -re ".*$gdb_prompt $" {
118 fail "missing bp at end"
123 # See if we can step out with control. The "1 2 3" stuff
124 # is output from the program.
126 gdb_test "cont" ".*Breakpoint.*31.*"
127 gdb_test "next" ".*1 2 7 14 23 34 47 62 79 Goodbye!.*32.*" "Step to return"
129 set old_timeout $timeout
133 -re "33.*$gdb_prompt $" {
134 # sometimes we stop at the closing brace, if so, do another next
137 -re ".*Unable to find return pc for this frame.*$gdb_prompt $" {
138 fail "Old bug came back!"
141 -re ".*in.*start.*$gdb_prompt $" {
142 pass "step out of main"
144 -re ".*in .nope ().*$gdb_prompt $" {
145 # This is what happens on Solaris currently -sts 1999-08-25
146 pass "step out of main on Solaris"
148 -re ".*in.*\\\$START\\\$.*from.*dld.sl.*$gdb_prompt $" {
149 pass "step out of main"
151 -re ".*$gdb_prompt $" { fail "step at end 2" }
152 timeout { fail "hang or timeout on step at end 2" }
155 -re ".*Unable to find return pc for this frame.*$gdb_prompt $" {
156 fail "Old bug came back!"
159 -re ".*in.*start.*$gdb_prompt $" {
160 pass "step out of main"
162 -re ".*in.*\\\$START\\\$.*from.*dld.sl.*$gdb_prompt $" {
163 pass "step out of main 2"
165 -re ".*in.*currently asm.*$gdb_prompt $" {
166 pass "step out of main into assembler"
168 -re ".*Program received signal SIGTRAP.*$gdb_prompt $" {
169 pass "Cygmon stopped in ending trap."
171 -re ".*$gdb_prompt $" { fail "step at end 1" }
172 timeout { fail "hang or timeout on step at end 1" }
175 if {![target_info exists use_cygmon] || ![target_info use_cygmon]} {
178 -re "Program exited normally.*$gdb_prompt $" {
179 # If we actually have debug info for the start function,
180 # then we won't get the "Single-stepping until function
182 pass "step to end of run 1"
184 -re ".*Single.*Program exited.*$gdb_prompt $" {
185 pass "step to end of run 1"
187 -re ".*Single.*in exit.*from.*dld.sl.*$gdb_prompt $" {
188 pass "step to end of run 2"
189 gdb_test "c" ".*" "continue after exit"
191 timeout { fail "(timeout) step to end of run" }
194 set timeout $old_timeout
196 gdb_test "n" ".*The program is not being run.*" "don't step after run"
198 set exec_output [remote_exec host "ls core"]
201 if [ regexp "core not found" $exec_output] {
202 pass "No core dumped on quit"
204 if [ regexp "No such file or directory" $exec_output] {
205 pass "ls: core: No core dumped on quit"
207 remote_exec build "rm -f core"
208 fail "Core dumped on quit"
213 #remote_exec build "rm -f ${binfile}"