gdb_continue_to_breakpoint "entry: breakhere"
-gdb_test "bt" "^bt\r\n#0 +d *\\(i=31, i@entry=30, j=31\\.5, j@entry=30\\.5\\) \[^\r\n\]*\r\n#1 +0x\[0-9a-f\]+ in main .*" \
- "entry: bt"
+gdb_test "bt" \
+ [multi_line \
+ "^#0 +d *\\(i=31, i@entry=30, j=31\\.5, j@entry=30\\.5\\) \[^\r\n\]*" \
+ "#1 +0x\[0-9a-f\]+ in main .*"] \
+ "entry: bt"
gdb_test "p i" " = 31" "entry: p i"
gdb_test "p i@entry" " = 30" "entry: p i@entry"
gdb_test "p j" { = 31\.5} "entry: p j"
gdb_continue_to_breakpoint "entry_locexpr: breakhere_locexpr"
gdb_test "p i" " = 30" "entry_locexpr: p i"
gdb_test_no_output "set variable i = 0" "entry_locexpr: set variable i = 0"
-gdb_test "bt" "^bt\r\n#0 +locexpr *\\(i=0, i@entry=30\\) \[^\r\n\]*\r\n#1 +0x\[0-9a-f\]+ in main .*" \
- "entry_locexpr: bt"
+gdb_test "bt" \
+ [multi_line \
+ "^#0 +locexpr *\\(i=0, i@entry=30\\) \[^\r\n\]*" \
+ "#1 +0x\[0-9a-f\]+ in main .*"] \
+ "entry_locexpr: bt"
# Test @entry values for stack passed parameters.
gdb_continue_to_breakpoint "entry_stack: stacktest"
-gdb_test "bt" "^bt\r\n#0 +stacktest *\\(r1=r1@entry=1, r2=r2@entry=2, \[^\r\n\]+, s1=s1@entry=11, s2=s2@entry=12, \[^\r\n\]+, d9=d9@entry=11\\.5, da=da@entry=12\\.5\\) \[^\r\n\]*\r\n#1 +0x\[0-9a-f\]+ in main .*" \
- "entry_stack: bt at entry"
+gdb_test "bt" \
+ [multi_line \
+ "^#0 +stacktest *\\(r1=r1@entry=1, r2=r2@entry=2, \[^\r\n\]+, s1=s1@entry=11, s2=s2@entry=12, \[^\r\n\]+, d9=d9@entry=11\\.5, da=da@entry=12\\.5\\) \[^\r\n\]*" \
+ "#1 +0x\[0-9a-f\]+ in main .*"] \
+ "entry_stack: bt at entry"
gdb_continue_to_breakpoint "entry_stack: breakhere_stacktest"
-gdb_test "bt" "^bt\r\n#0 +stacktest *\\(r1=r1@entry=1, r2=r2@entry=2, \[^\r\n\]+, s1=3, s1@entry=11, s2=4, s2@entry=12, \[^\r\n\]+, d9=3\\.5, d9@entry=11\\.5, da=4\\.5, da@entry=12\\.5\\) \[^\r\n\]*\r\n#1 +0x\[0-9a-f\]+ in main .*" \
- "entry_stack: bt"
+gdb_test "bt" \
+ [multi_line \
+ "^#0 +stacktest *\\(r1=r1@entry=1, r2=r2@entry=2, \[^\r\n\]+, s1=3, s1@entry=11, s2=4, s2@entry=12, \[^\r\n\]+, d9=3\\.5, d9@entry=11\\.5, da=4\\.5, da@entry=12\\.5\\) \[^\r\n\]*" \
+ "#1 +0x\[0-9a-f\]+ in main .*"] \
+ "entry_stack: bt"
gdb_test "p s1" " = 3" "entry_stack: p s1"
gdb_test "p s1@entry" " = 11" "entry_stack: p s1@entry"
gdb_continue_to_breakpoint "tailcall: breakhere"
-gdb_test "bt" "^bt\r\n#0 +d *\\(i=71, i@entry=70, j=73\\.5, j@entry=72\\.5\\) \[^\r\n\]*\r\n#1 +0x\[0-9a-f\]+ in c \\(i=i@entry=7, j=j@entry=7\\.25\\) \[^\r\n\]*\r\n#2 +0x\[0-9a-f\]+ in b \\(i=i@entry=5, j=j@entry=5\\.25\\) \[^\r\n\]*\r\n#3 +0x\[0-9a-f\]+ in main \[^\r\n\]*" \
- "tailcall: bt"
+gdb_test "bt" \
+ [multi_line \
+ "^#0 +d *\\(i=71, i@entry=70, j=73\\.5, j@entry=72\\.5\\) \[^\r\n\]*" \
+ "#1 +0x\[0-9a-f\]+ in c \\(i=i@entry=7, j=j@entry=7\\.25\\) \[^\r\n\]*" \
+ "#2 +0x\[0-9a-f\]+ in b \\(i=i@entry=5, j=j@entry=5\\.25\\) \[^\r\n\]*" \
+ "#3 +0x\[0-9a-f\]+ in main \[^\r\n\]*"] \
+ "tailcall: bt"
gdb_test "p i" " = 71" "tailcall: p i"
gdb_test "p i@entry" " = 70" "tailcall: p i@entry"
gdb_test "p j" " = 73\\.5" "tailcall: p j"
gdb_continue_to_breakpoint "ambiguous: breakhere"
-gdb_test "bt" "^bt\r\n#0 +d \\(i=<optimized out>, j=<optimized out>\\)\[^\r\n\]*\r\n#1 +0x\[0-9a-f\]+ in amb_z \\(i=<optimized out>\\)\[^\r\n\]*\r\n#2 +0x\[0-9a-f\]+ in amb_y \\(i=<optimized out>\\)\[^\r\n\]*\r\n#3 +0x\[0-9a-f\]+ in amb_x \\(i=<optimized out>\\)\[^\r\n\]*\r\n#4 +0x\[0-9a-f\]+ in amb_b \\(i=i@entry=101\\)\[^\r\n\]*\r\n#5 +0x\[0-9a-f\]+ in amb_a \\(i=i@entry=100\\)\[^\r\n\]*\r\n#6 +0x\[0-9a-f\]+ in main \\(\\)\[^\r\n\]*" \
- "ambiguous: bt"
+gdb_test "bt" \
+ [multi_line \
+ "^#0 +d \\(i=<optimized out>, j=<optimized out>\\)\[^\r\n\]*" \
+ "#1 +0x\[0-9a-f\]+ in amb_z \\(i=<optimized out>\\)\[^\r\n\]*" \
+ "#2 +0x\[0-9a-f\]+ in amb_y \\(i=<optimized out>\\)\[^\r\n\]*" \
+ "#3 +0x\[0-9a-f\]+ in amb_x \\(i=<optimized out>\\)\[^\r\n\]*" \
+ "#4 +0x\[0-9a-f\]+ in amb_b \\(i=i@entry=101\\)\[^\r\n\]*" \
+ "#5 +0x\[0-9a-f\]+ in amb_a \\(i=i@entry=100\\)\[^\r\n\]*" \
+ "#6 +0x\[0-9a-f\]+ in main \\(\\)\[^\r\n\]*"] \
+ "ambiguous: bt"
# Test self tail calls verification.
gdb_continue_to_breakpoint "self: breakhere"
-gdb_test "bt" "^bt\r\n#0 +d \\(i=<optimized out>, j=<optimized out>\\)\[^\r\n\]*\r\n#1 +0x\[0-9a-f\]+ in self \\(i=<optimized out>\\)\[^\r\n\]*\r\n#2 +0x\[0-9a-f\]+ in self2 \\(i=<optimized out>\\)\[^\r\n\]*\r\n#3 +0x\[0-9a-f\]+ in self \\(i=<optimized out>\\)\[^\r\n\]*\r\n#4 +0x\[0-9a-f\]+ in main \\(\\)\[^\r\n\]*" \
- "self: bt"
+gdb_test "bt" \
+ [multi_line \
+ "^#0 +d \\(i=<optimized out>, j=<optimized out>\\)\[^\r\n\]*" \
+ "#1 +0x\[0-9a-f\]+ in self \\(i=<optimized out>\\)\[^\r\n\]*" \
+ "#2 +0x\[0-9a-f\]+ in self2 \\(i=<optimized out>\\)\[^\r\n\]*" \
+ "#3 +0x\[0-9a-f\]+ in self \\(i=<optimized out>\\)\[^\r\n\]*" \
+ "#4 +0x\[0-9a-f\]+ in main \\(\\)\[^\r\n\]*"] \
+ "self: bt"
gdb_test_no_output "set debug entry-values 1"
gdb_test "bt" "DW_OP_entry_value resolving has found function \"self\\(int\\)\" at 0x\[0-9a-f\]+ can call itself via tail calls\r\n.*" \
return -1
}
-gdb_test "bt" "^bt\r\n#0 +breakpt *\\(\\) \[^\r\n\]*\r\n#1 +0x\[0-9a-f\]+ in func5\[^\r\n\]*\r\n#2 +0x\[0-9a-f\]+ in func4\[^\r\n\]*\r\n#3 +0x\[0-9a-f\]+ in func3\[^\r\n\]*\r\nBacktrace stopped: Cannot access memory at address 0x\[0-9a-f\]+" \
+gdb_test "bt" "^#0 +breakpt *\\(\\) \[^\r\n\]*\r\n#1 +0x\[0-9a-f\]+ in func5\[^\r\n\]*\r\n#2 +0x\[0-9a-f\]+ in func4\[^\r\n\]*\r\n#3 +0x\[0-9a-f\]+ in func3\[^\r\n\]*\r\nBacktrace stopped: Cannot access memory at address 0x\[0-9a-f\]+" \
"first backtrace, with error message"
-gdb_test "bt" "^bt\r\n#0 +breakpt *\\(\\) \[^\r\n\]*\r\n#1 +0x\[0-9a-f\]+ in func5\[^\r\n\]*\r\n#2 +0x\[0-9a-f\]+ in func4\[^\r\n\]*\r\n#3 +0x\[0-9a-f\]+ in func3\[^\r\n\]*\r\nBacktrace stopped: Cannot access memory at address 0x\[0-9a-f\]+" \
+gdb_test "bt" "^#0 +breakpt *\\(\\) \[^\r\n\]*\r\n#1 +0x\[0-9a-f\]+ in func5\[^\r\n\]*\r\n#2 +0x\[0-9a-f\]+ in func4\[^\r\n\]*\r\n#3 +0x\[0-9a-f\]+ in func3\[^\r\n\]*\r\nBacktrace stopped: Cannot access memory at address 0x\[0-9a-f\]+" \
"second backtrace, with error message"
clean_restart ${binfile}
# Use 'bt no-filters' here as the python filters will raise their own
# error during initialisation, the no-filters case is simpler.
-gdb_test "bt no-filters" "^bt no-filters\r\n#0 +$hex in func2 \\(\\)\r\nBacktrace stopped: Cannot access memory at address 0x\[0-9a-f\]+" \
+gdb_test "bt no-filters" "^#0 +$hex in func2 \\(\\)\r\nBacktrace stopped: Cannot access memory at address 0x\[0-9a-f\]+" \
"first backtrace, with error message"
-gdb_test "bt no-filters" "^bt no-filters\r\n#0 +$hex in func2 \\(\\)\r\nBacktrace stopped: Cannot access memory at address 0x\[0-9a-f\]+" \
+gdb_test "bt no-filters" "^#0 +$hex in func2 \\(\\)\r\nBacktrace stopped: Cannot access memory at address 0x\[0-9a-f\]+" \
"second backtrace, with error message"
clean_restart ${binfile}
-re "MIS-MATCHED.*$gdb_prompt $" {
fail $test
}
- -re "warning.*One or more sections.*does not match.*loaded file.*$gdb_prompt $" {
+ -re "warning: One or more sections.*does not match.*loaded file.*$gdb_prompt $" {
fail $test
}
-re "Section.*matched.*$gdb_prompt $" {
clean_restart ${testfile}
-gdb_test "rbreak $realsrcfile2:func" "^rbreak \[^\r\n\]*:func\r\nBreakpoint 1 at 0x\[0-9a-f\]+: file [string_to_regexp ${subdir}/${srcfile2}], line \[0-9\]+\\.\r\nvoid func\\(void\\);" "rbreak XXX/fullpath-expand-func.c:func"
+gdb_test "rbreak $realsrcfile2:func" "^Breakpoint 1 at 0x\[0-9a-f\]+: file [string_to_regexp ${subdir}/${srcfile2}], line \[0-9\]+\\.\r\nvoid func\\(void\\);" "rbreak XXX/fullpath-expand-func.c:func"
# Verify the compilation pathnames are as expected:
gdb_test "list func" "\tfunc \\(void\\)\r\n.*"
-gdb_test "info source" "^info source\r\nCurrent source file is [string_to_regexp ${subdir}/${srcfile2}]\r\nCompilation directory is /.*"
+gdb_test "info source" "^Current source file is [string_to_regexp ${subdir}/${srcfile2}]\r\nCompilation directory is /.*"
}
# Check that we restore input in GDB correctly.
-gdb_test "print 1" "^print 1\r\n.. = 1" "gdb input still works"
+gdb_test "print 1" "^\\\$$decimal = 1" "gdb input still works"
# Ensure echo remains enabled in both consoles.
with_spawn_id $con1_spawn_id {
- gdb_test "print 1" "^print 1\r\n\\\$1 = 1" "print on $con1_name echoes"
+ gdb_test "print 1" "\\\$1 = 1" "print on $con1_name echoes"
}
with_spawn_id $con2_spawn_id {
- gdb_test "print 2" "^print 2\r\n\\\$2 = 2" "print on $con2_name echoes"
+ gdb_test "print 2" "\\\$2 = 2" "print on $con2_name echoes"
}
}
# Run a command and use an anchor to make sure no output appears
# before the command's expected output.
- gdb_test "print 999" "^print 999\r\n\\\$$decimal = 999" $message
+ gdb_test "print 999" "^\\\$$decimal = 999" $message
}
# Run a few execution-related commands on CON1, and ensure the proper
# Ensure non-execution commands in one console don't cause output
# in the other consoles.
with_spawn_id $gdb_main_spawn_id {
- gdb_test "print 1" "^print 1\r\n\\\$1 = 1" "print on main console"
+ gdb_test "print 1" "^\\\$1 = 1" "print on main console"
}
with_spawn_id $extra_spawn_id {
- gdb_test "print 2" "^print 2\r\n\\\$2 = 2" "print on extra console"
+ gdb_test "print 2" "^\\\$2 = 2" "print on extra console"
}
# Verify that we get proper queries on the main UI, but that they are
# Checks that gdb doesn't crash if we haven't set the string yet.
if {$variant != "filename"} {
- gdb_test "$show_cmd" "^$show_cmd\r\n" "$show_cmd: show default"
+ # This odd expected output here is because we expect GDB to
+ # emit a single blank line as a result of this command.
+ gdb_test "$show_cmd" "^" "$show_cmd: show default"
} else {
gdb_test "$show_cmd" "/foo/bar" "$show_cmd: show default"
}
show_setting "$show_cmd" "\"hello world\""
} else {
gdb_test_no_output "$set_cmd"
- gdb_test "$show_cmd" \
- "^$show_cmd\r\n" "$show_cmd: empty second time"
+ # This odd expected output here is because we expect GDB to
+ # emit a single blank line as a result of this command.
+ gdb_test "$show_cmd" "^" "$show_cmd: empty second time"
}
}
# ...call the function
- gdb_test "p func1 ()" "^p func1 \\(\\)\r\n.\[0-9\]* = void" \
+ gdb_test "p func1 ()" "^\\\$$decimal = void" \
"p func1 () #1"
# ...veryfiy that the cout was updated
if {[runto marker1]} {
gdb_test "watch ival2" \
- "^watch ival2\r\n\[^\r\n\]*\[Ww\]atchpoint \[0-9\]*: ival2"
+ "^(?:Hardware w|W)atchpoint $::decimal: ival2"
# Well, let's not be too mundane. It should be a *bit* of a challenge
gdb_test "break func2 if 0" "Breakpoint.*at.*"
if {[runto marker4]} {
gdb_test "watch ptr1->val" \
- "^watch ptr1->val\r\n\[^\r\n\]*\[Ww\]atchpoint \[0-9\]*: ptr1->val"
+ "^(?:Hardware w|W)atchpoint $::decimal: ptr1->val"
gdb_test "break marker5" ".*Breakpoint.*"
gdb_test "cont" "Continuing.*\[Ww\]atchpoint.*ptr1->val.*Old value = 1.*New value = 2.*" "test complex watchpoint"
# execution exits the scope of the watchpoint.
#
gdb_test "watch local_a" \
- "^watch local_a\r\n\[^\r\n\]*\[Ww\]atchpoint \[0-9\]*: local_a" \
+ "^(?:Hardware w|W)atchpoint $::decimal: local_a" \
"set local watch"
gdb_test "cont" "\[Ww\]atchpoint.*local_a.*" "trigger local watch"
# of "func2". This should also auto-delete.
#
gdb_test "watch local_a + ival5" \
- "^watch local_a \\+ ival5\r\n\[^\r\n\]*\[Ww\]atchpoint \[0-9\]*: local_a . ival5" \
- "set partially local watch"
+ "^(?:Hardware w|W)atchpoint $::decimal: local_a . ival5" \
+ "set partially local watch"
gdb_test "cont" "Continuing.*\[Ww\]atchpoint .*: local_a . ival5.*" \
"trigger1 partially local watch"
gdb_test "cont" "Continuing.*\[Ww\]atchpoint .*: local_a . ival5.*" \
#
gdb_continue_to_breakpoint "func2 breakpoint here, third time"
gdb_test "watch static_b" \
- "^watch static_b\r\n\[^\r\n\]*\[Ww\]atchpoint \[0-9\]*: static_b" \
+ "^(?:Hardware w|W)atchpoint $::decimal: static_b" \
"set static local watch"
gdb_test "cont" "Continuing.*\[Ww\]atchpoint .*: static_b.*" \
"trigger static local watch"
gdb_test "cont" "Continuing.*recurser.*"
gdb_test "next" "if \\(x > 0.*" "next past local_x initialization"
gdb_test "watch local_x" \
- "^watch local_x\r\n\[^\r\n\]*\[Ww\]atchpoint \[0-9\]*: local_x" \
+ "^(?:Hardware w|W)atchpoint $::decimal: local_x" \
"set local watch in recursive call"
gdb_test "cont" "Continuing.*\[Ww\]atchpoint .*: local_x.*New value = 2.*" \
"trigger local watch in recursive call"
gdb_test "cont" "Continuing.*recurser.*" "continue to recurser"
gdb_test "next" "if \\(x > 0.*" "next past local_x initialization"
gdb_test "watch recurser::local_x" \
- "^watch recurser::local_x\r\n\[^\r\n\]*\[Ww\]atchpoint \[0-9\]*: recurser::local_x" \
+ "^(?:Hardware w|W)atchpoint $::decimal: recurser::local_x" \
"set local watch in recursive call with explicit scope"
gdb_test "cont" "Continuing.*\[Ww\]atchpoint .*: recurser::local_x.*New value = 2.*" \
"trigger local watch with explicit scope in recursive call"
gdb_breakpoint [gdb_get_line_number "second x assignment"]
gdb_continue_to_breakpoint "second x assignment"
gdb_test "watch x" \
- "^watch x\r\n\[^\r\n\]*\[Ww\]atchpoint \[0-9\]+: x"
+ "^(?:Hardware w|W)atchpoint $::decimal: x"
gdb_test "next" \
".*atchpoint \[0-9\]+: x\r\n\r\nOld value = 0\r\nNew value = 1\r\n.*" \
"next after watch x"
gdb_test "watch count + 6" ".*atchpoint \[0-9\]+: count \\+ 6"
gdb_test_no_output "delete \$bpnum" "delete watchpoint `count + 6'"
gdb_test "watch 7 + count" \
- "^watch 7 \\+ count\r\n\[^\r\n\]*atchpoint \[0-9\]+: 7 \\+ count"
+ "^(?:Hardware w|W)atchpoint $::decimal: 7 \\+ count"
gdb_test_no_output "delete \$bpnum" "delete watchpoint `7 + count'"
}
# for software watchpoints.
# Watch something not memory to force a software watchpoint.
- gdb_test {watch $pc} "^watch \\\$pc\r\n\[^\r\n\]*\[Ww\]atchpoint \[0-9\]+: .pc"
+ gdb_test {watch $pc} "^(?:Hardware w|W)atchpoint $::decimal: .pc"
gdb_test_no_output "disable \$bpnum" "disable watchpoint `\$pc'"
gdb_test_no_output "enable \$bpnum" "reenable watchpoint `\$pc'"
"show disable fast watches"
gdb_test "watch ival3 if count > 1" \
- "^watch ival3 if count > 1\r\nWatchpoint \[0-9\]*: ival3.*" \
+ "^Watchpoint \[0-9\]*: ival3.*" \
"set slow conditional watch"
gdb_test "continue" \
global gdb_prompt
with_test_prefix "$setting, $tmp_val" {
- set test "save org value"
set org_val ""
- gdb_test_multiple "maint show test-settings $setting" $test {
- -re "(.*)\r\n$gdb_prompt $" {
- set org_val $expect_out(1,string)
- pass $test
+ gdb_test_multiple "maint show test-settings $setting" \
+ "save org value" {
+ -re "^maint show test-settings $setting\r\n" {
+ exp_continue
+ }
+ -re "^(.*)\r\n$gdb_prompt $" {
+ set org_val $expect_out(1,string)
+ pass $gdb_test_name
+ }
}
- }
gdb_test \
"maint with test-settings $setting $tmp_val -- p 1" \
pass $test
}
}
-gdb_test "2" "^2\r\nBreakpoint \[0-9\]+ at 0x\[0-9a-f\]+: file thefile\\.cc, line \[0-9a-f\]+\\."
+gdb_test "2" "^Breakpoint \[0-9\]+ at 0x\[0-9a-f\]+: file thefile\\.cc, line \[0-9a-f\]+\\."
gdb_breakpoint "body_elsewhere"
pass $test
}
}
-gdb_test "3" "^3\r\nBreakpoint \[0-9\]+ at 0x\[0-9a-f\]+: file thefile\\.cc, line \[0-9a-f\]+\\."
+gdb_test "3" "^Breakpoint \[0-9\]+ at 0x\[0-9a-f\]+: file thefile\\.cc, line \[0-9a-f\]+\\."
gdb_breakpoint "body_elsewhere"
if { $gdb_spawn_id == $gdb_main_spawn_id } {
# CLI
gdb_test "print 666" \
- "^print 666\r\n\\\$$decimal = 666" \
+ "^\\\$$decimal = 666" \
"$test, ensure no output CLI"
} elseif { $gdb_spawn_id == $mi_spawn_id } {
# MI
pass $test
}
}
- gdb_test "q" "^q\r\nQuit" "pagination quit - $bttype - q"
+ gdb_test "q" "^Quit" "pagination quit - $bttype - q"
}
gdb_test_no_output "set height unlimited" "pagination quit - set height unlimited"
# The "quit" must be seen on the output. A buggy GDB
# would not display it.
- gdb_test "quit" "^quit.*leaving help.*" "quit help"
+ gdb_test "quit" "^\r\nYou are now leaving help.*" "quit help"
}
}
}
#
# COMMAND is the command to execute, send to GDB with send_gdb. If
# this is the null string no command is sent.
-# PATTERN is the pattern to match for a PASS, and must NOT include
-# the \r\n sequence immediately before the gdb prompt. This argument
-# may be omitted to just match the prompt, ignoring whatever output
-# precedes it.
+# PATTERN is the pattern to match for a PASS, and must NOT include the
+# \r\n sequence immediately before the gdb prompt (see -nonl below).
+# This argument may be omitted to just match the prompt, ignoring
+# whatever output precedes it. If PATTERN starts with '^' then
+# PATTERN will be anchored such that it should match all output from
+# COMMAND.
# MESSAGE is an optional message to be printed. If this is
# omitted, then the pass/fail messages use the command string as the
# message. (If this is the empty string, then sometimes we don't
set saw_question 0
+ # If the pattern starts with a '^' then we want to match all the
+ # output from COMMAND. To support this, here we inject an
+ # additional pattern that matches the command immediately after
+ # the '^'.
+ if {[string range $pattern 0 0] eq "^"} {
+ set command_regex [string_to_regexp $command]
+ set pattern [string range $pattern 1 end]
+ if {$command_regex ne ""} {
+ set pattern "^${command_regex}\r\n$pattern"
+ }
+ }
+
set user_code {}
lappend user_code {
-re "(?:$pattern)$nl$prompt" {