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