* lib/gdb.exp (CFLAGS): Remove, unreferenced.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / list.exp
index 25c30c436d1dadec19a56e3fa413d79e59f45a2f..8177c6242cc0c539cacff4c5113349a65c15f808 100644 (file)
@@ -12,7 +12,7 @@
 # 
 # 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.  */
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 
 # Please email any bugs, comments, and/or additions to this file to:
 # bug-gdb@prep.ai.mit.edu
@@ -26,13 +26,31 @@ if $tracelevel then {
 set prms_id 0
 set bug_id 0
 
-set binfile "list"
-set srcfile $binfile.c
+set testfile "list"
+set binfile ${objdir}/${subdir}/${testfile}
+if  { [compile "-g -c ${srcdir}/${subdir}/list0.c"] != "" } {
+    perror "Couldn't compile ${testfile}0.c to object"
+    return -1
+}
+execute_anywhere "mv list0.o ${binfile}0.o"
+if  { [compile "-g -c ${srcdir}/${subdir}/list1.c"] != "" } {
+    perror "Couldn't compile ${testfile}1.c to object"
+    return -1
+}
+execute_anywhere "mv list1.o ${binfile}1.o"
+if  { [compile "${binfile}0.o ${binfile}1.o -o ${binfile}"] != "" } {
+    perror "Couldn't link ${testfile}."
+    return -1
+}
 
-if ![file exists $objdir/$subdir/$binfile] then {
-    perror "$objdir/$subdir/$binfile does not exist."
-    return 0
+# Create and source the file that provides information about the compiler
+# used to compile the test case.
+execute_anywhere "rm -f ${binfile}.ci"
+if  { [compile "-E ${srcdir}/${subdir}/compiler.c > ${binfile}.ci"] != "" } {
+    perror "Couldn't make ${binfile}.ci file"
+    return -1
 }
+source ${binfile}.ci
 
 #
 # Local utility proc just to set and verify listsize
@@ -44,7 +62,7 @@ proc set_listsize { arg } {
 
     send "set listsize $arg\n"
     expect {
-       -re "set listsize $arg\r\n$prompt $" {}
+       -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 } 
     }
@@ -81,13 +99,17 @@ proc test_listsize {} {
     }
     
     # Show the default lines
+    # The second case is for optimized code, it is still correct.
     
     # 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 "1\[ \t\]+#include \"list0.h\".*10\[ \t\]+x = 0;\r\n$prompt $" {
+           pass "list default lines around main"
+       }
+       -re "2.*11\[ \t\]+foo .x\[+)\]+;\r\n$prompt $" {
+           pass "list default lines around main"
        }
        -re ".*$prompt $" {
            fail "list default lines around main"
@@ -294,21 +316,27 @@ proc test_listsize {} {
     if [ set_listsize 100 ] then {
        send "list 1\n"
        expect {
-           -re "1\[ \t\]+#include \"list0.h\".*\r\n39\[ \t\]+\}\r\n$prompt $" {
+           -re "1\[ \t\]+#include \"list0.h\".*\r\n42\[ \t\]+\}\r\n$prompt $" {
                pass "list line 1 with listsize 100"
            }
-           timeout {
+           -re ".*$prompt $" {
                fail "list line 1 with listsize 100"
            }
+           timeout {
+               fail "list line 1 with listsize 100 (timeout)"
+           }
        }
        
        send "list 10\n"
        expect {
-           -re "1\[ \t\]+#include \"list0.h\".*\r\n39\[ \t\]+\}\r\n$prompt $" {
-               pass "list line 1 with listsize 100"
+           -re "1\[ \t\]+#include \"list0.h\".*\r\n42\[ \t\]+\}\r\n$prompt $" {
+               pass "list line 10 with listsize 100"
+           }
+           -re ".*$prompt $" {
+               fail "list line 10 with listsize 100"
            }
            timeout {
-               fail "list line 1 with listsize 100"
+               fail "list line 10 with listsize 100 (timeout)"
            }
        }
     }
@@ -317,7 +345,7 @@ proc test_listsize {} {
 
     send "set listsize 0\n"
     expect {
-       -re "set listsize 0\r\n$prompt $" {
+       -re "set listsize 0\[\r\n\]+$prompt $" {
            setup_xfail "*-*-*"
            send "show listsize\n"
            expect {
@@ -336,7 +364,7 @@ proc test_listsize {} {
            }
            send "list 1\n"
            expect {
-               -re "list 1\r\n$prompt $" {
+               -re "list 1\[\r\n\]+$prompt $" {
                    pass "listsize of 0 suppresses output"
                }
                -re ".*$prompt $" {
@@ -359,7 +387,7 @@ proc test_listsize {} {
 
     send "set listsize -1\n"
     expect {
-       -re "set listsize -1\r\n$prompt $" {
+       -re "set listsize -1\[\r\n\]+$prompt $" {
            send "show listsize\n"
            expect {
                -re "Number of source lines .* is unlimited.\r\n.*$prompt $" {
@@ -378,11 +406,11 @@ proc test_listsize {} {
                -re "1\[ \t\]+#include .*\r\n39\[ \t\]+\}\r\n$prompt $" {
                    pass "list line 1 with unlimited listsize"
                }
-               -re "list 1\r\n$prompt $" {
+               -re "list 1\[\r\n\]+$prompt $" {
                    fail "listsize of -1 (unlimited) suppresses output"
                }
                timeout {
-                   fail "list line 1 with unlimited listsize"
+                   fail "list line 1 with unlimited listsize (timeout)"
                }
            }
        }
@@ -402,8 +430,6 @@ proc test_listsize {} {
 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"
@@ -422,8 +448,6 @@ proc test_list_include_file {} {
        }
     }
 
-    # 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"
@@ -458,7 +482,7 @@ proc test_list_filename_and_number {} {
            incr testcnt 
        }
        -re ".*$prompt $" { fail "list list0.c:1" ; return }
-       timeout { fail "list list0.c:1" ; return }
+       timeout { fail "list list0.c:1 (timeout)" ; return }
     }
     send "list list0.c:10\n"
     expect {
@@ -466,7 +490,7 @@ proc test_list_filename_and_number {} {
            incr testcnt 
        }
        -re ".*$prompt $" { fail "list list.c:10" ; return }
-       timeout { fail "list list.c:10" ; return }
+       timeout { fail "list list.c:10 (timeout)" ; return }
     }
     send "list list1.c:1\n"
     expect {
@@ -474,7 +498,7 @@ proc test_list_filename_and_number {} {
            incr testcnt 
        }
        -re ".*$prompt $" { fail "list list1.c:1" ; return }
-       timeout { fail "list list1.c:1" ; return }
+       timeout { fail "list list1.c:1 (timeout)" ; return }
     }
     send "list list1.c:12\n"
     expect {
@@ -482,7 +506,7 @@ proc test_list_filename_and_number {} {
            incr testcnt 
        }
        -re ".*$prompt $" { fail "list list1.c:12" ; return }
-       timeout { fail "list list1.c:12" ; return }
+       timeout { fail "list list1.c:12 (timeout)" ; return }
     }
     pass "list filename:number ($testcnt tests)"
 }
@@ -493,22 +517,22 @@ proc test_list_filename_and_number {} {
 
 proc test_list_function {} {
     global prompt
+    global gcc_compiled
 
     # gcc appears to generate incorrect debugging information for code
     # in include files, which breaks this test.
     # SunPRO cc is the second case below, it's also correct.
-    setup_xfail "rs6000-*-*" 1804
     setup_xfail "a29k-*-udi"
     send "list main\n"
     expect {
-       -re "1\[ \t\]+#include .*8\[ \t\]+foo \[(\]+.*\[)\]+;\r\n$prompt $" {
+       -re "1\[ \t\]+#include .*8\[ \t\]+breakpoint\[(\]\[)\]+;\r\n$prompt $" {
            pass "list function in source file 1"
        }
-       -re "2\[ \t\]+.*11\[ \t\]+foo \[(\]+.*\[)\]+;\r\n$prompt $" {
+       -re "5\[ \t\]+int x;.*14\[ \t\]+foo \[(\]+.*\[)\]+;\r\n$prompt $" {
            pass "list function in source file 1"
        }
        -re ".*$prompt $" { fail "list main" ; return }
-       timeout { fail "list main" ; return }
+       timeout { fail "list main (timeout)" ; return }
     }
 
     # Ultrix gdb takes the second case below; it's also correct.
@@ -525,14 +549,13 @@ proc test_list_function {} {
            pass "list function in source file 2"
        }
        -re ".*$prompt $" { fail "list bar" ; return }
-       timeout { fail "list bar" ; return }
+       timeout { fail "list bar (timeout)" ; return }
     }
 
     # Test "list function" for C include file
     # Ultrix gdb is the second case, still correct.
     # SunPRO cc is the third case.
-    # FIXME This fails on DWARF
-    setup_xfail "*-*-sysv4*"
+    setup_xfail "powerpc-*-*"
     send "list foo\n"
     expect {
        -re "2\[ \t\]+including file.*11\[ \t\]+bar \[(\]+.*\[)\]+;\r\n$prompt $" {
@@ -561,7 +584,7 @@ proc test_list_forward {} {
     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 }
+       timeout { fail "list list0.c:10 (timeout)" ; return }
     }
 
     send "list\n"
@@ -573,16 +596,16 @@ proc test_list_forward {} {
 
     send "list\n"
     expect {
-       -re "25\[ \t\]+foo \[(\]+.*\[)\]+;.*34\[ \t\]+\r\n$prompt $" { incr testcnt }
+       -re "25\[ \t\]+foo \[(\]+.*\[)\]+;.*34\[ \t\]+foo \[(\]+.*\[)\]+;\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 }
+       -re "35\[ \t\]+foo \[(\]+.*\[)\]+;.*42\[ \t\]+\}\r\n$prompt $" { incr testcnt }
+       -re ".*$prompt $" { fail "list 35-42" ; return }
+       timeout { fail "list 35-42 (timeout)" ; return }
     }
 
     pass "successive list commands to page forward ($testcnt tests)"
@@ -593,32 +616,32 @@ proc test_list_backwards {} {
 
     set testcnt 0
 
-    send "list list0.c:30\n"
+    send "list list0.c:33\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 }
+       -re "28\[ \t\]+foo \[(\]+.*\[)\]+;.*37\[ \t\]+\r\n$prompt $" { incr testcnt }
+       -re ".*$prompt $" { fail "list list0.c:33" ; return }
+       timeout { fail "list list0.c:33 (timeout)" ; 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 }
+       -re "18\[ \t\]+foo \[(\]+.*\[)\]+;.*27\[ \t\]+foo \[(\]+.*\[)\]+;\r\n$prompt $" { incr testcnt }
+       -re ".*$prompt $" { fail "list 18-27" ; return }
+       timeout { fail "list 18-27 (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 }
+       -re "8\[ \t\]+breakpoint\[(\]\[)\];.*17\[ \t\]+foo \[(\]+.*\[)\]+;\r\n$prompt $" { incr testcnt }
+       -re ".*$prompt $" { fail "list 8-17" ; return }
+       timeout { fail "list 8-17 (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 }
+       -re "1\[ \t\]+#include .*7\[ \t\]+set_debug_traps\[(\]\[)\]+;\r\n$prompt $" { incr testcnt }
+       -re ".*$prompt $" { fail "list 1-7" ; return }
+       timeout { fail "list 1-7 (timeout)" ; return }
     }
 
     pass "$testcnt successive \"list -\" commands to page backwards"
@@ -637,7 +660,7 @@ proc test_list_range {} {
            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" }
+       timeout { fail "list list0.c:2,list0.c:5 (timeout)" }
     }
 
     send "list 2,5\n"
@@ -646,7 +669,7 @@ proc test_list_range {} {
            pass "list range; line1,line2"
        }
        -re ".*$prompt $" { fail "list 2,5" }
-       timeout { fail "list 2,5" }
+       timeout { fail "list 2,5 (timeout)" }
     }
 
     #send "list -1,6\n"
@@ -655,7 +678,7 @@ proc test_list_range {} {
            #pass "list range; lower bound negative"
        #}
        #-re ".*$prompt $" { fail "list -1,6" }
-       #timeout { fail "list -1,6" }
+       #timeout { fail "list -1,6 (timeout)" }
     #}
 
     #send "list -100,-40\n"
@@ -664,25 +687,25 @@ proc test_list_range {} {
            #pass "list range; both bounds negative"
        #}
        #-re ".*$prompt $" { fail "-100,-40" }
-       #timeout { fail "-100,-40" }
+       #timeout { fail "-100,-40 (timeout)" }
     #}
 
-    send "list 30,40\n"
+    send "list 30,43\n"
     expect {
-       -re "30\[ \t\]+foo \[(\]+.*\[)\]+;.*39\[ \t\]+\}\r\n$prompt $" {
+       -re "30\[ \t\]+foo \[(\]+.*\[)\]+;.*42\[ \t\]+\}\r\n$prompt $" {
            pass "list range; upper bound past EOF"
        }
-       -re ".*$prompt $" { fail "list 30,40" }
-       timeout { fail "list 30,40" }
+       -re ".*$prompt $" { fail "list 30,43" }
+       timeout { fail "list 30,43 (timeout)" }
     }
 
-    send "list 40,100\n"
+    send "list 43,100\n"
     expect {
-       -re "Line number 40 out of range; .*list0.c has 39 lines.\r\n$prompt $" {
+       -re "Line number 43 out of range; .*list0.c has 42 lines.\r\n$prompt $" {
            pass "list range; both bounds past EOF"
        }
-       -re ".*$prompt $" { fail "40,100" }
-       timeout { fail "40,100" }
+       -re ".*$prompt $" { fail "43,100" }
+       timeout { fail "43,100 (timeout)" }
     }
 
     send "list list0.c:2,list1.c:17\n"
@@ -691,7 +714,7 @@ proc test_list_range {} {
            pass "list range, must be same files"
        }
        -re ".*$prompt $" { fail "list0.c:2,list1.c:17" }
-       timeout { fail "list0.c:2,list1.c:17" }
+       timeout { fail "list0.c:2,list1.c:17 (timeout)" }
     }
 }
 
@@ -707,14 +730,13 @@ proc test_list_filename_and_function {} {
     # gcc appears to generate incorrect debugging information for code
     # in include files, which breaks this test.
     # SunPRO cc is the second case below, it's also correct.
-    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 $" {
+       -re "1\[ \t\]+#include .*8\[ \t\]+breakpoint\[(\]\[)\]+;\r\n$prompt $" {
            incr testcnt
        }
-       -re "2\[ \t\]+.*11\[ \t\]+foo \[(\]+.*\[)\]+;\r\n$prompt $" {
+       -re "5\[ \t\]+int x;.*14\[ \t\]+foo \[(\]+.*\[)\]+;\r\n$prompt $" {
            pass "list function in source file 1"
        }
        -re ".*$prompt $" { fail "list list0.c:main" }
@@ -728,10 +750,10 @@ proc test_list_filename_and_function {} {
     setup_xfail "rs6000-*-aix*"
     send "list list0.c:unused\n"
     expect {
-       -re "32\[ \t\]+foo \[(\]+.*\[)\]+;.*39\[ \t\]+\}\r\n$prompt $" {
+       -re "36\[ \t\]+\}.*42\[ \t\]+\}\r\n$prompt $" {
            incr testcnt
        }
-       -re "34.*39\[ \t\]+\}\r\n$prompt $" {
+       -re "37.*42\[ \t\]+\}\r\n$prompt $" {
            incr testcnt
        }
        -re ".*$prompt $" { fail "list list0.c:unused" }
@@ -743,9 +765,8 @@ proc test_list_filename_and_function {} {
     # in include files, which breaks this test.
     # Ultrix gdb is the second case, one line different but still correct.
     # SunPRO cc is the third case.
-    # FIXME This fails on DWARF
     setup_xfail "rs6000-*-*" 1804
-    setup_xfail "*-*-sysv4*"
+    setup_xfail "powerpc-*-*" 1804
     # FIXME Fails for COFF as well, I think.
     setup_xfail "a29k-*-udi"
     send "list list0.h:foo\n"
@@ -846,10 +867,6 @@ proc test_list_filename_and_function {} {
        }
     }
 
-    # 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 $" {
@@ -882,15 +899,15 @@ proc test_forward_search {} {
 
        gdb_test "search 6789" "24\[ \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.
+       # Test that GDB won't crash if the line being searched is extremely long.
 
        set oldtimeout $timeout
-       set timeout 30
-       gdb_test "search 1234" ""
+       set timeout [expr "$timeout + 60"]
+       verbose "Timeout is now $timeout seconds" 2
+       match_max 10000
+       gdb_test "search 1234" ".*1234.*" "search extremely long line (> 5000 chars)"
        set timeout $oldtimeout
+       verbose "Timeout is now $timeout seconds" 2
 }
 
 # Start with a fresh gdb.
@@ -898,7 +915,16 @@ proc test_forward_search {} {
 gdb_exit
 gdb_start
 gdb_reinitialize_dir $srcdir/$subdir
-gdb_load $objdir/$subdir/$binfile
+gdb_load ${binfile}
+
+if $usestubs {
+    send "step\n"
+    # if use stubs step out of the breakpoint() function.
+    expect {
+        -re "main.* at .*$prompt $" {}
+        timeout { fail "single step at breakpoint() (timeout)" ; return 0 }
+    }
+}
 
 send "set width 0\n"
 expect -re "$prompt $"
This page took 0.033593 seconds and 4 git commands to generate.