import gdb-19990422 snapshot
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.hp / dbx.exp
1 # Copyright (C) 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
21 if $tracelevel then {
22 strace $tracelevel
23 }
24
25 if { [skip_hp_tests] } then { continue }
26
27 set testfile1 "average"
28 set testfile2 "sum"
29 set testfile "dbx-test"
30 set binfile1 ${objdir}/${subdir}/${testfile1}
31 set binfile2 ${objdir}/${subdir}/${testfile2}
32 set binfile ${objdir}/${subdir}/${testfile}
33
34
35
36 if { [gdb_compile "${srcdir}/${subdir}/average.c" "${binfile1}.o" object {debug}] != "" } {
37 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
38 }
39
40 if { [gdb_compile "${srcdir}/${subdir}/sum.c" "${binfile2}.o" object {debug}] != "" } {
41 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
42 }
43
44 if { [gdb_compile "${binfile1}.o ${binfile2}.o" ${binfile} executable {debug}] != "" } {
45 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
46 }
47
48 if [get_compiler_info ${binfile}] {
49 return -1;
50 }
51 if { $gcc_compiled } then { continue }
52
53 proc dbx_reinitialize_dir { subdir } {
54 global gdb_prompt
55
56 send_gdb "use\n"
57 gdb_expect {
58 -re "Reinitialize source path to empty.*y or n. " {
59 send_gdb "y\n"
60 gdb_expect {
61 -re "Source directories searched.*$gdb_prompt $" {
62 send_gdb "use $subdir\n"
63 gdb_expect {
64 -re "Source directories searched.*$gdb_prompt $" {
65 verbose "Dir set to $subdir"
66 }
67 -re ".*$gdb_prompt $" {
68 perror "Dir \"$subdir\" failed."
69 }
70 }
71 }
72 -re ".*$gdb_prompt $" {
73 perror "Dir \"$subdir\" failed."
74 }
75 }
76 }
77 -re ".*$gdb_prompt $" {
78 perror "Dir \"$subdir\" failed."
79 }
80 }
81 }
82
83 # In "testsuite/config/unix-gdb.exp", the routine "gdb_load"
84 # is defined as "gdb_file_cmd". The binding of "gdb_file_cmd"
85 # is done at invocation time. Before this file is processed,
86 # it binds to the definition in "testsuite/lib/gdb.exp"; after
87 # this file is processed, it binds to this definition.
88 # TCL lets us overrides a previous routine definition without a
89 # warning (isn't that special?).
90 #
91 # This means that tests before use "file" to load a target, and
92 # tests afterwards use the pair "symbol-file" "exec-file".
93 #
94 # I'm leaving it as it is for now because at the moment it
95 # is the only test we have of the use of the combination of
96 # "symbol-file" and "exec-file" to load a debugging target (the
97 # other definition uses "file".
98 #
99 # Symbol-file and exec-file should be tested explicitly, not
100 # as a side effect of running a particular test (in this case,
101 # "testsuite/gdb.compat/dbx.exp").
102 #
103 #
104 proc gdb_file_cmd {arg } {
105 global verbose
106 global loadpath
107 global loadfile
108 global GDB
109 global gdb_prompt
110 global spawn_id
111 upvar timeout timeout
112
113 send_gdb "symbol-file $arg\n"
114 gdb_expect {
115 -re "Reading symbols from.*done.*$gdb_prompt $" {
116 verbose "\t\tLoaded $arg into the $GDB"
117 send_gdb "exec-file $arg\n"
118 return 0
119 }
120 -re "has no symbol-table.*$gdb_prompt $" {
121 perror "$arg wasn't compiled with \"-g\""
122 return -1
123 }
124 -re "A program is being debugged already.*Kill it.*y or n. $" {
125 send_gdb "y\n"
126 verbose "\t\tKilling previous program being debugged"
127 exp_continue
128 }
129 -re "Load new symbol table from \".*\".*y or n. $" {
130 send_gdb "y\n"
131 gdb_expect {
132 -re "Reading symbols from.*done.*$gdb_prompt $" {
133 verbose "\t\tLoaded $arg with new symbol table into $GDB"
134 return 0
135 }
136 timeout {
137 perror "(timeout) Couldn't load $arg, other program already loaded."
138 return -1
139 }
140 }
141 }
142 -re ".*No such file or directory.*$gdb_prompt $" {
143 perror "($arg) No such file or directory\n"
144 return -1
145 }
146 -re "$gdb_prompt $" {
147 perror "couldn't load $arg into $GDB."
148 return -1
149 }
150 timeout {
151 perror "couldn't load $arg into $GDB (timed out)."
152 return -1
153 }
154 eof {
155 # This is an attempt to detect a core dump, but seems not to
156 # work. Perhaps we need to match .* followed by eof, in which
157 # expect does not seem to have a way to do that.
158 perror "couldn't load $arg into $GDB (end of file)."
159 return -1
160 }
161 }
162 }
163
164 #
165 #test_breakpoints
166 #
167 proc test_breakpoints { } {
168 gdb_test "stop in main" "Breakpoint.*at.*: file.*average\.c, line 31\."
169 gdb_test "status" "Num.*Type.*Disp.*Enb.*Address.*What\r\n1\[ \r\]+breakpoint\[ \r\]+keep y.*in main at.*average\.c:31.*"
170 gdb_test "stop at 36" "Breakpoint.*at.*: file.*average\.c, line 36.*"
171 gdb_test "stop in 36" "Usage: stop in <function . address>"
172 gdb_test "stop at main" "Usage: stop at <line>"
173 }
174
175 #
176 #test_assign
177 #
178 proc test_assign { } {
179 gdb_test "run" ""
180 gdb_test "assign first=1" ""
181 gdb_test "print first" ".1 = 1"
182 }
183
184 #
185 #test_whereis
186 #
187 proc test_whereis { } {
188 gdb_test "whereis my_list" "All variables matching regular expression \"my_list\":\r\n\r\nFile.*average\.c:\r\nstatic int my_list\\\[10\\\];"
189 }
190
191 #
192 #test_func
193 #
194 proc test_func { } {
195 gdb_test "cont" ""
196 gdb_test "step" ""
197 gdb_test "func sum" "'sum' not within current stack frame\."
198 gdb_test "stop in sum" "Breakpoint.*at.*: file.*sum\.c, line 11\."
199 gdb_test "cont"
200 gdb_test "func print_average" ".*in print_average.*\\(list=.*, low=0, high=6\\).*at.*average\.c:17\r\n17\[ \t\]+total = sum\\(list, low, high\\);"
201 }
202
203 # Start with a fresh gdb.
204
205 gdb_exit
206 global GDBFLAGS
207 set saved_gdbflags $GDBFLAGS
208
209 set GDBFLAGS "$GDBFLAGS --dbx"
210 gdb_start
211 dbx_reinitialize_dir $srcdir/$subdir
212 gdb_load ${binfile}
213 send_gdb "set width 0\n"
214 gdb_expect -re "$gdb_prompt $"
215 test_breakpoints
216 test_assign
217 test_whereis
218 gdb_test "file average.c:1" "1\[ \t\]+/. This is a sample program.*"
219 test_func
220
221 gdb_exit
222 set GDBFLAGS $saved_gdbflags
223 return 0
This page took 0.040578 seconds and 4 git commands to generate.