diff options
Diffstat (limited to 'gdb/testsuite')
-rw-r--r-- | gdb/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/list.exp | 887 |
2 files changed, 892 insertions, 0 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index c852c36..3ae953c 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,8 @@ +Mon Dec 19 00:32:55 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de) + + * gdb.base/list.exp: Correct some alternate expect patterns + to reflect changes in list1.c. + Sat Dec 17 14:20:03 1994 Jim Kingdon (kingdon@lioth.cygnus.com) * TODO: Add item regarding large frames. diff --git a/gdb/testsuite/gdb.base/list.exp b/gdb/testsuite/gdb.base/list.exp new file mode 100644 index 0000000..e7fe615 --- /dev/null +++ b/gdb/testsuite/gdb.base/list.exp @@ -0,0 +1,887 @@ +# Copyright (C) 1992, 1994 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +# Please email any bugs, comments, and/or additions to this file to: +# bug-gdb@prep.ai.mit.edu + +# This file was written by Fred Fish. (fnf@cygnus.com) + +if $tracelevel then { + strace $tracelevel +} + +set prms_id 0 +set bug_id 0 + +set binfile "list" +set srcfile $binfile.c + +if ![file exists $objdir/$subdir/$binfile] then { + perror "$objdir/$subdir/$binfile does not exist." + return 0 +} + +# +# Local utility proc just to set and verify listsize +# Return 1 if success, 0 if fail. +# + +proc set_listsize { arg } { + global prompt + + send "set listsize $arg\n" + expect { + -re "set listsize $arg\r\n$prompt $" {} + -re ".*$prompt $" { fail "setting listsize to $arg" ; return 0 } + timeout { fail "set listsize to $arg (timeout)" ; return 0 } + } + + send "show listsize\n" + expect { + -re "Number of source lines .* is $arg.\r\n.*$prompt $" {} + -re ".*$prompt $" { fail "listsize not set to $arg" ; return 0 } + timeout { fail "show listsize (timeout)" ; return 0 } + } + return 1 +} + +# +# Test display of listsize lines around a given line number. +# + +proc test_listsize {} { + global prompt + + # Show default size + + send "show listsize\n" + expect { + -re "Number of source lines gdb will list by default is 10.*$prompt $" { + pass "show default list size" + } + -re ".*$prompt $" { + fail "show default listsize (10)" + } + timeout { + fail "show listsize (timeout)" + } + } + + # Show the default lines + + # This doesn't work for COFF targets. + setup_xfail "a29k-*-udi" + send "list\n" + expect { + -re "1\[ \t\]+#include \"list0.h\".*10\[ \t\]+foo .x\[+)\]+;\r\n$prompt $" { + pass "show default lines around main" + } + -re ".*$prompt $" { + fail "list default lines around main" + } + timeout { + fail "list default lines around main (timeout)" + } + } + + # Ensure we can limit printouts to one line + + if [ set_listsize 1 ] then { + setup_xfail "*-*-*" + send "list 1\n" + expect { + -re "1\[ \t\]+#include \"list0.h\"\r\n$prompt $" { + pass "list line 1 with listsize 1" + } + -re "list 1\r\n$prompt $" { + fail "list line 1 with listsize 1" + } + -re ".*$prompt $" { + fail "list line 1 with listsize 1" + } + timeout { + fail "list line 1 with listsize 1 (timeout)" + } + } + + setup_xfail "*-*-*" + send "list 2\n" + expect { + -re "2\[ \t\]+\r\n$prompt $" { + pass "list line 2 with listsize 1" + } + -re "list 2\r\n$prompt $" { + fail "list line 2 with listsize 1" + } + -re ".*$prompt $" { + fail "list line 2 with listsize 1" + } + timeout { + fail "list line 2 with listsize 1 (timeout)" + } + } + } + + # Try just two lines + + if [ set_listsize 2 ] then { + send "list 1\n" + expect { + -re "1\[ \t\]+#include \"list0.h\"\r\n$prompt $" { + pass "list line 1 with listsize 2" + } + -re ".*$prompt $" { + fail "list line 1 with listsize 2" + } + timeout { + fail "list line 1 with listsize 2 (timeout)" + } + } + + send "list 2\n" + expect { + -re "1\[ \t\]+#include \"list0.h\"\r\n2\[ \t\]+\r\n$prompt $" { + pass "list line 2 with listsize 2" + } + -re ".*$prompt $" { + fail "list line 2 with listsize 2" + } + timeout { + fail "list line 2 with listsize 2 (timeout)" + } + } + + send "list 3\n" + expect { + -re "2\[ \t\]+\r\n3\[ \t\]+main \[)(\]+\r\n$prompt $" { + pass "list line 3 with listsize 2" + } + -re ".*$prompt $" { + fail "list line 3 with listsize 2" + } + timeout { + fail "list line 3 with listsize 2 (timeout)" + } + } + } + + # Try small listsize > 1 that is an odd number + + if [ set_listsize 3 ] then { + setup_xfail "*-*-*" + send "list 1\n" + expect { + -re "1\[ \t\]+#include \"list0.h\"2\[ \t\]+\r\n$prompt $" { + pass "list line 1 with listsize 3" + } + -re "1\[ \t\]+#include \"list0.h\"\r\n$prompt $" { + fail "list line 1 with listsize 3" + } + -re ".*$prompt $" { + fail "list line 1 with listsize 3" + } + timeout { + fail "list line 1 with listsize 3 (timeout)" + } + } + + setup_xfail "*-*-*" + send "list 2\n" + expect { + -re "1\[ \t\]+#include \"list0.h\".*3\[ \t\]+main \[)(\]+\r\n$prompt $" { + pass "list line 2 with listsize 3" + } + -re "1\[ \t\]+#include \"list0.h\"\r\n2\[ \t\]+\r\n$prompt $" { + fail "list line 2 with listsize 3" + } + -re ".*$prompt $" { + fail "list line 2 with listsize 3" + } + timeout { + fail "list line 2 with listsize 3 (timeout)" + } + } + + setup_xfail "*-*-*" + send "list 3\n" + expect { + -re "2\[ \t\]+\r\n3\[ \t\]+main \[(\]+\[)\]+\r\n4\[ \t\]+\{\r\n$prompt $" { + pass "list line 3 with listsize 3" + } + -re "2\[ \t\]+\r\n3\[ \t\]+main \[)(\]+\r\n$prompt $" { + fail "list line 3 with listsize 3" + } + -re ".*$prompt $" { + fail "list line 3 with listsize 3" + } + timeout { + fail "list line 3 with listsize 3 (timeout)" + } + } + } + + # Try small listsize > 2 that is an even number. + + if [ set_listsize 4 ] then { + send "list 1\n" + expect { + -re "1\[ \t\]+#include \"list0.h\"\r\n2\[ \t\]+\r\n$prompt $" { + pass "list line 1 with listsize 4" + } + -re ".*$prompt $" { + fail "list line 1 with listsize 4" + } + timeout { + fail "list line 1 with listsize 4 (timeout)" + } + } + + send "list 2\n" + expect { + -re "1\[ \t\]+#include \"list0.h\".*3\[ \t\]+main \[)(\]+\r\n$prompt $" { + pass "list line 2 with listsize 4" + } + -re ".*$prompt $" { + fail "list line 2 with listsize 4" + } + timeout { + fail "list line 2 with listsize 4 (timeout)" + } + } + + send "list 3\n" + expect { + -re "1\[ \t\]+#include \"list0.h\".*4\[ \t\]+\{\r\n$prompt $" { + pass "list line 3 with listsize 4" + } + -re ".*$prompt $" { + fail "list line 3 with listsize 4" + } + timeout { + fail "list line 3 with listsize 4 (timeout)" + } + } + + send "list 4\n" + expect { + -re "2\[ \t\]+\r\n.*5\[ \t\]+int x;\r\n$prompt $" { + pass "list line 4 with listsize 4" + } + -re ".*$prompt $" { + fail "list line 4 with listsize 4" + } + timeout { + fail "list line 4 with listsize 4 (timeout)" + } + } + } + + # Try a size larger than the entire file. + + if [ set_listsize 100 ] then { + send "list 1\n" + expect { + -re "1\[ \t\]+#include \"list0.h\".*\r\n39\[ \t\]+\}\r\n$prompt $" { + pass "list line 1 with listsize 100" + } + timeout { + fail "list line 1 with listsize 100" + } + } + + send "list 10\n" + expect { + -re "1\[ \t\]+#include \"list0.h\".*\r\n39\[ \t\]+\}\r\n$prompt $" { + pass "list line 1 with listsize 100" + } + timeout { + fail "list line 1 with listsize 100" + } + } + } + + # Try listsize of 0 which suppresses printing. + + send "set listsize 0\n" + expect { + -re "set listsize 0\r\n$prompt $" { + setup_xfail "*-*-*" + send "show listsize\n" + expect { + -re "Number of source lines .* is 0.\r\n.*$prompt $" { + pass "listsize of 0 displays as 0" + } + -re "Number of source lines .* is unlimited.\r\n.*$prompt $" { + fail "listsize of 0 displays as unlimited" + } + -re ".*$prompt $" { + fail "listsize not set to unlimited (0)" + } + timeout { + fail "show listsize (timeout)" + } + } + send "list 1\n" + expect { + -re "list 1\r\n$prompt $" { + pass "listsize of 0 suppresses output" + } + -re ".*$prompt $" { + fail "listsize of 0 should suppress output" + } + timeout { + fail "listsize of 0 suppresses output (timeout)" + } + } + } + -re ".*$prompt $" { + fail "setting listsize to 0" + } + timeout { + fail "set listsize to 0 (timeout)" + } + } + + # Try listsize of -1 which is special, and means unlimited. + + send "set listsize -1\n" + expect { + -re "set listsize -1\r\n$prompt $" { + send "show listsize\n" + expect { + -re "Number of source lines .* is unlimited.\r\n.*$prompt $" { + pass "listsize of -1 displays as unlimited" + } + -re ".*$prompt $" { + fail "listsize not set to unlimited (-1)" + } + timeout { + fail "show listsize (timeout)" + } + } + setup_xfail "*-*-*" + send "list 1\n" + expect { + -re "1\[ \t\]+#include .*\r\n39\[ \t\]+\}\r\n$prompt $" { + pass "list line 1 with unlimited listsize" + } + -re "list 1\r\n$prompt $" { + fail "listsize of -1 (unlimited) suppresses output" + } + timeout { + fail "list line 1 with unlimited listsize" + } + } + } + -re ".*$prompt $" { + fail "setting listsize to -1" + } + timeout { + fail "set listsize to -1 (timeout)" + } + } +} + +# +# Test "list filename:number" for C include file +# + +proc test_list_include_file {} { + global prompt + + # FIXME This fails on DWARF. + setup_xfail "*-*-sysv4*" + # FIXME Fails for COFF as well, I think. + setup_xfail "a29k-*-udi" + send "list list0.h:1\n" + expect { + -re "1\[ \t\]+/\[*\]+ An include file .*5\[ \t\]+foo \[(\]+x\[)\]+\r\n$prompt $" { + pass "list line 1 in include file" + } + -re "No source file named list0.h.\r\n$prompt $" { + fail "list line 1 in include file" + } + -re ".*$prompt $" { + fail "list line 1 in include file" + } + timeout { + fail "list line 1 in include file (timeout)" + } + } + + # FIXME fails on DWARF + setup_xfail "*-*-sysv4*" + # FIXME Fails for COFF as well, I think. + setup_xfail "a29k-*-udi" + send "list list0.h:100\n" + expect { + -re "Line number 95 out of range; .*list0.h has 36 lines.\r\n$prompt $" { + pass "list message for lines past EOF" + } + -re "No source file named list0.h.\r\n$prompt $" { + fail "list message for lines past EOF" + } + -re ".*$prompt $" { + fail "list message for lines past EOF" + } + timeout { + fail "list message for lines past EOF (timeout)" + } + } +} + +# +# Test "list filename:number" for C source file +# + +proc test_list_filename_and_number {} { + global prompt + + set testcnt 0 + + send "list list0.c:1\n" + expect { + -re "1\[ \t\]+#include \"list0.h\".*5\[ \t\]+int x;\r\n$prompt $" { + incr testcnt + } + -re ".*$prompt $" { fail "list list0.c:1" ; return } + timeout { fail "list list0.c:1" ; return } + } + send "list list0.c:10\n" + expect { + -re "5\[ \t\]+int x;.*14\[ \t\]+foo .x\[+)\]+;\r\n$prompt $" { + incr testcnt + } + -re ".*$prompt $" { fail "list list.c:10" ; return } + timeout { fail "list list.c:10" ; return } + } + send "list list1.c:1\n" + expect { + -re "1\[ \t\]+void.*5\[ \t\]+printf \[(\]+.*\[)\]+;\r\n$prompt $" { + incr testcnt + } + -re ".*$prompt $" { fail "list list1.c:1" ; return } + timeout { fail "list list1.c:1" ; return } + } + send "list list1.c:12\n" + expect { + -re "7\[ \t\]+long_line \[(\]+.*\[)\]+;.*14\[ \t\]+\}\r\n.*$prompt $" { + incr testcnt + } + -re ".*$prompt $" { fail "list list1.c:12" ; return } + timeout { fail "list list1.c:12" ; return } + } + pass "list filename:number ($testcnt tests)" +} + +# +# Test "list function" for C source file +# + +proc test_list_function {} { + global prompt + + # gcc appears to generate incorrect debugging information for code + # in include files, which breaks this test. + setup_xfail "rs6000-*-*" 1804 + setup_xfail "a29k-*-udi" + send "list main\n" + expect { + -re "1\[ \t\]+#include .*8\[ \t\]+foo \[(\]+.*\[)\]+;\r\n$prompt $" { + pass "list function in source file 1" + } + -re ".*$prompt $" { fail "list main" ; return } + timeout { fail "list main" ; return } + } + + # Ultrix gdb takes the second case below; it's also correct. + send "list bar\n" + expect { + -re "1\[ \t\]+void.*8\[ \t\]+\}\r\n$prompt $" { + pass "list function in source file 2" + } + -re "1\[ \t\]+void.*7\[ \t\]*long_line ..;\r\n$prompt $" { + pass "list function in source file 2" + } + -re ".*$prompt $" { fail "list bar" ; return } + timeout { fail "list bar" ; return } + } + + # Test "list function" for C include file + # Ultrix gdb is the second case, still correct. + # FIXME This fails on DWARF + setup_xfail "*-*-sysv4*" + send "list foo\n" + expect { + -re "2\[ \t\]+including file.*11\[ \t\]+bar \[(\]+.*\[)\]+;\r\n$prompt $" { + pass "list function in include file" + } + -re "1\[ \t\]+/. An include file.*10\[ \t\]+bar \[(\]+.*\[)\]+;\r\n$prompt $" { + pass "list function in include file" + } + -re ".*main \[)(\]+.*$prompt $" { + fail "list function in include file" + } + -re ".*$prompt $" { fail "list foo (in include file)" ; return } + timeout { fail "list foo (timeout)" ; return } + } +} + +proc test_list_forward {} { + global prompt + + set testcnt 0 + + send "list list0.c:10\n" + expect { + -re "5\[ \t\]+int x;.*14\[ \t\]+foo \[(\]+.*\[)\]+;\r\n$prompt $" { incr testcnt } + -re ".*$prompt $" { fail "list list0.c:10" ; return } + timeout { fail "list list0.c:10" ; return } + } + + send "list\n" + expect { + -re "15\[ \t\]+foo \[(\]+.*\[)\]+;.*24\[ \t\]+foo \[(\]+.*\[)\]+;\r\n$prompt $" { incr testcnt } + -re ".*$prompt $" { fail "list 15-24" ; return } + timeout { fail "list 15-24 (timeout)" ; return } + } + + send "list\n" + expect { + -re "25\[ \t\]+foo \[(\]+.*\[)\]+;.*34\[ \t\]+\r\n$prompt $" { incr testcnt } + -re ".*$prompt $" { fail "list 25-34" ; return } + timeout { fail "list 25-34 (timeout)" ; return } + } + + send "list\n" + expect { + -re "35\[ \t\]+static void.*39\[ \t\]+\}\r\n$prompt $" { incr testcnt } + -re ".*$prompt $" { fail "list 35-39" ; return } + timeout { fail "list 35-39 (timeout)" ; return } + } + + pass "successive list commands to page forward ($testcnt tests)" +} + +proc test_list_backwards {} { + global prompt + + set testcnt 0 + + send "list list0.c:30\n" + expect { + -re "25\[ \t\]+foo \[(\]+.*\[)\]+;.*34\[ \t\]+\r\n$prompt $" { incr testcnt } + -re ".*$prompt $" { fail "list list0.c:30" ; return } + timeout { fail "list list0.c:30" ; return } + } + + send "list -\n" + expect { + -re "15\[ \t\]+foo \[(\]+.*\[)\]+;.*24\[ \t\]+foo \[(\]+.*\[)\]+;\r\n$prompt $" { incr testcnt } + -re ".*$prompt $" { fail "list 15-24" ; return } + timeout { fail "list 15-24 (timeout)" ; return } + } + + send "list -\n" + expect { + -re "5\[ \t\]+int x;.*14\[ \t\]+foo \[(\]+.*\[)\]+;\r\n$prompt $" { incr testcnt } + -re ".*$prompt $" { fail "list 5-14" ; return } + timeout { fail "list 5-14 (timeout)" ; return } + } + + send "list -\n" + expect { + -re "1\[ \t\]+#include .*4\[ \t\]+\{\r\n$prompt $" { incr testcnt } + -re ".*$prompt $" { fail "list 1-4" ; return } + timeout { fail "list 1-4 (timeout)" ; return } + } + + pass "$testcnt successive \"list -\" commands to page backwards" +} + +# +# Test "list first,last" +# + +proc test_list_range {} { + global prompt + + send "list list0.c:2,list0.c:5\n" + expect { + -re "2\[ \t\]+\r\n3\[ \t\]+main \[)(\]+.*5\[ \t\]+int x;\r\n$prompt $" { + pass "list range; filename:line1,filename:line2" + } + -re ".*$prompt $" { fail "list list0.c:2,list0.c:5" } + timeout { fail "list list0.c:2,list0.c:5" } + } + + send "list 2,5\n" + expect { + -re "2\[ \t\]+\r\n3\[ \t\]+main \[)(\]+.*5\[ \t\]+int x;\r\n$prompt $" { + pass "list range; line1,line2" + } + -re ".*$prompt $" { fail "list 2,5" } + timeout { fail "list 2,5" } + } + + #send "list -1,6\n" + #expect { + #-re "Line number 0 out of range; .*list0.c has 39 lines.\r\n$prompt $" { + #pass "list range; lower bound negative" + #} + #-re ".*$prompt $" { fail "list -1,6" } + #timeout { fail "list -1,6" } + #} + + #send "list -100,-40\n" + #expect { + #-re "Line number -60 out of range; .*list0.c has 39 lines.\r\n$prompt $" { + #pass "list range; both bounds negative" + #} + #-re ".*$prompt $" { fail "-100,-40" } + #timeout { fail "-100,-40" } + #} + + send "list 30,40\n" + expect { + -re "30\[ \t\]+foo \[(\]+.*\[)\]+;.*39\[ \t\]+\}\r\n$prompt $" { + pass "list range; upper bound past EOF" + } + -re ".*$prompt $" { fail "list 30,40" } + timeout { fail "list 30,40" } + } + + send "list 40,100\n" + expect { + -re "Line number 40 out of range; .*list0.c has 39 lines.\r\n$prompt $" { + pass "list range; both bounds past EOF" + } + -re ".*$prompt $" { fail "40,100" } + timeout { fail "40,100" } + } + + send "list list0.c:2,list1.c:17\n" + expect { + -re "Specified start and end are in different files.\r\n$prompt $" { + pass "list range, must be same files" + } + -re ".*$prompt $" { fail "list0.c:2,list1.c:17" } + timeout { fail "list0.c:2,list1.c:17" } + } +} + +# +# Test "list filename:function" +# + +proc test_list_filename_and_function {} { + global prompt + + set testcnt 0 + + # gcc appears to generate incorrect debugging information for code + # in include files, which breaks this test. + setup_xfail "rs6000-*-*" 1804 + setup_xfail "a29k-*-udi" + send "list list0.c:main\n" + expect { + -re "1\[ \t\]+#include .*8\[ \t\]+foo \[(\]+.*\[)\]+;\r\n$prompt $" { + incr testcnt + } + -re ".*$prompt $" { fail "list list0.c:main" } + timeout { fail "list list0.c:main (timeout)" } + } + + # The i960 and a29k-amd-udi are the second case + + # Not sure what the point of having this function be unused is. + # AIX is legitimately removing it. + setup_xfail "rs6000-*-aix*" + send "list list0.c:unused\n" + expect { + -re "32\[ \t\]+foo \[(\]+.*\[)\]+;.*39\[ \t\]+\}\r\n$prompt $" { + incr testcnt + } + -re "34.*39\[ \t\]+\}\r\n$prompt $" { + incr testcnt + } + -re ".*$prompt $" { fail "list list0.c:unused" } + timeout { fail "list list0.c:unused (timeout)" } + } + clear_xfail "rs6000-*-aix*" + + # gcc appears to generate incorrect debugging information for code + # in include files, which breaks this test. + # Ultrix gdb is the second case, one line different but still correct. + # FIXME This fails on DWARF + setup_xfail "rs6000-*-*" 1804 + setup_xfail "*-*-sysv4*" + # FIXME Fails for COFF as well, I think. + setup_xfail "a29k-*-udi" + send "list list0.h:foo\n" + expect { + -re "2\[ \t\]+including file. This.*11\[ \t\]+bar \[(\]+.*\[)\]+;\r\n$prompt $" { + incr testcnt + } + -re "1\[ \t\]+/. An include file.*10\[ \t\]+bar \[(\]+.*\[)\]+;\r\n$prompt $" { + incr testcnt + } + -re "No source file named list0.h.\r\n$prompt $" { + fail "list list0.h:foo" + } + -re ".*$prompt $" { fail "list list0.h:foo" } + timeout { fail "list list0.h:foo (timeout)" } + } + + # Ultrix gdb is the second case. + # a29k-amd-udi is the third case. + send "list list1.c:bar\n" + expect { + -re "1\[ \t\]+void.*8\[ \t\]+\}\r\n$prompt $" { + incr testcnt + } + -re "1\[ \t\]+void.*7\[ \t\]*long_line ..;\r\n$prompt $" { + incr testcnt + } + -re "1\[ \t\]+void.*9\[ \t\]*\r\n$prompt $" { + incr testcnt + } + -re ".*$prompt $" { fail "list list1.c:bar" } + timeout { fail "list list1.c:bar (timeout)" } + } + + # The i960 and a29k-amd-udi are the second case + + # Not sure what the point of having this function be unused is. + # AIX is legitimately removing it. + setup_xfail "rs6000-*-aix*" + send "list list1.c:unused\n" + expect { + -re "7\[ \t\]+long_line \[(\]\[)\];.*14\[ \t\]+\}\r\n.*$prompt $" { + incr testcnt + } + -re "9.*14\[ \t\]+\}\r\n.*$prompt $" { + incr testcnt + } + -re ".*$prompt $" { fail "list list1.c:unused" } + timeout { fail "list list1.c:unused (timeout)" } + } + clear_xfail "rs6000-*-aix*" + + pass "list filename:function ($testcnt tests)" + + # Test some invalid specs + # The following test takes the FIXME result on most systems using + # DWARF. It fails to notice that main() is not in the file requested. + + setup_xfail "*-*-*" + +# Does this actually work ANYWHERE? I believe not, as this is an `aspect' of +# lookup_symbol(), where, when it is given a specific symtab which does not +# contain the requested symbol, it will subsequently search all of the symtabs +# for the requested symbol. + + send "list list0.c:foo\n" + expect { + -re "Function \"foo\" not defined in .*list0.c\r\n$prompt $" { + pass "list filename:function; wrong filename rejected" + } + -re "2\[ \t\]+including file.*11\[ \t\]+bar \[(\]+.*\[)\]+;\r\n$prompt $" { + fail "list filename:function; wrong filename not rejected" + } + -re ".*main \[)(\]+.*$prompt $" { + fail "list filename:function; wrong filename not rejected" + } + -re ".*$prompt $" { + fail "list filename:function; wrong filename not rejected" + } + timeout { + fail "list filename:function; wrong filename (timeout)" + } + } + + send "list foobar.c:main\n" + expect { + -re "No source file named foobar.c.\r\n$prompt $" { + pass "list filename:function; nonexistant file" + } + -re ".*$prompt $" { + fail "list filename:function; nonexistant file" + } + timeout { + fail "list filename:function; nonexistant file (timeout)" + } + } + + # The following test takes the FIXME result on most systems using + # DWARF. It doesn't know how to find functions in include files. + + setup_xfail "*-*-sysv4*" + send "list list0.h:foobar\n" + expect { + -re "Function \"foobar\" not defined.\r\n$prompt $" { + pass "list filename:function; nonexistant function" + } + -re "No source file named list0.h.\r\n$prompt $" { + fail "list filename:function; nonexistant function" + } + -re ".*$prompt $" { + fail "list filename:function; nonexistant function" + } + timeout { + fail "list filename:function; nonexistant function (timeout)" + } + } + +} + +proc test_forward_search {} { + gdb_test "set listsize 2" "" + gdb_test "list long_line" "20\[ \t\]+long_line " + + gdb_test "search 4321" " not found" + + gdb_test "search 6789" "22\[ \t\]+oof .6789.;" + + # We could look at the result of this, but dejagnu seems to + # fail, perhaps because expect's buffers are too small. + # In any case, we just want GDB to not crash if the line + # being searched is extremely long. + + gdb_test "search 1234" "" +} + +# Start with a fresh gdb. + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load $objdir/$subdir/$binfile + +send "set width 0\n" +expect -re "$prompt $" + +test_listsize +if [ set_listsize 10 ] then { + test_list_include_file + test_list_filename_and_number + test_list_function + test_list_forward + test_list_backwards + test_list_range + test_list_filename_and_function + test_forward_search +} |