Commit | Line | Data |
---|---|---|
c906108c SS |
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 | # smoke.exp -- Expect script to test gdb before checkins | |
21 | ||
22 | # use this to debug: | |
23 | # | |
24 | #log_user 1 | |
25 | ||
26 | if $tracelevel then { | |
27 | strace $tracelevel | |
28 | } | |
29 | ||
30 | set testfile smoke | |
31 | set testfile1 smoke1 | |
32 | set c_srcfile ${srcdir}/${subdir}/${testfile}.c | |
33 | set cpp_srcfile ${srcdir}/${subdir}/${testfile}.cc | |
34 | set binfile ${objdir}/${subdir}/${testfile} | |
35 | set binfile1 ${objdir}/${subdir}/${testfile1} | |
36 | ||
37 | #remote_exec build "rm -f ${binfile}" | |
38 | remote_exec build "rm -f core" | |
39 | ||
40 | # "C" section, using source copied from "step-test.c" from "gdb.base" | |
41 | # | |
42 | if { [gdb_compile "${c_srcfile}" "${binfile}" executable {debug}] != "" } { | |
43 | gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." | |
44 | } | |
45 | ||
46 | gdb_exit | |
47 | gdb_start | |
48 | gdb_reinitialize_dir $srcdir/$subdir | |
49 | gdb_load ${binfile} | |
50 | ||
51 | # Some basic tests | |
52 | # | |
53 | gdb_test "tb main" ".*Breakpoint 1 at.*line 15.*" "temp breakpoint" | |
54 | gdb_test "b callee" ".*Breakpoint 2 at.*line 6.*" "breakpoint" | |
55 | gdb_test "l 10" ".*10.*int main.*11.*int w,x,y,z;.*12.*int a.*" "list" | |
56 | gdb_test "c" ".*The program is not being run.*" "catch error" | |
57 | gdb_test "r" ".*Starting program.*main.*15.*" "hit bp" | |
58 | gdb_test "hel r" ".*Start debugged program.*without arguments.*" "help" | |
59 | gdb_test "n" ".*x = 1;.*" "next" | |
60 | gdb_test "s" ".*y = 2;.*" "step" | |
61 | gdb_test "p/t y" ".* = 1.*" "print y in binary" | |
62 | gdb_test "p 1+2*3+4" ".* = 11.*" "calculate" | |
63 | gdb_test "p/t 1+2*3+4" ".* = 1011.*" "binary" | |
64 | ||
65 | # Note: accept either "Watchpoint" or "Hardware watchpoint"; | |
66 | # 10.20 can't do the hardware watch. The hardware kind | |
67 | # triggers one line earlier than the regular kind. | |
68 | # | |
69 | gdb_test "wat y" ".*atchpoint.*y.*" "set watch" | |
70 | gdb_test "c" ".*atchpoint.*Old.*= .*New.*= 2.*1\[78\].*" "continue, hit watch" | |
71 | ||
72 | gdb_test "set glob=999" ".*.*" "set" | |
73 | gdb_test "p glob" ".*= 999.*.*" "print glob" | |
74 | gdb_test "p/x glob" ".*= 0x3e7.*" "hex" | |
75 | gdb_test "c" ".*atchpoint.*Old.*= 2.*New.*= 6.*2\[12\].*" "continue, 2nd hit watch" | |
76 | gdb_test "d 5" "No breakpoint number 5." "del non existing watch" | |
77 | gdb_test "c" ".*Breakpoint.*callee.*6.*" "hit bp" | |
78 | gdb_test "bt" ".*callee.*6.*main.*25.*" "bt" | |
79 | gdb_test "fin" ".*Run till exit.*callee.*Value returned.*0.*" "finish" | |
80 | gdb_test "c" ".*Breakpoint.*callee.*6.*" "hit bp again" | |
81 | gdb_test "cle" ".*Deleted breakpoint.*" "clear" | |
82 | gdb_test "wat glob" ".*atchpoint.*glob.*" "set 2nd watch" | |
83 | gdb_test "i wat" ".*" "" | |
84 | gdb_test "whe" ".*" "" | |
85 | ||
86 | # ??rehrauer: We're now disabling watchpoints while an interactive | |
87 | # call is "in flight". When/if we can teach gdb how to unwind through | |
88 | # the call dummy frame, we can then allow watches during calls, and | |
89 | # also then restore this testpoint to the original, commented-out form. | |
90 | # | |
91 | gdb_test "call callee()" ".*\[0-9\]* = 0.*" "call, didn't hit watch" | |
92 | #gdb_test "call callee()" ".*atchpoint.*Old.*= 1000.*New.*= 1001.*\[67\].*being debug.*is done.*" "call, hit watch" | |
93 | ||
94 | gdb_test "d 4" ".*" "del watch 2" | |
95 | gdb_test "d 3" ".*" "del watch 1" | |
96 | gdb_test "info break" "No breakpoints or watchpoints." | |
97 | # since we have deleted all the watchpoints this test is useless | |
98 | #gdb_test "c" ".*Continuing.*" "end call" | |
99 | gdb_test "c" ".*Program exited normally.*" "pgm exit" | |
100 | ||
101 | # Check for production of a core file | |
102 | # | |
103 | #set exec_output [execute_anywhere "ls core"] | |
104 | set exec_output [remote_exec build "ls core"] | |
105 | ||
106 | if [ regexp "core not found" $exec_output] { | |
107 | pass "No core dumped on quit" | |
108 | } else { | |
109 | if [ regexp "No such file or directory" $exec_output] { | |
110 | pass "ls: core: No core dumped on quit" | |
111 | } else { | |
112 | remote_exec build "rm -f core" | |
113 | fail "Core dumped on quit" | |
114 | } | |
115 | } | |
116 | ||
117 | ||
118 | #======================================== | |
119 | # | |
120 | # "C++" section, using source copied from "misc.cc" from "gdb.c++" | |
121 | # | |
122 | ||
123 | # | |
124 | #remote_exec build "rm -f ${binfile}" | |
125 | #remote_exec build "CC -g -o ${binfile} ${cpp_srcfile}" | |
126 | if {[gdb_compile "${cpp_srcfile}" "${binfile1}" executable {c++ debug}] != ""} { | |
127 | gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." | |
128 | } | |
129 | ||
130 | gdb_exit | |
131 | gdb_start | |
132 | gdb_reinitialize_dir $srcdir/$subdir | |
133 | gdb_load ${binfile1} | |
134 | ||
135 | # Tests, some copied from misc.exp. | |
136 | # | |
137 | ||
138 | # See what language gdb thinks main() is, prior to reading full symbols. | |
139 | # I think this fails for COFF targets. | |
140 | setup_xfail "a29k-*-udi" | |
141 | send_gdb "show language\n" | |
142 | gdb_expect { | |
143 | -re ".* source language is \"auto; currently c\\+\\+\".*$gdb_prompt $" { | |
144 | pass "deduced language is C++, before full symbols" | |
145 | } | |
146 | -re ".*$gdb_prompt $" { fail "source language not correct for C++ (psymtabs only)"} | |
147 | return | |
148 | ||
149 | timeout { fail "can't show language (timeout)"} | |
150 | return | |
151 | } | |
152 | ||
153 | gdb_test "b main" ".*Breakpoint 1 at.*" "" | |
154 | gdb_test "r" ".*Starting program.*Breakpoint 1.*" "run to main" | |
155 | gdb_test "ptype Foo" ".*type = class Foo.*static int st;.*int operator.*" "ptype" | |
156 | gdb_test "step" ".*inheritance1.*" "step" | |
157 | gdb_test "ptype g_anon_union" ".*anon_union.*union.*int a;.*" "anon" | |
158 | gdb_test "p g_E" ".*class D.*class B.*class A.*class C.*class A.*x = 0.*" "print inherited class " | |
159 | gdb_test "p g_E.x = 99" ".*warn.*x ambiguous; using E::x. Use a cast to disambig.*99.*" "set via print" | |
160 | gdb_test "c" ".*Program exited.*" "run to end" | |
161 | ||
162 | gdb_exit | |
163 | ||
164 | # Check for production of a core file | |
165 | # | |
166 | #set exec_output [execute_anywhere "ls core"] | |
167 | set exec_output [remote_exec build "ls core"] | |
168 | if [ regexp "core not found" $exec_output] { | |
169 | pass "No core dumped on quit" | |
170 | } else { | |
171 | if [ regexp "No such file or directory" $exec_output] { | |
172 | pass "ls: core: No core dumped on quit" | |
173 | } else { | |
174 | remote_exec build "rm -f core" | |
175 | fail "Core dumped on quit" | |
176 | } | |
177 | } | |
178 | ||
179 | # execute_anywhere "rm -f ${binfile1}" | |
180 | # | |
181 | return 0 |