1 # Copyright (C) 1998 Free Software Foundation, Inc.
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.
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.
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. */
17 # Please email any bugs, comments, and/or additions to this file to:
18 # bug-gdb@prep.ai.mit.edu
25 if { [skip_hp_tests] } then { continue }
27 set testfile1 "average"
29 set testfile "dbx-test"
30 set binfile1 ${objdir}/${subdir}/${testfile1}
31 set binfile2 ${objdir}/${subdir}/${testfile2}
32 set binfile ${objdir}/${subdir}/${testfile}
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."
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."
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."
48 if [get_compiler_info ${binfile}] {
51 if { $gcc_compiled } then { continue }
53 proc dbx_reinitialize_dir { subdir } {
58 -re "Reinitialize source path to empty.*y or n. " {
61 -re "Source directories searched.*$gdb_prompt $" {
62 send_gdb "use $subdir\n"
64 -re "Source directories searched.*$gdb_prompt $" {
65 verbose "Dir set to $subdir"
67 -re ".*$gdb_prompt $" {
68 perror "Dir \"$subdir\" failed."
72 -re ".*$gdb_prompt $" {
73 perror "Dir \"$subdir\" failed."
77 -re ".*$gdb_prompt $" {
78 perror "Dir \"$subdir\" failed."
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?).
91 # This means that tests before use "file" to load a target, and
92 # tests afterwards use the pair "symbol-file" "exec-file".
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".
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").
104 proc gdb_file_cmd {arg } {
111 upvar timeout timeout
113 send_gdb "symbol-file $arg\n"
115 -re "Reading symbols from.*done.*$gdb_prompt $" {
116 verbose "\t\tLoaded $arg into the $GDB"
117 send_gdb "exec-file $arg\n"
120 -re "has no symbol-table.*$gdb_prompt $" {
121 perror "$arg wasn't compiled with \"-g\""
124 -re "A program is being debugged already.*Kill it.*y or n. $" {
126 verbose "\t\tKilling previous program being debugged"
129 -re "Load new symbol table from \".*\".*y or n. $" {
132 -re "Reading symbols from.*done.*$gdb_prompt $" {
133 verbose "\t\tLoaded $arg with new symbol table into $GDB"
137 perror "(timeout) Couldn't load $arg, other program already loaded."
142 -re ".*No such file or directory.*$gdb_prompt $" {
143 perror "($arg) No such file or directory\n"
146 -re "$gdb_prompt $" {
147 perror "couldn't load $arg into $GDB."
151 perror "couldn't load $arg into $GDB (timed out)."
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)."
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>"
178 proc test_assign { } {
180 gdb_test "assign first=1" ""
181 gdb_test "print first" ".1 = 1"
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\\\];"
197 gdb_test "func sum" "'sum' not within current stack frame\."
198 gdb_test "stop in sum" "Breakpoint.*at.*: file.*sum\.c, line 11\."
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\\);"
203 # Start with a fresh gdb.
207 set saved_gdbflags $GDBFLAGS
209 set GDBFLAGS "$GDBFLAGS --dbx"
211 dbx_reinitialize_dir $srcdir/$subdir
213 send_gdb "set width 0\n"
214 gdb_expect -re "$gdb_prompt $"
218 gdb_test "file average.c:1" "1\[ \t\]+/. This is a sample program.*"
222 set GDBFLAGS $saved_gdbflags