diff options
author | Andrew Burgess <aburgess@redhat.com> | 2023-03-29 10:41:07 +0100 |
---|---|---|
committer | Andrew Burgess <aburgess@redhat.com> | 2023-04-27 13:56:38 +0100 |
commit | 08ec06d6440745ef9204d39197aa1e732df41056 (patch) | |
tree | 3eac76fc93733286399bc74e02c1dff4f11bb489 /gdb | |
parent | e2f620135d92f7cd670af4e524fffec7ac307666 (diff) | |
download | gdb-08ec06d6440745ef9204d39197aa1e732df41056.zip gdb-08ec06d6440745ef9204d39197aa1e732df41056.tar.gz gdb-08ec06d6440745ef9204d39197aa1e732df41056.tar.bz2 |
gdb/testsuite: special case '^' in gdb_test pattern
In this commit I propose that we add special handling for the '^' when
used at the start of a gdb_test pattern. Consider this usage:
gdb_test "some_command" "^command output pattern"
I think the intention here is pretty clear - run 'some_command', and
the output from the command should be exactly 'command output
pattern'.
After the previous commit which tightened up how gdb_test matches the
final newline and prompt we know that the only thing after the output
pattern will be a single newline and prompt, and the leading '^'
ensures that there's no output before 'command output pattern', so
this will do what I want, right?
... except it doesn't. The command itself will also needs to be
matched, so I should really write:
gdb_test "some_command" "^some_command\r\ncommand output pattern"
which will do what I want, right? Well, that's fine until I change
the command and include some regexp character, then I have to write:
gdb_test "some_command" \
"^[string_to_regexp some_command]\r\ncommand output pattern"
but this all gets a bit verbose, so in most cases I simply don't
bother anchoring the output with a '^', and a quick scan of the
testsuite would indicate that most other folk don't both either.
What I propose is this: the *only* thing that can appear immediately
after the '^' is the command converted into a regexp, so lets do that
automatically, moving the work into gdb_test. Thus, when I write:
gdb_test "some_command" "^command output pattern"
Inside gdb_test we will spot the leading '^' in the pattern, and
inject the regexp version of the command after the '^', followed by a
'\r\n'.
My hope is that given this new ability, folk will be more inclined to
anchor their output patterns when this makes sense to do so. This
should increase our ability to catch any unexpected output from GDB
that appears as a result of running a particular command.
There is one problem case we need to consider, sometime people do
this:
gdb_test "" "^expected output pattern"
In this case no command is sent to GDB, but we are still expecting
some output from GDB. This might be a result of some asynchronous
event for example. As there is no command sent to GDB (from the
gdb_test) there will be no command text to parse.
In this case my proposed new feature injects the command regexp, which
is the empty string (as the command itself is empty), but still
injects the '\r\n' after the command regexp, thus we end up with this
pattern:
^\r\nexpected output pattern
This extra '\r\n' is not what we should expected here, and so there is
a special case inside gdb_test -- if the command is empty then don't
add anything after the '^' character.
There are a bunch of tests that do already use '^' followed by the
command, and these can all be simplified in this commit.
I've tried to run all the tests that I can to check this commit, but I
am certain that there will be some tests that I manage to miss.
Apologies for any regressions this commit causes, hopefully fixing the
regressions will not be too hard.
Reviewed-By: Tom Tromey <tom@tromey.com>
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/testsuite/gdb.arch/amd64-entry-value.exp | 59 | ||||
-rw-r--r-- | gdb/testsuite/gdb.arch/amd64-invalid-stack-middle.exp | 4 | ||||
-rw-r--r-- | gdb/testsuite/gdb.arch/amd64-invalid-stack-top.exp | 4 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/compare-sections.exp | 2 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/fullpath-expand.exp | 4 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/multi-line-starts-subshell.exp | 2 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/new-ui-echo.exp | 4 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/new-ui.exp | 6 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/settings.exp | 9 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/signals.exp | 2 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/watchpoint.exp | 24 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/with.exp | 15 | ||||
-rw-r--r-- | gdb/testsuite/gdb.linespec/break-ask.exp | 4 | ||||
-rw-r--r-- | gdb/testsuite/gdb.mi/user-selected-context-sync.exp | 2 | ||||
-rw-r--r-- | gdb/testsuite/gdb.python/py-framefilter.exp | 2 | ||||
-rw-r--r-- | gdb/testsuite/gdb.python/python.exp | 2 | ||||
-rw-r--r-- | gdb/testsuite/lib/gdb.exp | 22 |
17 files changed, 109 insertions, 58 deletions
diff --git a/gdb/testsuite/gdb.arch/amd64-entry-value.exp b/gdb/testsuite/gdb.arch/amd64-entry-value.exp index a700e9a..3c666ac 100644 --- a/gdb/testsuite/gdb.arch/amd64-entry-value.exp +++ b/gdb/testsuite/gdb.arch/amd64-entry-value.exp @@ -48,8 +48,11 @@ gdb_breakpoint "breakhere_reference" 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" @@ -61,21 +64,30 @@ gdb_test "p j@entry" { = 30\.5} "entry: p j@entry" 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" @@ -202,8 +214,13 @@ gdb_test "p nodataparam@entry" "Cannot resolve DW_AT_call_data_value" "entry_ref 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" @@ -243,8 +260,16 @@ gdb_test_multiple $test $test { 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. @@ -252,8 +277,14 @@ gdb_test "bt" "^bt\r\n#0 +d \\(i=<optimized out>, j=<optimized out>\\)\[^\r\n\]* 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.*" \ diff --git a/gdb/testsuite/gdb.arch/amd64-invalid-stack-middle.exp b/gdb/testsuite/gdb.arch/amd64-invalid-stack-middle.exp index 156300b..c90b92c 100644 --- a/gdb/testsuite/gdb.arch/amd64-invalid-stack-middle.exp +++ b/gdb/testsuite/gdb.arch/amd64-invalid-stack-middle.exp @@ -39,10 +39,10 @@ if ![runto breakpt] { 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} diff --git a/gdb/testsuite/gdb.arch/amd64-invalid-stack-top.exp b/gdb/testsuite/gdb.arch/amd64-invalid-stack-top.exp index b6a25f8..03edcef 100644 --- a/gdb/testsuite/gdb.arch/amd64-invalid-stack-top.exp +++ b/gdb/testsuite/gdb.arch/amd64-invalid-stack-top.exp @@ -43,10 +43,10 @@ if ![runto breakpt] { # 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} diff --git a/gdb/testsuite/gdb.base/compare-sections.exp b/gdb/testsuite/gdb.base/compare-sections.exp index f24ff16..7fa8939 100644 --- a/gdb/testsuite/gdb.base/compare-sections.exp +++ b/gdb/testsuite/gdb.base/compare-sections.exp @@ -38,7 +38,7 @@ proc compare_sections { {options ""} } { -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 $" { diff --git a/gdb/testsuite/gdb.base/fullpath-expand.exp b/gdb/testsuite/gdb.base/fullpath-expand.exp index 285d0be..82d3b24 100644 --- a/gdb/testsuite/gdb.base/fullpath-expand.exp +++ b/gdb/testsuite/gdb.base/fullpath-expand.exp @@ -41,8 +41,8 @@ if { $result != 0 || $realsrcfile2 == "" } { 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 /.*" diff --git a/gdb/testsuite/gdb.base/multi-line-starts-subshell.exp b/gdb/testsuite/gdb.base/multi-line-starts-subshell.exp index 640c3be..ee58691 100644 --- a/gdb/testsuite/gdb.base/multi-line-starts-subshell.exp +++ b/gdb/testsuite/gdb.base/multi-line-starts-subshell.exp @@ -52,4 +52,4 @@ gdb_test_multiple "if 1\nshell ${shell_cmd}\nend\nPS1=\"$shell_prompt\"" $test { } # 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" diff --git a/gdb/testsuite/gdb.base/new-ui-echo.exp b/gdb/testsuite/gdb.base/new-ui-echo.exp index efcc711..9618148 100644 --- a/gdb/testsuite/gdb.base/new-ui-echo.exp +++ b/gdb/testsuite/gdb.base/new-ui-echo.exp @@ -103,10 +103,10 @@ proc echo_test {driver} { # 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" } } diff --git a/gdb/testsuite/gdb.base/new-ui.exp b/gdb/testsuite/gdb.base/new-ui.exp index 2056d80..a6a38fa 100644 --- a/gdb/testsuite/gdb.base/new-ui.exp +++ b/gdb/testsuite/gdb.base/new-ui.exp @@ -28,7 +28,7 @@ proc ensure_no_output {message} { # 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 @@ -121,10 +121,10 @@ proc_with_prefix do_test {} { # 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 diff --git a/gdb/testsuite/gdb.base/settings.exp b/gdb/testsuite/gdb.base/settings.exp index e542039..eb127d2 100644 --- a/gdb/testsuite/gdb.base/settings.exp +++ b/gdb/testsuite/gdb.base/settings.exp @@ -540,7 +540,9 @@ proc test-string {variant} { # 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" } @@ -570,8 +572,9 @@ proc test-string {variant} { 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" } } diff --git a/gdb/testsuite/gdb.base/signals.exp b/gdb/testsuite/gdb.base/signals.exp index 338cf4b..de613a2 100644 --- a/gdb/testsuite/gdb.base/signals.exp +++ b/gdb/testsuite/gdb.base/signals.exp @@ -88,7 +88,7 @@ if {[runto_main]} { # ...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 diff --git a/gdb/testsuite/gdb.base/watchpoint.exp b/gdb/testsuite/gdb.base/watchpoint.exp index 917439e..7086465 100644 --- a/gdb/testsuite/gdb.base/watchpoint.exp +++ b/gdb/testsuite/gdb.base/watchpoint.exp @@ -277,7 +277,7 @@ proc test_stepping {} { 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.*" @@ -437,7 +437,7 @@ proc test_complex_watchpoint {} { 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" @@ -464,7 +464,7 @@ proc 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" @@ -495,8 +495,8 @@ proc test_complex_watchpoint {} { # 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.*" \ @@ -511,7 +511,7 @@ proc test_complex_watchpoint {} { # 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" @@ -531,7 +531,7 @@ proc test_complex_watchpoint {} { 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" @@ -547,7 +547,7 @@ proc test_complex_watchpoint {} { 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" @@ -574,7 +574,7 @@ proc test_watchpoint_and_breakpoint {} { 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" @@ -592,7 +592,7 @@ proc test_constant_watchpoint {} { 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'" } @@ -601,7 +601,7 @@ proc test_disable_enable_software_watchpoint {} { # 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'" @@ -835,7 +835,7 @@ proc test_no_hw_watchpoints {} { "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" \ diff --git a/gdb/testsuite/gdb.base/with.exp b/gdb/testsuite/gdb.base/with.exp index 233dc30..ebe84c0 100644 --- a/gdb/testsuite/gdb.base/with.exp +++ b/gdb/testsuite/gdb.base/with.exp @@ -54,14 +54,17 @@ proc test_with_error {setting tmp_val expected_re} { 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" \ diff --git a/gdb/testsuite/gdb.linespec/break-ask.exp b/gdb/testsuite/gdb.linespec/break-ask.exp index 8de8a95..251f7dd 100644 --- a/gdb/testsuite/gdb.linespec/break-ask.exp +++ b/gdb/testsuite/gdb.linespec/break-ask.exp @@ -68,7 +68,7 @@ gdb_test_multiple $cmd $test { 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" @@ -88,7 +88,7 @@ gdb_test_multiple $cmd $test { 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" diff --git a/gdb/testsuite/gdb.mi/user-selected-context-sync.exp b/gdb/testsuite/gdb.mi/user-selected-context-sync.exp index 9bcc90f..4889c31 100644 --- a/gdb/testsuite/gdb.mi/user-selected-context-sync.exp +++ b/gdb/testsuite/gdb.mi/user-selected-context-sync.exp @@ -500,7 +500,7 @@ proc ensure_no_output { test } { 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 diff --git a/gdb/testsuite/gdb.python/py-framefilter.exp b/gdb/testsuite/gdb.python/py-framefilter.exp index 6897518..f02fc86 100644 --- a/gdb/testsuite/gdb.python/py-framefilter.exp +++ b/gdb/testsuite/gdb.python/py-framefilter.exp @@ -97,7 +97,7 @@ foreach bttype [list "bt" "bt full"] { 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" diff --git a/gdb/testsuite/gdb.python/python.exp b/gdb/testsuite/gdb.python/python.exp index 8fe119f..7e9ddaa 100644 --- a/gdb/testsuite/gdb.python/python.exp +++ b/gdb/testsuite/gdb.python/python.exp @@ -69,7 +69,7 @@ with_test_prefix "python interactive help" { # 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" } } } diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 5fd084b..aed7e2d 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -1401,10 +1401,12 @@ proc gdb_test_multiline { name args } { # # 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 @@ -1458,6 +1460,18 @@ proc gdb_test { args } { 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" { |