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
26 set testfile1 "average"
28 set testfile "dbx-test"
29 set binfile1 ${objdir}/${subdir}/${testfile1}
30 set binfile2 ${objdir}/${subdir}/${testfile2}
31 set binfile ${objdir}/${subdir}/${testfile}
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."
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."
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."
47 if [get_compiler_info ${binfile}] {
50 if {[skip_hp_tests $gcc_compiled]} then { continue }
52 proc dbx_reinitialize_dir { subdir } {
57 -re "Reinitialize source path to empty.*y or n. " {
60 -re "Source directories searched.*$gdb_prompt $" {
61 send_gdb "use $subdir\n"
63 -re "Source directories searched.*$gdb_prompt $" {
64 verbose "Dir set to $subdir"
66 -re ".*$gdb_prompt $" {
67 perror "Dir \"$subdir\" failed."
71 -re ".*$gdb_prompt $" {
72 perror "Dir \"$subdir\" failed."
76 -re ".*$gdb_prompt $" {
77 perror "Dir \"$subdir\" failed."
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?).
90 # This means that tests before use "file" to load a target, and
91 # tests afterwards use the pair "symbol-file" "exec-file".
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".
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").
103 proc gdb_file_cmd {arg } {
110 upvar timeout timeout
112 send_gdb "symbol-file $arg\n"
114 -re "Reading symbols from.*done.*$gdb_prompt $" {
115 verbose "\t\tLoaded $arg into the $GDB"
116 send_gdb "exec-file $arg\n"
119 -re "has no symbol-table.*$gdb_prompt $" {
120 perror "$arg wasn't compiled with \"-g\""
123 -re "A program is being debugged already.*Kill it.*y or n. $" {
125 verbose "\t\tKilling previous program being debugged"
128 -re "Load new symbol table from \".*\".*y or n. $" {
131 -re "Reading symbols from.*done.*$gdb_prompt $" {
132 verbose "\t\tLoaded $arg with new symbol table into $GDB"
136 perror "(timeout) Couldn't load $arg, other program already loaded."
141 -re ".*No such file or directory.*$gdb_prompt $" {
142 perror "($arg) No such file or directory\n"
145 -re "$gdb_prompt $" {
146 perror "couldn't load $arg into $GDB."
150 perror "couldn't load $arg into $GDB (timed out)."
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)."
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>"
177 proc test_assign { } {
179 gdb_test "assign first=1" ""
180 gdb_test "print first" ".1 = 1"
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\\\];"
196 gdb_test "func sum" "'sum' not within current stack frame\."
197 gdb_test "stop in sum" "Breakpoint.*at.*: file.*sum\.c, line 11\."
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\\);"
202 # Start with a fresh gdb.
206 set saved_gdbflags $GDBFLAGS
208 set GDBFLAGS "$GDBFLAGS --dbx"
210 dbx_reinitialize_dir $srcdir/$subdir
212 send_gdb "set width 0\n"
213 gdb_expect -re "$gdb_prompt $"
217 gdb_test "file average.c:1" "1\[ \t\]+/. This is a sample program.*"
221 set GDBFLAGS $saved_gdbflags