]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.base/ending-run.exp
This commit was generated by cvs2svn to track changes on a CVS vendor
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / ending-run.exp
1 # Copyright (C) 1997, 1998 Free Software Foundation, Inc.
2
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.
7 #
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.
12 #
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. */
16
17 # Please email any bugs, comments, and/or additions to this file to:
18 # bug-gdb@prep.ai.mit.edu
19
20 # use this to debug:
21 #
22 #log_user 1
23
24 # ending-run.exp -- Expect script to test ending a test run in gdb
25
26 if $tracelevel then {
27 strace $tracelevel
28 }
29
30 set testfile ending-run
31 set srcfile ${testfile}.c
32 set binfile ${objdir}/${subdir}/${testfile}
33
34 remote_exec build "rm -f ${binfile}"
35 remote_exec build "rm -f core"
36
37
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."
40 }
41
42
43
44 gdb_exit
45 gdb_start
46 gdb_reinitialize_dir $srcdir/$subdir
47 gdb_load ${binfile}
48
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...)
53 #
54 gdb_test "b 1" ".*Breakpoint.*line 1.*" "bpt at line before routine"
55 gdb_test "b 8" ".*Note.*also.*Breakpoint.*2.*" ""
56
57 # Set up to go to the next-to-last line of the program
58 #
59 gdb_test "b 26" ".*Breakpoint.*3.*" ""
60
61 # Expect to hit the bp at line "1", but symbolize this
62 # as line "8". Then try to clear it--this should work.
63 #
64 gdb_test "r" ".*Breakpoint.*1.*callee.*8.*" ""
65 gdb_test "cle" ".*Deleted breakpoints 2 1.*" "clear worked"
66 send_gdb "i b\n"
67 gdb_expect {
68 -re ".*breakpoint.*breakpoint.*$gdb_prompt $" { fail "clear bp" }
69 -re ".*3.*main.*26.*$gdb_prompt $" { pass "cleared bp at line before routine" }
70 -re ".*$gdb_prompt $" { fail "info b" }
71 }
72
73 # Test some other "clear" combinations
74 #
75 gdb_test "b 1" ".*Breakpoint.*4.*" ""
76 gdb_test "b 8" ".*Note.*also.*Breakpoint.*5.*" ""
77 gdb_test "cle 8" ".*Deleted breakpoint 5.*" "Only cleared 1 by line"
78
79 send_gdb "inf line 8\n"
80 gdb_expect {
81 -re ".*address (0x\[0-9a-fA-F]*).*$gdb_prompt $" {
82 set line_eight $expect_out(1,string)
83 gdb_test "b 8" ".*Breakpoint.*6.*" ""
84 gdb_test "cle *$line_eight" ".*Deleted breakpoints 6 4.*" "Clear 2 by address"
85 }
86 -re ".*$gdb_prompt $" {
87 fail "need to fix test for new compile outcome"
88 }
89 }
90
91 send_gdb "inf line 9\n"
92 gdb_expect {
93 -re ".*address (0x\[0-9a-fA-F]*).*$gdb_prompt $" {
94 set line_nine $expect_out(1,string)
95 gdb_test "b 9" ".*Breakpoint.*7.*" ""
96 gdb_test "b *$line_nine" ".*Note.*also.*Breakpoint.*8.*" ""
97 gdb_test "c" ".*Breakpoint.*7.*callee.*9.*" ""
98 gdb_test "cle" ".*Deleted breakpoints 8 7.*" "Clear 2 by default"
99 }
100 -re ".*$gdb_prompt $" {
101 fail "need to fix test for new compile outcome"
102 }
103 }
104
105 send_gdb "i b\n"
106 gdb_expect {
107 -re ".*breakpoint.*breakpoint.*$gdb_prompt $" {
108 fail "didn't clear bps"
109 }
110 -re ".*3.*main.*26.*$gdb_prompt $" {
111 pass "all set to continue"
112 }
113 -re ".*$gdb_prompt $" {
114 fail "missing bp at end"
115 }
116 }
117
118
119 # See if we can step out with control. The "1 2 3" stuff
120 # is output from the program.
121 #
122 gdb_test "cont" ".*Breakpoint.*26.*" ""
123 gdb_test "next" ".*1 2 7 14 23 34 47 62 79 Goodbye!.*27.*" "Step to return"
124
125 set old_timeout $timeout
126 set timeout 50
127 send_gdb "next\n"
128 gdb_expect {
129 -re "27.*$gdb_prompt $" {
130 # sometimes we stop at the closing brace, if so, do another next
131 send_gdb "next\n"
132 gdb_expect {
133 -re ".*Unable to find return pc for this frame.*$gdb_prompt $" {
134 fail "Old bug came back!"
135 gdb_test "n" ".*" ""
136 }
137 -re ".*in.*start.*$gdb_prompt $" {
138 pass "step out of main"
139 }
140 timeout { fail "hang or timeout on step at end 2" }
141 }
142 }
143 -re ".*Unable to find return pc for this frame.*$gdb_prompt $" {
144 fail "Old bug came back!"
145 gdb_test "n" ".*" ""
146 }
147 -re ".*in.*start.*$gdb_prompt $" {
148 pass "step out of main"
149 }
150 timeout { fail "hang or timeout on step at end 1" }
151 }
152
153 gdb_test "n" ".*Single.*Program exited.*" "step to end of run"
154 set timeout $old_timeout
155
156 gdb_test "n" ".*The program is not being run.*" "don't step after run"
157
158 set exec_output [remote_exec host "ls core"]
159
160 if [ regexp "core not found" $exec_output] {
161 pass "No core dumped on quit"
162 } else {
163 if [ regexp "No such file or directory" $exec_output] {
164 pass "ls: core: No core dumped on quit"
165 } else {
166 remote_exec build "rm -f core"
167 fail "Core dumped on quit"
168 }
169 }
170
171 #remote_exec build "rm -f ${binfile}"
172 return 0
173
174
175
176