# Test "list filename:number" for C source file
#
-proc test_list_filename_and_number {} {
- global gdb_prompt
-
- set testcnt 0
-
- send_gdb "list list0.c:1\n"
- gdb_expect {
- -re "1\[ \t\]+#include \"list0.h\".*10\[ \t\]+foo .x\[+)\]+;\r\n$gdb_prompt $" {
- incr testcnt
- }
- -re ".*$gdb_prompt $" { fail "list list0.c:1" ; gdb_suppress_tests }
- timeout { fail "list list0.c:1 (timeout)" ; gdb_suppress_tests }
- }
- 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 ".*$gdb_prompt $" { fail "list list.c:10" ; gdb_suppress_tests }
- timeout { fail "list list.c:10 (timeout)" ; gdb_suppress_tests }
- }
- 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 ".*$gdb_prompt $" { fail "list list1.c:1" ; gdb_suppress_tests }
- timeout { fail "list list1.c:1 (timeout)" ; gdb_suppress_tests }
- }
- send_gdb "list list1.c:12\n"
- gdb_expect {
- -re "12\[ \t\]+long_line \[(\]+.*\[)\]+;.*13\[ \t\]+\}\r\n.*$gdb_prompt $" {
- incr testcnt
- }
- -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_with_prefix test_list_filename_and_number {} {
+ gdb_test "list list0.c:1" "1\[ \t\]+#include \"list0.h\".*10\[ \t\]+foo .x\[+)\]+;"
+ gdb_test "list list0.c:10" "5\[ \t\]+int x;.*14\[ \t\]+foo .x\[+)\]+;"
+ gdb_test "list list1.c:1" "1\[ \t\]+\#include.*4\[ \t\]+.*int oof\[ \t\]*\(.*\);\r\n.*"
+ gdb_test "list list1.c:12" "12\[ \t\]+long_line \[(\]+.*\[)\]+;.*13\[ \t\]+\}\r\n.*"
}
#
# Test "list function" for C source file
#
-proc test_list_function {} {
- global gdb_prompt
-
+proc_with_prefix test_list_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.
gdb_test "list -q 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 gdb_prompt
+proc_with_prefix test_list_forward {} {
global last_line_re
- 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 "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_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_gdb "list\n"
- gdb_expect {
- -re "35\[ \t\]+foo \\(.*\\);.*${last_line_re}\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_test "list list0.c:10" "5\[ \t\]+int x;.*14\[ \t\]+foo \[(\]+.*\[)\]+;"
+ gdb_test "list" "15\[ \t\]+foo \[(\]+.*\[)\]+;.*24\[ \t\]+foo \[(\]+.*\[)\]+;" \
+ "list 15-24"
+ gdb_test "list" "25\[ \t\]+foo \[(\]+.*\[)\]+;.*34\[ \t\]+foo \[(\]+.*\[)\]+;" \
+ "list 25-34"
+ gdb_test "list" "35\[ \t\]+foo \\(.*\\);.*${last_line_re}" \
+ "list 35-42"
gdb_test "list" "Line number 44 out of range; \[^\r\n\]+ has 43 lines\." \
"end of file error after \"list\" command"
-
- gdb_stop_suppressing_tests
}
# Test that repeating the list linenum command doesn't print the same
# linenum is dropped, when we repeat the previous command. 'x/5i $pc'
# works the same way.
-proc test_repeat_list_command {} {
- global gdb_prompt
+proc_with_prefix test_repeat_list_command {} {
global last_line_re
- 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 \\(.*\\);.*${last_line_re}\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_test "list list0.c:10" "5\[ \t\]+int x;.*14\[ \t\]+foo \[(\]+.*\[)\]+;"
+ gdb_test " " "15\[ \t\]+foo \[(\]+.*\[)\]+;.*24\[ \t\]+foo \[(\]+.*\[)\]+;" \
+ "list 15-24"
+ gdb_test " " "25\[ \t\]+foo \[(\]+.*\[)\]+;.*34\[ \t\]+foo \[(\]+.*\[)\]+;" \
+ "list 25-34"
+ gdb_test " " "35\[ \t\]+foo \\(.*\\);.*${last_line_re}" \
+ "list 35-42"
gdb_test "list" "Line number 44 out of range; \[^\r\n\]+ has 43 lines\." \
"end of file error after using 'return' to repeat the list command"
-
- gdb_stop_suppressing_tests
}
-proc test_list_backwards {} {
- global gdb_prompt
-
- set testcnt 0
-
- 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_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_gdb "list -\n"
- gdb_expect {
- -re "8\[ \t\]+foo \[(\]+.*\[)\]+;.*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_gdb "list -\n"
- gdb_expect {
- -re "1\[ \t\]+#include .*7\[ \t\]+x = 0;\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"
-
+proc_with_prefix test_list_backwards {} {
+ gdb_test "list list0.c:33" "28\[ \t\]+foo \\(.*\\);.*37\[ \t\]+\}"
+ gdb_test "list -" "18\[ \t\]+foo \[(\]+.*\[)\]+;.*27\[ \t\]+foo \[(\]+.*\[)\]+;" \
+ "list 18-27"
+ gdb_test "list -" "8\[ \t\]+foo \[(\]+.*\[)\]+;.*17\[ \t\]+foo \[(\]+.*\[)\]+;" \
+ "list 8-17"
+ gdb_test "list -" "1\[ \t\]+#include .*7\[ \t\]+x = 0;" \
+ "list 1-7"
gdb_test "list -" "Already at the start of .*\." \
"beginning of file error after \"list -\" command"
-
- gdb_stop_suppressing_tests
}
#