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