-# Copyright (C) 1992, 1994, 1995 Free Software Foundation, Inc.
+# Copyright 1992, 1994, 1995, 1996, 1997, 1998, 1999, 2002, 2003, 2007, 2008,
+# 2009, 2010 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
+# the Free Software Foundation; either version 3 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., 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
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
# This file was written by Fred Fish. (fnf@cygnus.com)
strace $tracelevel
}
-set prms_id 0
-set bug_id 0
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
+
+# Need to download the header to the host.
+remote_download host ${srcdir}/${subdir}/list0.h list0.h
+
+
+if { [gdb_compile "${srcdir}/${subdir}/list0.c" "${binfile}0.o" object {debug}] != "" } {
+ untested list.exp
+ 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
+
+if { [gdb_compile "${srcdir}/${subdir}/list1.c" "${binfile}1.o" object {debug}] != "" } {
+ untested list.exp
+ 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 { [gdb_compile "${binfile}0.o ${binfile}1.o" ${binfile} executable {debug}] != "" } {
+ untested list.exp
+ return -1
}
+
+
# 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
+if [get_compiler_info ${binfile}] {
+ return -1;
}
-source ${binfile}.ci
#
# Local utility proc just to set and verify listsize
# Return 1 if success, 0 if fail.
#
+set set_listsize_count 0;
+
proc set_listsize { arg } {
- global prompt
+ global gdb_prompt
+ global set_listsize_count;
- 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 }
+ incr set_listsize_count;
+ if [gdb_test "set listsize $arg" ".*" "setting listsize to $arg #$set_listsize_count"] {
+ 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 }
+ if { $arg <= 0 } {
+ set arg "unlimited";
+ }
+
+ if [gdb_test "show listsize" "Number of source lines.* is ${arg}.*" "show listsize $arg #$set_listsize_count"] {
+ return 0;
}
return 1
}
#
proc test_listsize {} {
- global prompt
+ global gdb_prompt
+ global hp_cc_compiler
+ global hp_aCC_compiler
# 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)"
- }
- }
+ gdb_test "show listsize" "Number of source lines gdb will list by default is 10.*" "show default list size"
# Show the default lines
+ # Note that remote targets that have debugging info for _start available will
+ # list the lines there instead of main, so we skip this test for remote targets.
# 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\]+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"
- }
- timeout {
- fail "list default lines around main (timeout)"
- }
+ if [target_info exists use_gdb_stub] {
+ runto_main;
+ unsupported "list default lines around main";
+ } else {
+ gdb_test "list" "(1\[ \t\]+#include \"list0.h\".*10\[ \t\]+x = 0;|2.*11\[ \t\]+foo .x\[+)\]+;)" "list default lines around main"
}
-
+
# 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)"
- }
- }
+
+ if [set_listsize 1] {
+ gdb_test "list 1" "1\[ \t\]+#include \"list0.h\"" "list line 1 with listsize 1"
+ gdb_test "list 2" "2\[ \t\]+" "list line 2 with listsize 1"
}
# 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)"
- }
- }
- }
+ if [ set_listsize 2 ] {
+ gdb_test "list 1" "1\[ \t\]+#include \"list0.h\"\r\n2\[ \t\]+" "list line 1 with listsize 2"
+ gdb_test "list 2" "1\[ \t\]+#include \"list0.h\"\r\n2\[ \t\]+" "list line 2 with listsize 2"
+ gdb_test "list 3" "2\[ \t\]+\r\n3\[ \t\]+int main \[)(\]+" "list line 3 with listsize 2"
+ }
# 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)"
- }
- }
+
+ if [ set_listsize 3 ] {
+ gdb_test "list 1" "1\[ \t\]+#include \"list0.h\".*3\[ \t\]+int main \[)(\]+" "list line 1 with listsize 3"
+ gdb_test "list 2" "1\[ \t\]+#include \"list0.h\".*3\[ \t\]+int main \[)(\]+" "list line 2 with listsize 3"
+ gdb_test "list 3" "2\[ \t\]+\r\n3\[ \t\]+int main \[(\]+\[)\]+\r\n4\[ \t\]+\{" "list line 3 with listsize 3"
}
# 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)"
- }
- }
+ gdb_test "list 1" "1\[ \t\]+#include \"list0.h\".*4\[ \t\]+\{" "list line 1 with listsize 4"
+ gdb_test "list 2" "1\[ \t\]+#include \"list0.h\".*4\[ \t\]+\{" "list line 2 with listsize 4"
- 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)"
- }
- }
+ gdb_test "list 3" "1\[ \t\]+#include \"list0.h\".*4\[ \t\]+\{" "list line 3 with listsize 4"
+ gdb_test "list 4" "2\[ \t\]+\r\n.*5\[ \t\]+int x;.*" "list line 4 with listsize 4"
}
# 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\n42\[ \t\]+\}\r\n$prompt $" {
- pass "list line 1 with listsize 100"
- }
- -re ".*$prompt $" {
- fail "list line 1 with listsize 100"
- }
- timeout {
- fail "list line 1 with listsize 100 (timeout)"
- }
- }
+ gdb_test "list 1" "1\[ \t\]+#include \"list0.h\".*\r\n4\[23\]\[ \t\]+\}" "list line 1 with listsize 100"
- send "list 10\n"
- expect {
- -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 10 with listsize 100 (timeout)"
- }
- }
+ gdb_test "list 10" "1\[ \t\]+#include \"list0.h\".*\r\n4\[23\]\[ \t\]+\}" "list line 10 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)"
- }
- }
+ set_listsize 0
+ gdb_test "list 1" "" "listsize of 0 suppresses output"
# 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 (timeout)"
- }
- }
- }
- -re ".*$prompt $" {
- fail "setting listsize to -1"
- }
- timeout {
- fail "set listsize to -1 (timeout)"
- }
- }
+ set_listsize -1
+ setup_xfail "*-*-*"
+ gdb_test "list 1" "1\[ \t\]+#include .*\r\n39\[ \t\]+\}" "list line 1 with unlimited listsize"
}
#
#
proc test_list_include_file {} {
- global prompt
-
- # 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)"
- }
- }
+ global gdb_prompt
- # 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)"
- }
- }
+ setup_xfail_format "COFF"
+ gdb_test "list list0.h:1" "1\[ \t\]+/\[*\]+ An include file .*10\[ \t\]+bar \\(x\\+\\+\\);" "list line 1 in include file"
+
+ setup_xfail_format "COFF"
+ gdb_test "list list0.h:100" "Line number 95 out of range; .*list0.h has 3\[67\] lines." "list message for lines past EOF"
}
#
#
proc test_list_filename_and_number {} {
- global prompt
+ global gdb_prompt
set testcnt 0
- send "list list0.c:1\n"
- expect {
- -re "1\[ \t\]+#include \"list0.h\".*5\[ \t\]+int x;\r\n$prompt $" {
+ send_gdb "list list0.c:1\n"
+ gdb_expect {
+ -re "1\[ \t\]+#include \"list0.h\".*10\[ \t]+x = 0;\r\n$gdb_prompt $" {
incr testcnt
}
- -re ".*$prompt $" { fail "list list0.c:1" ; return }
- timeout { fail "list list0.c:1 (timeout)" ; return }
+ -re ".*$gdb_prompt $" { fail "list list0.c:1" ; gdb_suppress_tests }
+ timeout { fail "list list0.c:1 (timeout)" ; gdb_suppress_tests }
}
- send "list list0.c:10\n"
- expect {
- -re "5\[ \t\]+int x;.*14\[ \t\]+foo .x\[+)\]+;\r\n$prompt $" {
+ send_gdb "list list0.c:10\n"
+ gdb_expect {
+ -re "5\[ \t\]+int x;.*14\[ \t\]+foo .x\[+)\]+;\r\n$gdb_prompt $" {
incr testcnt
}
- -re ".*$prompt $" { fail "list list.c:10" ; return }
- timeout { fail "list list.c:10 (timeout)" ; return }
+ -re ".*$gdb_prompt $" { fail "list list.c:10" ; gdb_suppress_tests }
+ timeout { fail "list list.c:10 (timeout)" ; gdb_suppress_tests }
}
- send "list list1.c:1\n"
- expect {
- -re "1\[ \t\]+void.*5\[ \t\]+printf \[(\]+.*\[)\]+;\r\n$prompt $" {
+ send_gdb "list list1.c:1\n"
+ gdb_expect {
+ -re "1\[ \t\]+\#include.*4\[ \t\]+.*int oof\[ \t\]*\(.*\);\r\n.*$gdb_prompt $" {
incr testcnt
}
- -re ".*$prompt $" { fail "list list1.c:1" ; return }
- timeout { fail "list list1.c:1 (timeout)" ; return }
+ -re ".*$gdb_prompt $" { fail "list list1.c:1" ; gdb_suppress_tests }
+ timeout { fail "list list1.c:1 (timeout)" ; gdb_suppress_tests }
}
- send "list list1.c:12\n"
- expect {
- -re "7\[ \t\]+long_line \[(\]+.*\[)\]+;.*14\[ \t\]+\}\r\n.*$prompt $" {
+ send_gdb "list list1.c:12\n"
+ gdb_expect {
+ -re "12\[ \t\]+long_line \[(\]+.*\[)\]+;.*13\[ \t\]+\}\r\n.*$gdb_prompt $" {
incr testcnt
}
- -re ".*$prompt $" { fail "list list1.c:12" ; return }
- timeout { fail "list list1.c:12 (timeout)" ; return }
+ -re ".*$gdb_prompt $" { fail "list list1.c:12" ; gdb_suppress_tests }
+ timeout { fail "list list1.c:12 (timeout)" ; gdb_suppress_tests }
}
pass "list filename:number ($testcnt tests)"
+ gdb_stop_suppressing_tests;
}
#
#
proc test_list_function {} {
- global prompt
- global gcc_compiled
+ global gdb_prompt
# 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 "a29k-*-udi"
- send "list main\n"
- expect {
- -re "1\[ \t\]+#include .*8\[ \t\]+breakpoint\[(\]\[)\]+;\r\n$prompt $" {
- pass "list function in source file 1"
- }
- -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 (timeout)" ; return }
- }
+ gdb_test "list main" "(5\[ \t\]+int x;.*14\[ \t\]+foo \[(\]+.*\[)\]+;|1\[ \t\]+#include .*10\[ \t\]+x = 0;)" "list function in source file 1"
# Ultrix gdb takes the second case below; it's also correct.
# SunPRO cc is the third case.
- 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 "1\[ \t\]+void.*7\[ \t\]*long_line ..;.*9\[ \t\]*\r\n$prompt $" {
- pass "list function in source file 2"
- }
- -re ".*$prompt $" { fail "list bar" ; return }
- timeout { fail "list bar (timeout)" ; return }
- }
+ gdb_test "list bar" "(4\[ \t\]+void.*\[ \t\]*long_line.*;.*bar.*9\[ \t\]*.*|1\[ \t\]+void.*8\[ \t\]+\}|1\[ \t\]+void.*7\[ \t\]*long_line ..;|7\[ \t\]+void.*14\[ \t\]+\})" "list function in source file 2"
# Test "list function" for C include file
# Ultrix gdb is the second case, still correct.
# SunPRO cc is the third case.
- setup_xfail "powerpc-*-*"
- 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 "3\[ \t\]+.*12\[ \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 }
- }
+ gdb_test "list foo" "(3\[ \t\]+.*12\[ \t\]+bar \[(\]+.*\[)\]+;|2\[ \t\]+including file.*11\[ \t\]+bar \[(\]+.*\[)\]+;|1\[ \t\]+/. An include file.*10\[ \t\]+bar \[(\]+.*\[)\]+;)" "list function in include file"
}
proc test_list_forward {} {
- global prompt
+ global gdb_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 (timeout)" ; return }
+ send_gdb "list list0.c:10\n"
+ gdb_expect {
+ -re "5\[ \t\]+int x;.*14\[ \t\]+foo \[(\]+.*\[)\]+;\r\n$gdb_prompt $" { incr testcnt }
+ -re ".*$gdb_prompt $" { fail "list list0.c:10" ; gdb_suppress_tests }
+ timeout { fail "list list0.c:10 (timeout)" ; gdb_suppress_tests }
}
- 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_gdb "list\n"
+ gdb_expect {
+ -re "15\[ \t\]+foo \[(\]+.*\[)\]+;.*24\[ \t\]+foo \[(\]+.*\[)\]+;\r\n$gdb_prompt $" { incr testcnt }
+ -re ".*$gdb_prompt $" { fail "list 15-24" ; gdb_suppress_tests }
+ timeout { fail "list 15-24 (timeout)" ; gdb_suppress_tests }
}
- send "list\n"
- expect {
- -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_gdb "list\n"
+ gdb_expect {
+ -re "25\[ \t\]+foo \[(\]+.*\[)\]+;.*34\[ \t\]+foo \[(\]+.*\[)\]+;\r\n$gdb_prompt $" { incr testcnt }
+ -re ".*$gdb_prompt $" { fail "list 25-34" ; gdb_suppress_tests }
+ timeout { fail "list 25-34 (timeout)" ; gdb_suppress_tests }
}
- send "list\n"
- expect {
- -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 }
+ send_gdb "list\n"
+ gdb_expect {
+ -re "35\[ \t\]+foo \\(.*\\);.*42\[ \t\]+.*\}\r\n$gdb_prompt $" { incr testcnt }
+ -re ".*$gdb_prompt $" { fail "list 35-42" ; gdb_suppress_tests }
+ timeout { fail "list 35-42 (timeout)" ; gdb_suppress_tests }
}
pass "successive list commands to page forward ($testcnt tests)"
+ gdb_stop_suppressing_tests;
+}
+
+# Test that repeating the list linenum command doesn't print the same
+# lines over again. Note that this test makes sure that the argument
+# linenum is dropped, when we repeat the previous command. 'x/5i $pc'
+# works the same way.
+
+proc test_repeat_list_command {} {
+ global gdb_prompt
+
+ set testcnt 0
+
+ send_gdb "list list0.c:10\n"
+ gdb_expect {
+ -re "5\[ \t\]+int x;.*14\[ \t\]+foo \[(\]+.*\[)\]+;\r\n$gdb_prompt $" { incr testcnt }
+ -re ".*$gdb_prompt $" { fail "list list0.c:10" ; gdb_suppress_tests }
+ timeout { fail "list list0.c:10 (timeout)" ; gdb_suppress_tests }
+ }
+
+ send_gdb "\n"
+ gdb_expect {
+ -re "15\[ \t\]+foo \[(\]+.*\[)\]+;.*24\[ \t\]+foo \[(\]+.*\[)\]+;\r\n$gdb_prompt $" { incr testcnt }
+ -re ".*$gdb_prompt $" { fail "list 15-24" ; gdb_suppress_tests }
+ timeout { fail "list 15-24 (timeout)" ; gdb_suppress_tests }
+ }
+
+ send_gdb "\n"
+ gdb_expect {
+ -re "25\[ \t\]+foo \[(\]+.*\[)\]+;.*34\[ \t\]+foo \[(\]+.*\[)\]+;\r\n$gdb_prompt $" { incr testcnt }
+ -re ".*$gdb_prompt $" { fail "list 25-34" ; gdb_suppress_tests }
+ timeout { fail "list 25-34 (timeout)" ; gdb_suppress_tests }
+ }
+
+ send_gdb "\n"
+ gdb_expect {
+ -re "35\[ \t\]+foo \\(.*\\);.*42\[ \t\]+.*\}\r\n$gdb_prompt $" { incr testcnt }
+ -re ".*$gdb_prompt $" { fail "list 35-42" ; gdb_suppress_tests }
+ timeout { fail "list 35-42 (timeout)" ; gdb_suppress_tests }
+ }
+
+ pass "repeat list commands to page forward using 'return' ($testcnt tests)"
+ gdb_stop_suppressing_tests;
}
proc test_list_backwards {} {
- global prompt
+ global gdb_prompt
set testcnt 0
- send "list list0.c:33\n"
- expect {
- -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_gdb "list list0.c:33\n"
+ gdb_expect {
+ -re "28\[ \t\]+foo \\(.*\\);.*37\[ \t\]+\}\r\n$gdb_prompt $" { incr testcnt }
+ -re ".*$gdb_prompt $" { fail "list list0.c:33" ; gdb_suppress_tests }
+ timeout { fail "list list0.c:33 (timeout)" ; gdb_suppress_tests }
}
- send "list -\n"
- expect {
- -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_gdb "list -\n"
+ gdb_expect {
+ -re "18\[ \t\]+foo \[(\]+.*\[)\]+;.*27\[ \t\]+foo \[(\]+.*\[)\]+;\r\n$gdb_prompt $" { incr testcnt }
+ -re ".*$gdb_prompt $" { fail "list 18-27" ; gdb_suppress_tests }
+ timeout { fail "list 18-27 (timeout)" ; gdb_suppress_tests }
}
- send "list -\n"
- expect {
- -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_gdb "list -\n"
+ gdb_expect {
+ -re "8\[ \t\]+breakpoint\[(\]\[)\];.*17\[ \t\]+foo \[(\]+.*\[)\]+;\r\n$gdb_prompt $" { incr testcnt }
+ -re ".*$gdb_prompt $" { fail "list 8-17" ; gdb_suppress_tests }
+ timeout { fail "list 8-17 (timeout)" ; gdb_suppress_tests }
}
- send "list -\n"
- expect {
- -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 }
+ send_gdb "list -\n"
+ gdb_expect {
+ -re "1\[ \t\]+#include .*7\[ \t\]+set_debug_traps\[(\]\[)\]+;\r\n$gdb_prompt $" { incr testcnt }
+ -re ".*$gdb_prompt $" { fail "list 1-7" ; gdb_suppress_tests }
+ timeout { fail "list 1-7 (timeout)" ; gdb_suppress_tests }
}
pass "$testcnt successive \"list -\" commands to page backwards"
+ gdb_stop_suppressing_tests;
}
#
#
proc test_list_range {} {
- global prompt
+ global gdb_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 (timeout)" }
- }
+ gdb_test "list list0.c:2,list0.c:5" "2\[ \t\]+\r\n3\[ \t\]+int main \[)(\]+.*5\[ \t\]+int x;" "list range; filename:line1,filename:line2"
- 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 (timeout)" }
- }
+ gdb_test "list 2,5" "2\[ \t\]+\r\n3\[ \t\]+int main \[)(\]+.*5\[ \t\]+int x;" "list range; line1,line2"
- #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 (timeout)" }
- #}
-
- #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 (timeout)" }
- #}
-
- send "list 30,43\n"
- expect {
- -re "30\[ \t\]+foo \[(\]+.*\[)\]+;.*42\[ \t\]+\}\r\n$prompt $" {
- pass "list range; upper bound past EOF"
- }
- -re ".*$prompt $" { fail "list 30,43" }
- timeout { fail "list 30,43 (timeout)" }
- }
+# gdb_test "list -1,6" "Line number 0 out of range; .*list0.c has 39 lines." "list range; lower bound negative"
- send "list 43,100\n"
- expect {
- -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 "43,100" }
- timeout { fail "43,100 (timeout)" }
- }
+# gdb_test "list -100,-40" "Line number -60 out of range; .*list0.c has 39 lines." "list range; both bounds negative"
- 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 (timeout)" }
- }
+ gdb_test "list 30,45" "30\[ \t\]+foo \(.*\);.*43\[ \t\]+\}" "list range; upper bound past EOF"
+
+ gdb_test "list 45,100" "Line number 45 out of range; .*list0.c has 43 lines." "list range; both bounds past EOF"
+
+ gdb_test "list list0.c:2,list1.c:17" "Specified start and end are in different files." "list range, must be same files"
}
#
#
proc test_list_filename_and_function {} {
- global prompt
+ global gdb_prompt
set testcnt 0
# 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 "a29k-*-udi"
- send "list list0.c:main\n"
- expect {
- -re "1\[ \t\]+#include .*8\[ \t\]+breakpoint\[(\]\[)\]+;\r\n$prompt $" {
+ send_gdb "list list0.c:main\n"
+ gdb_expect {
+ -re "1\[ \t\]+#include .*10\[ \t\]+x = 0;\r\n$gdb_prompt $" {
incr testcnt
}
- -re "5\[ \t\]+int x;.*14\[ \t\]+foo \[(\]+.*\[)\]+;\r\n$prompt $" {
+ -re "5\[ \t\]+int x;.*14\[ \t\]+foo \[(\]+.*\[)\]+;\r\n$gdb_prompt $" {
pass "list function in source file 1"
}
- -re ".*$prompt $" { fail "list list0.c:main" }
+ -re ".*$gdb_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 "36\[ \t\]+\}.*42\[ \t\]+\}\r\n$prompt $" {
+ send_gdb "list list0.c:unused\n"
+ gdb_expect {
+ -re "40\[ \t\]+unused.*43\[ \t\]+\}\r\n$gdb_prompt $" {
incr testcnt
}
- -re "37.*42\[ \t\]+\}\r\n$prompt $" {
+ -re "37.*42\[ \t\]+\}\r\n$gdb_prompt $" {
incr testcnt
}
- -re ".*$prompt $" { fail "list list0.c:unused" }
+ -re ".*$gdb_prompt $" { fail "list list0.c:unused" }
timeout { fail "list list0.c:unused (timeout)" }
}
clear_xfail "rs6000-*-aix*"
# Ultrix gdb is the second case, one line different but still correct.
# SunPRO cc is the third case.
setup_xfail "rs6000-*-*" 1804
- setup_xfail "powerpc-*-*" 1804
- # 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 $" {
+ setup_xfail_format "COFF"
+ send_gdb "list list0.h:foo\n"
+ gdb_expect {
+ -re "2\[ \t\]+including file. This.*11\[ \t\]+bar \[(\]+.*\[)\]+;\r\n$gdb_prompt $" {
incr testcnt
}
- -re "1\[ \t\]+/. An include file.*10\[ \t\]+bar \[(\]+.*\[)\]+;\r\n$prompt $" {
+ -re "1\[ \t\]+/. An include file.*10\[ \t\]+bar \[(\]+.*\[)\]+;\r\n$gdb_prompt $" {
incr testcnt
}
- -re "3\[ \t\]+.*12\[ \t\]+bar \[(\]+.*\[)\]+;\r\n$prompt $" {
+ -re "3\[ \t\]+.*12\[ \t\]+bar \[(\]+.*\[)\]+;\r\n$gdb_prompt $" {
incr testcnt
}
- -re "No source file named list0.h.\r\n$prompt $" {
+ -re "No source file named list0.h.\r\n$gdb_prompt $" {
fail "list list0.h:foo"
}
- -re ".*$prompt $" { fail "list list0.h:foo" }
+ -re ".*$gdb_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 $" {
+ send_gdb "list list1.c:bar\n"
+ gdb_expect {
+ -re "4\[ \t\]+void.*13\[ \t\]+\}\r\n$gdb_prompt $" {
incr testcnt
}
- -re "1\[ \t\]+void.*7\[ \t\]*long_line ..;\r\n$prompt $" {
+ -re "4\[ \t\]+void.*12\[ \t\]*long_line ..;\r\n$gdb_prompt $" {
incr testcnt
}
- -re "1\[ \t\]+void.*9\[ \t\]*\r\n$prompt $" {
+ -re "4\[ \t\]+void.*11\[ \t\]*\r\n$gdb_prompt $" {
incr testcnt
}
- -re ".*$prompt $" { fail "list list1.c:bar" }
+ -re ".*$gdb_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 $" {
+ send_gdb "list list1.c:unused\n"
+ gdb_expect {
+ -re "12\[ \t\]+long_line \[(\]\[)\];.*13\[ \t\]+\}\r\n.*$gdb_prompt $" {
incr testcnt
}
- -re "9.*14\[ \t\]+\}\r\n.*$prompt $" {
+ -re "14.*19\[ \t\]+\}\r\n.*$gdb_prompt $" {
incr testcnt
}
- -re ".*$prompt $" { fail "list list1.c:unused" }
+ -re ".*$gdb_prompt $" { fail "list list1.c:unused" }
timeout { fail "list list1.c:unused (timeout)" }
}
clear_xfail "rs6000-*-aix*"
pass "list filename:function ($testcnt tests)"
+ # Test with quoting.
+ gdb_test "list 'list0.c:main'" "int main.*"
+
# 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.
# 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)"
- }
- }
+ gdb_test "list list0.c:foo" "Function \"foo\" not defined in .*list0.c" "list filename:function; wrong filename rejected"
- 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)"
- }
- }
+ gdb_test "list foobar.c:main" "No source file named foobar.c.|Location not found" "list filename:function; nonexistant file"
- 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)"
- }
- }
+ gdb_test "list list0.h:foobar" "Function \"foobar\" not defined.|Location not found" "list filename:function; nonexistant function"
}
proc test_forward_search {} {
global timeout
- gdb_test "set listsize 4" ""
+ gdb_test_no_output "set listsize 4"
# On SunOS4, this gives us lines 19-22. On AIX, it gives us
# lines 20-23. This depends on whether the line number of a function
# is considered to be the openbrace or the first statement--either one
# is acceptable.
- gdb_test "list long_line" "20\[ \t\]+long_line .*"
+ gdb_test "list long_line" "24\[ \t\]+long_line .*"
gdb_test "search 4321" " not found"
- gdb_test "search 6789" "24\[ \t\]+oof .6789.;"
+ gdb_test "search 6789" "28\[ \t\]+oof .6789.;"
# Test that GDB won't crash if the line being searched is extremely long.
set oldtimeout $timeout
- set timeout [expr "$timeout + 60"]
+ set timeout [expr "$timeout + 300"]
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
gdb_reinitialize_dir $srcdir/$subdir
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 }
- }
+if [target_info exists gdb_stub] {
+ gdb_step_for_stub;
}
-send "set width 0\n"
-expect -re "$prompt $"
+gdb_test_no_output "set width 0"
test_listsize
+get_debug_format
if [ set_listsize 10 ] then {
test_list_include_file
test_list_filename_and_number
test_list_function
test_list_forward
test_list_backwards
+ test_repeat_list_command
test_list_range
test_list_filename_and_function
test_forward_search
}
+
+remote_exec build "rm -f list0.h"