[4/5] gdb/testsuite: change newline patterns used in gdb_test

Message ID 464e64e3a3483c228f0a73c778bcaf79e4595abd.1680293848.git.aburgess@redhat.com
State New
Headers
Series gdb/testsuite: stricter matching for gdb_test |

Commit Message

Andrew Burgess March 31, 2023, 8:20 p.m. UTC
  This commit makes two changes to how we match newline characters in
the gdb_test proc.

First, for the newline pattern between the command output and the
prompt, I propose changing from '[\r\n]+' to an explicit '\r\n'.

The old pattern would spot multiple newlines, and so there are a few
places where, as part of this commit, I've needed to add an extra
trailing '\r\n' to the pattern in the main test file, where GDB's
output actually includes a blank line.

But I think this is a good thing.  If a command produces a blank line
then we should be checking for it, the current test doesn't.

Additionally, the existing pattern will happily match a partial
newline.  There are a strangely large number of tests that end with a
random '.' character.  Not matching a literal period, but matching any
single character, this is then matching half of the trailing newline
sequence, while the \[\r\n\]+ in gdb_test is matching the other half
of the sequence.  I can think of no reason why this would be
intentional.  All of these are cleaned up after this commit.

The basic rule of gdb_test after this is that the expected pattern
needs to match everything up to, but not including the newline
sequence immediately before the GDB prompt.

Second, while I was cleaning up newline matching in gdb_test, I've
also removed the '[\r\n]*' that was added to the start of the pattern
passed to gdb_test_multiple.

The addition of this pattern adds no value.  If the user pattern
matches at the start of a line then this would match against the
newline sequence.  But, due to the '*', if the user pattern doesn't
match at the start of a line then this group doesn't care, it'll
happily match nothing.

As such, there's no value to it, it just adds more complexity for no
gain, so I'm removing it.  No tests will need updating as a
consequence of this part of the patch.
---
 gdb/testsuite/gdb.ada/varsize_limit.exp       |   2 +-
 gdb/testsuite/gdb.base/call-rt-st.exp         |   2 +-
 gdb/testsuite/gdb.base/charset.exp            |   4 +-
 gdb/testsuite/gdb.base/default.exp            |   4 +-
 gdb/testsuite/gdb.base/display.exp            |  10 +-
 gdb/testsuite/gdb.base/foll-fork.exp          |   2 +-
 gdb/testsuite/gdb.base/info-macros.exp        |  12 +-
 gdb/testsuite/gdb.base/pc-fp.exp              |   2 +-
 gdb/testsuite/gdb.base/pending.exp            |   2 +-
 gdb/testsuite/gdb.base/rtld-step.exp          |   4 +-
 gdb/testsuite/gdb.base/setshow.exp            |   4 +-
 gdb/testsuite/gdb.base/until.exp              |   2 +-
 gdb/testsuite/gdb.base/watch-bitfields.exp    |   4 +-
 .../gdb.base/wrong_frame_bt_full.exp          |   4 +-
 gdb/testsuite/gdb.btrace/buffer-size.exp      |   4 +-
 .../gdb.btrace/function_call_history.exp      |   2 +-
 .../gdb.btrace/instruction_history.exp        |  10 +-
 gdb/testsuite/gdb.btrace/record_goto.exp      |   8 +-
 .../gdb.cp/incomplete-type-overload.exp       |   2 +-
 gdb/testsuite/gdb.cp/maint.exp                |   8 +-
 gdb/testsuite/gdb.cp/ovldbreak.exp            |  14 +--
 gdb/testsuite/gdb.cp/userdef.exp              |  20 ++--
 gdb/testsuite/gdb.cp/virtfunc.exp             |  23 +++-
 gdb/testsuite/gdb.guile/scm-breakpoint.exp    |   2 +-
 gdb/testsuite/gdb.guile/scm-cmd.exp           |   2 +-
 gdb/testsuite/gdb.opt/inline-break.exp        |   6 +-
 gdb/testsuite/gdb.python/py-breakpoint.exp    |   6 +-
 .../gdb.reverse/machinestate-precsave.exp     |  60 +++++-----
 gdb/testsuite/gdb.reverse/machinestate.exp    |  60 +++++-----
 gdb/testsuite/gdb.stabs/exclfwd.exp           |   4 +-
 .../gdb.threads/foll-fork-other-thread.exp    |   2 +-
 gdb/testsuite/gdb.threads/gcore-thread.exp    |   4 +-
 gdb/testsuite/gdb.trace/actions.exp           | 109 +++++++++---------
 gdb/testsuite/gdb.trace/deltrace.exp          |  73 ++++++------
 gdb/testsuite/gdb.trace/infotrace.exp         |   6 +-
 gdb/testsuite/gdb.trace/passcount.exp         |   8 +-
 gdb/testsuite/gdb.trace/tracecmd.exp          |   8 +-
 gdb/testsuite/gdb.trace/while-stepping.exp    |   2 +-
 gdb/testsuite/lib/gdb.exp                     |   4 +-
 39 files changed, 264 insertions(+), 241 deletions(-)
  

Comments

Simon Marchi April 27, 2023, 7:39 p.m. UTC | #1
On 3/31/23 16:20, Andrew Burgess via Gdb-patches wrote:
> This commit makes two changes to how we match newline characters in
> the gdb_test proc.
> 
> First, for the newline pattern between the command output and the
> prompt, I propose changing from '[\r\n]+' to an explicit '\r\n'.
> 
> The old pattern would spot multiple newlines, and so there are a few
> places where, as part of this commit, I've needed to add an extra
> trailing '\r\n' to the pattern in the main test file, where GDB's
> output actually includes a blank line.
> 
> But I think this is a good thing.  If a command produces a blank line
> then we should be checking for it, the current test doesn't.
> 
> Additionally, the existing pattern will happily match a partial
> newline.  There are a strangely large number of tests that end with a
> random '.' character.  Not matching a literal period, but matching any
> single character, this is then matching half of the trailing newline
> sequence, while the \[\r\n\]+ in gdb_test is matching the other half
> of the sequence.  I can think of no reason why this would be
> intentional.  All of these are cleaned up after this commit.
> 
> The basic rule of gdb_test after this is that the expected pattern
> needs to match everything up to, but not including the newline
> sequence immediately before the GDB prompt.
> 
> Second, while I was cleaning up newline matching in gdb_test, I've
> also removed the '[\r\n]*' that was added to the start of the pattern
> passed to gdb_test_multiple.
> 
> The addition of this pattern adds no value.  If the user pattern
> matches at the start of a line then this would match against the
> newline sequence.  But, due to the '*', if the user pattern doesn't
> match at the start of a line then this group doesn't care, it'll
> happily match nothing.
> 
> As such, there's no value to it, it just adds more complexity for no
> gain, so I'm removing it.  No tests will need updating as a
> consequence of this part of the patch.

Hi Andrew,

Starting with this patch, I see many new failures in gdb.trace (using
one of the gdbserver boards), for instance the first one being:

  FAIL: gdb.trace/collection.exp: collect args collectively: collected arg char

Simon
  
Andrew Burgess April 28, 2023, 2:05 p.m. UTC | #2
Simon Marchi <simark@simark.ca> writes:

> On 3/31/23 16:20, Andrew Burgess via Gdb-patches wrote:
>> This commit makes two changes to how we match newline characters in
>> the gdb_test proc.
>> 
>> First, for the newline pattern between the command output and the
>> prompt, I propose changing from '[\r\n]+' to an explicit '\r\n'.
>> 
>> The old pattern would spot multiple newlines, and so there are a few
>> places where, as part of this commit, I've needed to add an extra
>> trailing '\r\n' to the pattern in the main test file, where GDB's
>> output actually includes a blank line.
>> 
>> But I think this is a good thing.  If a command produces a blank line
>> then we should be checking for it, the current test doesn't.
>> 
>> Additionally, the existing pattern will happily match a partial
>> newline.  There are a strangely large number of tests that end with a
>> random '.' character.  Not matching a literal period, but matching any
>> single character, this is then matching half of the trailing newline
>> sequence, while the \[\r\n\]+ in gdb_test is matching the other half
>> of the sequence.  I can think of no reason why this would be
>> intentional.  All of these are cleaned up after this commit.
>> 
>> The basic rule of gdb_test after this is that the expected pattern
>> needs to match everything up to, but not including the newline
>> sequence immediately before the GDB prompt.
>> 
>> Second, while I was cleaning up newline matching in gdb_test, I've
>> also removed the '[\r\n]*' that was added to the start of the pattern
>> passed to gdb_test_multiple.
>> 
>> The addition of this pattern adds no value.  If the user pattern
>> matches at the start of a line then this would match against the
>> newline sequence.  But, due to the '*', if the user pattern doesn't
>> match at the start of a line then this group doesn't care, it'll
>> happily match nothing.
>> 
>> As such, there's no value to it, it just adds more complexity for no
>> gain, so I'm removing it.  No tests will need updating as a
>> consequence of this part of the patch.
>
> Hi Andrew,
>
> Starting with this patch, I see many new failures in gdb.trace (using
> one of the gdbserver boards), for instance the first one being:
>
>   FAIL: gdb.trace/collection.exp: collect args collectively: collected arg char

Sorry for that.

I thought I'd run the gdbserver tests, but I guess not.

I have a fix for gdb.trace/collection.exp, I'm just running the full set
of tests to see if there are any other regressions I missed.

I'll push the fix(es) soon.

Thanks,
Andrew
  
Andrew Burgess April 28, 2023, 3:51 p.m. UTC | #3
Simon Marchi <simark@simark.ca> writes:

> On 3/31/23 16:20, Andrew Burgess via Gdb-patches wrote:
>> This commit makes two changes to how we match newline characters in
>> the gdb_test proc.
>> 
>> First, for the newline pattern between the command output and the
>> prompt, I propose changing from '[\r\n]+' to an explicit '\r\n'.
>> 
>> The old pattern would spot multiple newlines, and so there are a few
>> places where, as part of this commit, I've needed to add an extra
>> trailing '\r\n' to the pattern in the main test file, where GDB's
>> output actually includes a blank line.
>> 
>> But I think this is a good thing.  If a command produces a blank line
>> then we should be checking for it, the current test doesn't.
>> 
>> Additionally, the existing pattern will happily match a partial
>> newline.  There are a strangely large number of tests that end with a
>> random '.' character.  Not matching a literal period, but matching any
>> single character, this is then matching half of the trailing newline
>> sequence, while the \[\r\n\]+ in gdb_test is matching the other half
>> of the sequence.  I can think of no reason why this would be
>> intentional.  All of these are cleaned up after this commit.
>> 
>> The basic rule of gdb_test after this is that the expected pattern
>> needs to match everything up to, but not including the newline
>> sequence immediately before the GDB prompt.
>> 
>> Second, while I was cleaning up newline matching in gdb_test, I've
>> also removed the '[\r\n]*' that was added to the start of the pattern
>> passed to gdb_test_multiple.
>> 
>> The addition of this pattern adds no value.  If the user pattern
>> matches at the start of a line then this would match against the
>> newline sequence.  But, due to the '*', if the user pattern doesn't
>> match at the start of a line then this group doesn't care, it'll
>> happily match nothing.
>> 
>> As such, there's no value to it, it just adds more complexity for no
>> gain, so I'm removing it.  No tests will need updating as a
>> consequence of this part of the patch.
>
> Hi Andrew,
>
> Starting with this patch, I see many new failures in gdb.trace (using
> one of the gdbserver boards), for instance the first one being:
>
>   FAIL: gdb.trace/collection.exp: collect args collectively: collected arg char

I've pushed the patch below which fixes all the regressions I see when
using the native-gdbserver board.

I'm still testing with the native-extended-gdbserver board, but I'm a
little short of time, so might not be able to fix any regressions that
throws up until next week.  So I've pushed this fix for now, and will
follow up with any additional fixes I find later.

Sorry for causing the regressions.

Thanks,
Andrew

---

commit 1f7f972f59470104734ec705c985ab319eb580db
Author: Andrew Burgess <aburgess@redhat.com>
Date:   Fri Apr 28 14:39:03 2023 +0100

    gdb/testsuite: additional test fixes after gdb_test changes
    
    After this commit:
    
      commit e2f620135d92f7cd670af4e524fffec7ac307666
      Date:   Thu Mar 30 13:26:25 2023 +0100
    
          gdb/testsuite: change newline patterns used in gdb_test
    
    There were some regressions in gdb.trace/*.exp tests when run with the
    native-gdbserver board.  This commit fixes these regressions.
    
    All the problems are caused by unnecessary trailing newline characters
    included in the patterns passed to gdb_test.  After the above commit
    the testsuite is stricter when matching trailing newlines, and so the
    additional trailing newline characters are now causing the test to
    fail.  Fix by removing all the excess trailing newline characters.
    
    In some cases this cleanup means we should use gdb_test_no_output,
    I've done that where appropriate.  In a couple of other places I've
    made use of multi_line to better build the expected output pattern.

diff --git a/gdb/testsuite/gdb.trace/actions.exp b/gdb/testsuite/gdb.trace/actions.exp
index 2a2158886d8..879690ddffb 100644
--- a/gdb/testsuite/gdb.trace/actions.exp
+++ b/gdb/testsuite/gdb.trace/actions.exp
@@ -316,10 +316,10 @@ check_tracepoint "live"
 gdb_test_no_output "tstop" ""
 set tracefile [standard_output_file ${testfile}]
 gdb_test "tsave ${tracefile}.tf" \
-    "Trace data saved to file '${tracefile}.tf'\.\\r" \
+    "Trace data saved to file '${tracefile}.tf'\." \
     "tsave ${testfile}.tf"
 gdb_test "tsave -ctf ${tracefile}.ctf" \
-    "Trace data saved to directory '${tracefile}.ctf'\.\\r" \
+    "Trace data saved to directory '${tracefile}.ctf'\\." \
     "save ctf trace file"
 
 # Restart GDB and read the trace data in tfile target.
diff --git a/gdb/testsuite/gdb.trace/change-loc.exp b/gdb/testsuite/gdb.trace/change-loc.exp
index 1315a6d9028..e79f1f1559d 100644
--- a/gdb/testsuite/gdb.trace/change-loc.exp
+++ b/gdb/testsuite/gdb.trace/change-loc.exp
@@ -190,7 +190,7 @@ proc tracepoint_change_loc_2 { trace_type } {
 	# else is displayed.
 	gdb_test "info trace" \
 	    "Num     Type\[ \]+Disp Enb Address\[ \]+What.*
-\[0-9\]+\[\t \]+\(|fast \)tracepoint\[ \]+keep y.*PENDING.*set_tracepoint\r\n\[\t \]+collect \\$$pcreg\r" \
+\[0-9\]+\[\t \]+\(|fast \)tracepoint\[ \]+keep y.*PENDING.*set_tracepoint\r\n\[\t \]+collect \\$$pcreg" \
 	    "single pending tracepoint info (without symbols)"
 
 	gdb_load ${binfile}
diff --git a/gdb/testsuite/gdb.trace/collection.exp b/gdb/testsuite/gdb.trace/collection.exp
index 966e313d3bd..0bbf98b27b4 100644
--- a/gdb/testsuite/gdb.trace/collection.exp
+++ b/gdb/testsuite/gdb.trace/collection.exp
@@ -34,21 +34,19 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug nowarning
 # 8) expressions (lots of different kinds: local and global)
 
 set ws "\[\r\n\t \]+"
-set cr "\[\r\n\]+"
 
 #
 # Utility procs
 #
 
 proc test_register { reg test_id } {
-    global cr
     global gdb_prompt
 
     gdb_test_multiple "print /x $reg" "" {
-	-re "\\$\[0-9\]+ = \[x0\]+$cr$gdb_prompt $" {
+	-re "\\$\[0-9\]+ = \[x0\]+\r\n$gdb_prompt $" {
 	    fail "collect $test_id: collected $reg (zero)"
 	}
-	-re "\\$\[0-9\]+ = \[x0-9a-fA-F\]+$cr$gdb_prompt $" {
+	-re "\\$\[0-9\]+ = \[x0-9a-fA-F\]+\r\n$gdb_prompt $" {
 	    pass "collect $test_id: collected $reg"
 	}
 	-re "\[Ee\]rror.*$gdb_prompt $" {
@@ -81,8 +79,7 @@ proc run_trace_experiment { test_func } {
 	gdb_test "continue" \
 	    "Continuing.*Breakpoint \[0-9\]+, end.*" \
 	    "run trace experiment"
-	gdb_test "tstop" \
-	    "\[\r\n\]+" \
+	gdb_test_no_output "tstop" \
 	    "stop trace experiment"
 	gdb_test "tfind start" \
 	    "#0  $test_func .*" \
@@ -96,7 +93,6 @@ proc run_trace_experiment { test_func } {
 #
 
 proc gdb_collect_args_test { myargs msg } {
-    global cr
     global gdb_prompt
 
     with_test_prefix "collect $msg" {
@@ -133,30 +129,30 @@ proc gdb_collect_args_test { myargs msg } {
 	}
 
 	gdb_test "print argc" \
-	    "\\$\[0-9\]+ = 1 '.001'$cr" \
+	    "\\$\[0-9\]+ = 1 '.001'" \
 	    "collected arg char"
 	gdb_test "print argi" \
-	    "\\$\[0-9\]+ = 2$cr" \
+	    "\\$\[0-9\]+ = 2" \
 	    "collected arg int"
 	gdb_test "print argf" \
-	    "\\$\[0-9\]+ = 3.\[23\]\[0-9\]*$cr" \
+	    "\\$\[0-9\]+ = 3.\[23\]\[0-9\]*" \
 	    "collected arg float"
 	gdb_test "print argd" \
-	    "\\$\[0-9\]+ = 4.\[34\]\[0-9\]*$cr" \
+	    "\\$\[0-9\]+ = 4.\[34\]\[0-9\]*" \
 	    "collected arg double"
 
 	# struct arg as one of several args (near end of list)
 	gdb_test "print argstruct.memberc" \
-	    "\\$\[0-9\]+ = 101 'e'$cr" \
+	    "\\$\[0-9\]+ = 101 'e'" \
 	    "collected arg struct member char"
 	gdb_test "print argstruct.memberi" \
-	    "\\$\[0-9\]+ = 102$cr" \
+	    "\\$\[0-9\]+ = 102" \
 	    "collected arg struct member int"
 	gdb_test "print argstruct.memberf" \
-	    "\\$\[0-9\]+ = 103.\[23\]\[0-9\]*$cr" \
+	    "\\$\[0-9\]+ = 103.\[23\]\[0-9\]*" \
 	    "collected arg struct member float"
 	gdb_test "print argstruct.memberd" \
-	    "\\$\[0-9\]+ = 104.\[34\]\[0-9\]*$cr" \
+	    "\\$\[0-9\]+ = 104.\[34\]\[0-9\]*" \
 	    "collected arg struct member double"
 
 	# array arg as one of several args (near end of list)
@@ -170,22 +166,22 @@ proc gdb_collect_args_test { myargs msg } {
 
 	setup_xfail "*-*-*"
 	gdb_test "print argarray\[0\]" \
-	    "\\$\[0-9\]+ = 111$cr" \
+	    "\\$\[0-9\]+ = 111" \
 	    "collected argarray #0"
 
 	setup_xfail "*-*-*"
 	gdb_test "print argarray\[1\]" \
-	    "\\$\[0-9\]+ = 112$cr" \
+	    "\\$\[0-9\]+ = 112" \
 	    "collected argarray #1"
 
 	setup_xfail "*-*-*"
 	gdb_test "print argarray\[2\]" \
-	    "\\$\[0-9\]+ = 113$cr" \
+	    "\\$\[0-9\]+ = 113" \
 	    "collected argarray #2"
 
 	setup_xfail "*-*-*"
 	gdb_test "print argarray\[3\]" \
-	    "\\$\[0-9\]+ = 114$cr" \
+	    "\\$\[0-9\]+ = 114" \
 	    "collected argarray #3"
 
 	gdb_test "tfind none" \
@@ -195,7 +191,6 @@ proc gdb_collect_args_test { myargs msg } {
 }
 
 proc gdb_collect_argstruct_test { myargs msg } {
-    global cr
     global gdb_prompt
 
     with_test_prefix "collect $msg" {
@@ -213,16 +208,16 @@ proc gdb_collect_argstruct_test { myargs msg } {
 
 	# struct argument as only argument
 	gdb_test "print argstruct.memberc" \
-	    "\\$\[0-9\]+ = 101 'e'$cr" \
+	    "\\$\[0-9\]+ = 101 'e'" \
 	    "collected arg struct member char"
 	gdb_test "print argstruct.memberi" \
-	    "\\$\[0-9\]+ = 102$cr" \
+	    "\\$\[0-9\]+ = 102" \
 	    "collected arg struct member int"
 	gdb_test "print argstruct.memberf" \
-	    "\\$\[0-9\]+ = 103.\[23\]\[0-9\]*$cr" \
+	    "\\$\[0-9\]+ = 103.\[23\]\[0-9\]*" \
 	    "collected arg struct member float"
 	gdb_test "print argstruct.memberd" \
-	    "\\$\[0-9\]+ = 104.\[34\]\[0-9\]*$cr" \
+	    "\\$\[0-9\]+ = 104.\[34\]\[0-9\]*" \
 	    "collected arg struct member double"
 
 	gdb_test "tfind none" \
@@ -233,7 +228,6 @@ proc gdb_collect_argstruct_test { myargs msg } {
 
 
 proc gdb_collect_argarray_test { myargs msg } {
-    global cr
     global gdb_prompt
 
     with_test_prefix "collect $msg" {
@@ -261,22 +255,22 @@ proc gdb_collect_argarray_test { myargs msg } {
 
 	setup_xfail "*-*-*"
 	gdb_test "print argarray\[0\]" \
-	    "\\$\[0-9\]+ = 111$cr" \
+	    "\\$\[0-9\]+ = 111" \
 	    "collected argarray #0"
 
 	setup_xfail "*-*-*"
 	gdb_test "print argarray\[1\]" \
-	    "\\$\[0-9\]+ = 112$cr" \
+	    "\\$\[0-9\]+ = 112" \
 	    "collected argarray #1"
 
 	setup_xfail "*-*-*"
 	gdb_test "print argarray\[2\]" \
-	    "\\$\[0-9\]+ = 113$cr" \
+	    "\\$\[0-9\]+ = 113" \
 	    "collected argarray #2"
 
 	setup_xfail "*-*-*"
 	gdb_test "print argarray\[3\]" \
-	    "\\$\[0-9\]+ = 114$cr" \
+	    "\\$\[0-9\]+ = 114" \
 	    "collected argarray #3"
 
 	gdb_test "tfind none" \
@@ -287,7 +281,6 @@ proc gdb_collect_argarray_test { myargs msg } {
 
 
 proc gdb_collect_locals_test { func mylocs msg } {
-    global cr
     global gdb_prompt
 
     with_test_prefix "collect $msg" {
@@ -321,42 +314,42 @@ proc gdb_collect_locals_test { func mylocs msg } {
 	run_trace_experiment $func
 
 	gdb_test "print locc" \
-	    "\\$\[0-9\]+ = 11 '.\[a-z0-7\]+'$cr" \
+	    "\\$\[0-9\]+ = 11 '.\[a-z0-7\]+'" \
 	    "collected local char"
 	gdb_test "print loci" \
-	    "\\$\[0-9\]+ = 12$cr" \
+	    "\\$\[0-9\]+ = 12" \
 	    "collected local int"
 	gdb_test "print locf" \
-	    "\\$\[0-9\]+ = 13.\[23\]\[0-9\]*$cr" \
+	    "\\$\[0-9\]+ = 13.\[23\]\[0-9\]*" \
 	    "collected local float"
 	gdb_test "print locd" \
-	    "\\$\[0-9\]+ = 14.\[34\]\[0-9\]*$cr" \
+	    "\\$\[0-9\]+ = 14.\[34\]\[0-9\]*" \
 	    "collected local double"
 
 	gdb_test "print locst.memberc" \
-	    "\\$\[0-9\]+ = 15 '.017'$cr" \
+	    "\\$\[0-9\]+ = 15 '.017'" \
 	    "collected local member char"
 	gdb_test "print locst.memberi" \
-	    "\\$\[0-9\]+ = 16$cr" \
+	    "\\$\[0-9\]+ = 16" \
 	    "collected local member int"
 	gdb_test "print locst.memberf" \
-	    "\\$\[0-9\]+ = 17.\[67\]\[0-9\]*$cr" \
+	    "\\$\[0-9\]+ = 17.\[67\]\[0-9\]*" \
 	    "collected local member float"
 	gdb_test "print locst.memberd" \
-	    "\\$\[0-9\]+ = 18.\[78\]\[0-9\]*$cr" \
+	    "\\$\[0-9\]+ = 18.\[78\]\[0-9\]*" \
 	    "collected local member double"
 
 	gdb_test "print locar\[0\]" \
-	    "\\$\[0-9\]+ = 121$cr" \
+	    "\\$\[0-9\]+ = 121" \
 	    "collected locarray #0"
 	gdb_test "print locar\[1\]" \
-	    "\\$\[0-9\]+ = 122$cr" \
+	    "\\$\[0-9\]+ = 122" \
 	    "collected locarray #1"
 	gdb_test "print locar\[2\]" \
-	    "\\$\[0-9\]+ = 123$cr" \
+	    "\\$\[0-9\]+ = 123" \
 	    "collected locarray #2"
 	gdb_test "print locar\[3\]" \
-	    "\\$\[0-9\]+ = 124$cr" \
+	    "\\$\[0-9\]+ = 124" \
 	    "collected locarray #3"
 
 	gdb_test "tfind none" \
@@ -366,7 +359,6 @@ proc gdb_collect_locals_test { func mylocs msg } {
 }
 
 proc gdb_collect_registers_test { myregs } {
-    global cr
     global gdb_prompt
     global fpreg
     global spreg
@@ -397,7 +389,6 @@ proc gdb_collect_registers_test { myregs } {
 }
 
 proc gdb_collect_expression_test { func expr val msg } {
-    global cr
     global gdb_prompt
 
     prepare_for_trace_test
@@ -431,7 +422,7 @@ proc gdb_collect_expression_test { func expr val msg } {
 	run_trace_experiment $func
 
 	gdb_test "print $expr" \
-	    "\\$\[0-9\]+ = $val$cr" \
+	    "\\$\[0-9\]+ = $val" \
 	    "got expected value '$val'"
 
 	gdb_test "tfind none" \
@@ -441,7 +432,6 @@ proc gdb_collect_expression_test { func expr val msg } {
 }
 
 proc gdb_collect_globals_test { } {
-    global cr
     global gdb_prompt
 
     with_test_prefix "collect globals" {
@@ -493,49 +483,49 @@ proc gdb_collect_globals_test { } {
 	run_trace_experiment globals_test_func
 
 	gdb_test "print globalc" \
-	    "\\$\[0-9\]+ = 71 'G'$cr" \
+	    "\\$\[0-9\]+ = 71 'G'" \
 	    "collected global char"
 	gdb_test "print globali" \
-	    "\\$\[0-9\]+ = 72$cr" \
+	    "\\$\[0-9\]+ = 72" \
 	    "collected global int"
 	gdb_test "print globalf" \
-	    "\\$\[0-9\]+ = 73.\[23\]\[0-9\]*$cr" \
+	    "\\$\[0-9\]+ = 73.\[23\]\[0-9\]*" \
 	    "collected global float"
 	gdb_test "print globald" \
-	    "\\$\[0-9\]+ = 74.\[34\]\[0-9\]*$cr" \
+	    "\\$\[0-9\]+ = 74.\[34\]\[0-9\]*" \
 	    "collected global double"
 
 	gdb_test "print globalstruct.memberc" \
-	    "\\$\[0-9\]+ = 81 'Q'$cr" \
+	    "\\$\[0-9\]+ = 81 'Q'" \
 	    "collected struct char member"
 	gdb_test "print globalstruct.memberi" \
-	    "\\$\[0-9\]+ = 82$cr" \
+	    "\\$\[0-9\]+ = 82" \
 	    "collected struct member int"
 	gdb_test "print globalstruct.memberf" \
-	    "\\$\[0-9\]+ = 83.\[23\]\[0-9\]*$cr" \
+	    "\\$\[0-9\]+ = 83.\[23\]\[0-9\]*" \
 	    "collected struct member float"
 	gdb_test "print globalstruct.memberd" \
-	    "\\$\[0-9\]+ = 84.\[34\]\[0-9\]*$cr" \
+	    "\\$\[0-9\]+ = 84.\[34\]\[0-9\]*" \
 	    "collected struct member double"
 
 	gdb_test "print globalp == &globalstruct" \
-	    "\\$\[0-9\]+ = 1$cr" \
+	    "\\$\[0-9\]+ = 1" \
 	    "collected global pointer"
 
 	gdb_test "print globalarr\[1\]" \
-	    "\\$\[0-9\]+ = 1$cr" \
+	    "\\$\[0-9\]+ = 1" \
 	    "collected global array element #1"
 	gdb_test "print globalarr\[2\]" \
-	    "\\$\[0-9\]+ = 2$cr" \
+	    "\\$\[0-9\]+ = 2" \
 	    "collected global array element #2"
 	gdb_test "print globalarr\[3\]" \
-	    "\\$\[0-9\]+ = 3$cr" \
+	    "\\$\[0-9\]+ = 3" \
 	    "collected global array element #3"
 
 	# Check that we didn't mess up sort&merging memory ranges to
 	# collect.
 	gdb_test "print globalarr2" \
-	    "\\$\[0-9\]+ = \\{0, 1, 2, 3\\}$cr" \
+	    "\\$\[0-9\]+ = \\{0, 1, 2, 3\\}" \
 	    "collected global array 2"
 
 	# GDB would internal error collecting UNOP_MEMVAL's whose address
@@ -543,7 +533,7 @@ proc gdb_collect_globals_test { } {
 	# corresponding 'collect' action above).  This just double checks
 	# we actually did collect what we wanted.
 	gdb_test "print globalarr3" \
-	    "\\$\[0-9\]+ = \\{3, 2, 1, 0\\}$cr" \
+	    "\\$\[0-9\]+ = \\{3, 2, 1, 0\\}" \
 	    "collect globals: collected global array 3"
 
 	gdb_test "tfind none" \
@@ -633,7 +623,6 @@ proc gdb_collect_return_test { } {
 
 proc gdb_collect_strings_test { func mystr myrslt mylim msg } {
     global hex
-    global cr
     global gdb_prompt
 
     with_test_prefix "collect $msg" {
@@ -667,7 +656,7 @@ proc gdb_collect_strings_test { func mystr myrslt mylim msg } {
 	run_trace_experiment $func
 
 	gdb_test "print $mystr" \
-	    "\\$\[0-9\]+ = $hex \"$myrslt\".*$cr" \
+	    "\\$\[0-9\]+ = $hex \"$myrslt\".*" \
 	    "collected local string"
 
 	gdb_test "tfind none" \
diff --git a/gdb/testsuite/gdb.trace/infotrace.exp b/gdb/testsuite/gdb.trace/infotrace.exp
index 97ef66b8df2..cff6ab06e00 100644
--- a/gdb/testsuite/gdb.trace/infotrace.exp
+++ b/gdb/testsuite/gdb.trace/infotrace.exp
@@ -114,12 +114,13 @@ gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*" \
 gdb_test_no_output "tstop"
 gdb_test "tstatus"
 gdb_test "info tracepoints" \
-    "Num     Type\[ \]+Disp Enb Address\[ \]+What.*
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_c_test at .*$srcfile:\[0-9\]+.
-\[\t \]+tracepoint already hit 1 time.
-\[\t \]+trace buffer usage ${decimal} bytes.
-\[\t \]+collect gdb_struct1_test.
-\tinstalled on target.
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_asm_test at .*$srcfile:\[0-9\]+.
-\tinstalled on target." \
+    [multi_line \
+	 "Num     Type\[ \]+Disp Enb Address\[ \]+What.*" \
+	 "\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_c_test at .*$srcfile:\[0-9\]+" \
+	 "\[\t \]+tracepoint already hit 1 time" \
+	 "\[\t \]+trace buffer usage ${decimal} bytes" \
+	 "\[\t \]+collect gdb_struct1_test" \
+	 "\tinstalled on target" \
+	 "\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_asm_test at .*$srcfile:\[0-9\]+" \
+	 "\tinstalled on target"] \
     "2.6: info tracepoints (trace buffer usage)"
diff --git a/gdb/testsuite/gdb.trace/pending.exp b/gdb/testsuite/gdb.trace/pending.exp
index da355bcdaee..a2db61729d1 100644
--- a/gdb/testsuite/gdb.trace/pending.exp
+++ b/gdb/testsuite/gdb.trace/pending.exp
@@ -154,7 +154,7 @@ proc pending_tracepoint_works { trace_type } {
 	gdb_test "continue" "Continuing.\r\n\r\n(Thread .* hit )?Breakpoint.*marker.*at.*$srcfile.*" \
 	    "continue to marker"
 
-	gdb_test "tstop" "\[\r\n\]+" "stop trace experiment"
+	gdb_test_no_output "tstop" "stop trace experiment"
 
 	gdb_test "tfind start" "#0 .*" "tfind test frame 0"
 	gdb_test "tfind" "Found trace frame 1, tracepoint 1.*" \
@@ -222,7 +222,7 @@ proc pending_tracepoint_resolved_during_trace { trace_type } \
 	}
     }
 
-    gdb_test "tstop" "\[\r\n\]+" "stop trace experiment"
+    gdb_test_no_output "tstop" "stop trace experiment"
 
     # tracepoint should be resolved.
     gdb_test "info trace" \
@@ -294,7 +294,7 @@ proc pending_tracepoint_installed_during_trace { trace_type } \
        }
     }
 
-    gdb_test "tstop" "\[\r\n\]+" "stop trace experiment"
+    gdb_test_no_output "tstop" "stop trace experiment"
 
     # tracepoint should be resolved.
     gdb_test "info trace" \
@@ -466,7 +466,7 @@ proc pending_tracepoint_with_action_resolved { trace_type } \
 
     }
 
-    gdb_test "tstop" "\[\r\n\]+" "stop trace experiment"
+    gdb_test_no_output "tstop" "stop trace experiment"
 
     # tracepoint should be resolved.
     gdb_test "info trace" \
diff --git a/gdb/testsuite/gdb.trace/stap-trace.exp b/gdb/testsuite/gdb.trace/stap-trace.exp
index 39c2fa02ca1..5b556f50a07 100644
--- a/gdb/testsuite/gdb.trace/stap-trace.exp
+++ b/gdb/testsuite/gdb.trace/stap-trace.exp
@@ -19,7 +19,6 @@ standard_testfile
 set executable ""
 
 set ws "\[\r\n\t \]+"
-set cr "\[\r\n\]+"
 
 # Only x86 and x86_64 targets are supported for now.
 
@@ -73,8 +72,7 @@ proc run_trace_experiment { test_probe msg } {
     gdb_test "continue" \
 	    "Continuing.*Breakpoint \[0-9\]+.*" \
 	    "collect $msg: run trace experiment"
-    gdb_test "tstop" \
-	    "\[\r\n\]+" \
+    gdb_test_no_output "tstop" \
 	    "collect $msg: stop trace experiment"
     gdb_test "tfind start" \
 	    "#0 .*" \
@@ -83,7 +81,6 @@ proc run_trace_experiment { test_probe msg } {
 
 proc gdb_collect_probe_arg { msg probe val_arg0 } {
     global gdb_prompt
-    global cr
 
     prepare_for_trace_test
 
@@ -98,7 +95,7 @@ proc gdb_collect_probe_arg { msg probe val_arg0 } {
     run_trace_experiment $msg $probe
 
     gdb_test "print \$_probe_arg0" \
-	    "\\$\[0-9\]+ = $val_arg0$cr" \
+	    "\\$\[0-9\]+ = $val_arg0" \
 	    "collect $msg: collected probe arg0"
 }
 
diff --git a/gdb/testsuite/gdb.trace/unavailable.exp b/gdb/testsuite/gdb.trace/unavailable.exp
index dfb1067d198..3e2e2c95f55 100644
--- a/gdb/testsuite/gdb.trace/unavailable.exp
+++ b/gdb/testsuite/gdb.trace/unavailable.exp
@@ -24,7 +24,6 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile \
 }
 
 set ws "\[\r\n\t \]+"
-set cr "\[\r\n\]+"
 
 #
 # Utility procs
@@ -33,13 +32,12 @@ set cr "\[\r\n\]+"
 proc test_register { reg } {
     global gdb_prompt
     global hex
-    global cr
 
     gdb_test_multiple "print /x $reg" "collected $reg" {
-	-re "\\$\[0-9\]+ = \[x0\]+$cr$gdb_prompt $" {
+	-re "\\$\[0-9\]+ = \[x0\]+\r\n$gdb_prompt $" {
 	    fail "collected $reg (zero)"
 	}
-	-re "\\$\[0-9\]+ = $hex$cr$gdb_prompt $" {
+	-re "\\$\[0-9\]+ = $hex\r\n$gdb_prompt $" {
 	    pass "collected $reg"
 	}
 	-re "\[Ee\]rror.*$gdb_prompt $" {
@@ -77,8 +75,7 @@ proc run_trace_experiment { test_func } {
     gdb_test "continue" \
 	    "Continuing.*Breakpoint \[0-9\]+, end.*" \
 	    "run trace experiment"
-    gdb_test "tstop" \
-	    "\[\r\n\]+" \
+    gdb_test_no_output "tstop" \
 	    "stop trace experiment"
     gdb_test "tfind start" \
 	    "#0  $test_func .*" \
@@ -120,8 +117,6 @@ proc test_maybe_regvar_display { var } {
 #
 
 proc gdb_collect_args_test_1 {} {
-    global cr
-
     # Test printing the variables, and also their addresses.  We
     # haven't collected any stack, so there's no way GDB can figure
     # out the latter.
@@ -159,13 +154,13 @@ proc gdb_collect_args_test_1 {} {
     gdb_test "print argarray\[0\]" "value is not available"
 
     # Test "info args"
-    set r ""
-    set r "${r}argc = <unavailable>${cr}"
-    set r "${r}argi = <unavailable>${cr}"
-    set r "${r}argf = <unavailable>${cr}"
-    set r "${r}argd = <unavailable>${cr}"
-    set r "${r}argstruct = <unavailable>${cr}"
-    set r "${r}argarray = <unavailable>${cr}"
+    set r [multi_line \
+	       "argc = <unavailable>" \
+	       "argi = <unavailable>" \
+	       "argf = <unavailable>" \
+	       "argd = <unavailable>" \
+	       "argstruct = <unavailable>" \
+	       "argarray = <unavailable>"]
     gdb_test "info args" "$r" "info args"
 
     test_maybe_regvar_display "argc"
@@ -194,10 +189,10 @@ proc gdb_collect_args_test {} {
 
 	set tracefile [standard_output_file ${testfile}]
 	gdb_test "tsave ${tracefile}.args.tfile" \
-	    "Trace data saved to file '${tracefile}.args.tfile'\.\\r" \
+	    "Trace data saved to file '${tracefile}.args.tfile'\\." \
 	    "tsave ${testfile}.args.tfile"
 	gdb_test "tsave -ctf ${tracefile}.args.ctf" \
-	    "Trace data saved to directory '${tracefile}.args.ctf'\.\\r" \
+	    "Trace data saved to directory '${tracefile}.args.ctf'\\." \
 	    "save ctf trace file"
 
 	foreach target_name ${trace_file_targets} {
@@ -217,8 +212,6 @@ proc gdb_collect_args_test {} {
 }
 
 proc gdb_collect_locals_test_1 { func } {
-    global cr
-
     gdb_test "print locc" " = <unavailable>"
     gdb_test "print loci" " = <unavailable>"
     gdb_test "print locf" " = <unavailable>"
@@ -236,16 +229,16 @@ proc gdb_collect_locals_test_1 { func } {
 
     # Test "info locals"
     set r ""
-    set r "${r}locf = <unavailable>${cr}"
-    set r "${r}locd = <unavailable>${cr}"
-    set r "${r}locst = <unavailable>${cr}"
-    set r "${r}locar = <unavailable>${cr}"
-    set r "${r}i = <unavailable>${cr}"
+    set r "${r}locf = <unavailable>"
+    set r "${r}locd = <unavailable>"
+    set r "${r}locst = <unavailable>"
+    set r "${r}locar = <unavailable>"
+    set r "${r}i = <unavailable>"
     if { $func == "local_test_func" } {
-	set r "${r}locdefst = <unavailable>${cr}"
+	set r "${r}locdefst = <unavailable>"
     }
-    set r "${r}locc = <unavailable>${cr}"
-    set r "${r}loci = <unavailable>${cr}"
+    set r "${r}locc = <unavailable>"
+    set r "${r}loci = <unavailable>"
     gdb_test "info locals" "$r" "info locals"
 
     test_maybe_regvar_display "loci"
@@ -276,10 +269,10 @@ proc gdb_collect_locals_test { func msg } {
 
 	set tracefile [standard_output_file ${testfile}]
 	gdb_test "tsave ${tracefile}.locals.tfile" \
-	    "Trace data saved to file '${tracefile}.locals.tfile'\.\\r" \
+	    "Trace data saved to file '${tracefile}.locals.tfile'\\." \
 	    "tsave ${testfile}.locals.tfile"
 	gdb_test "tsave -ctf ${tracefile}.locals.ctf" \
-	    "Trace data saved to directory '${tracefile}.locals.ctf'\.\\r" \
+	    "Trace data saved to directory '${tracefile}.locals.ctf'\\." \
 	    "save ctf trace file"
 
 	foreach target_name ${trace_file_targets} {
@@ -357,10 +350,10 @@ proc gdb_unavailable_registers_test { } {
 
 	set tracefile [standard_output_file ${testfile}]
 	gdb_test "tsave ${tracefile}.registers.tfile" \
-	    "Trace data saved to file '${tracefile}.registers.tfile'\.\\r" \
+	    "Trace data saved to file '${tracefile}.registers.tfile'\\." \
 	    "tsave ${testfile}.registers.tfile"
 	gdb_test "tsave -ctf ${tracefile}.registers.ctf" \
-	    "Trace data saved to directory '${tracefile}.registers.ctf'\.\\r" \
+	    "Trace data saved to directory '${tracefile}.registers.ctf'\\." \
 	    "save ctf trace file"
 
 	foreach target_name ${trace_file_targets} {
@@ -419,10 +412,10 @@ proc gdb_unavailable_floats { } {
 
 	set tracefile [standard_output_file ${testfile}]
 	gdb_test "tsave ${tracefile}.floats.tfile" \
-	    "Trace data saved to file '${tracefile}.floats.tfile'\.\\r" \
+	    "Trace data saved to file '${tracefile}.floats.tfile'\\." \
 	    "tsave ${testfile}.floats.tfile"
 	gdb_test "tsave -ctf ${tracefile}.floats.ctf" \
-	    "Trace data saved to directory '${tracefile}.floats.ctf'\.\\r" \
+	    "Trace data saved to directory '${tracefile}.floats.ctf'\\." \
 	    "save ctf trace file"
 
 	foreach target_name ${trace_file_targets} {
@@ -443,7 +436,6 @@ proc gdb_unavailable_floats { } {
 
 proc gdb_collect_globals_test_1 { } {
     global ws
-    global cr
     global gdb_prompt
     global hex
 
@@ -522,7 +514,7 @@ proc gdb_collect_globals_test_1 { } {
 	"global reference shows address but not value"
 
     gdb_test "print *&g_ref" \
-	"\\$\[0-9\]+ = <unavailable>$cr" \
+	"\\$\[0-9\]+ = <unavailable>" \
 	"referenced integer was not collected (taking address of reference)"
 
     gdb_test "print *g_structref_p" " = <unavailable>"
@@ -531,7 +523,7 @@ proc gdb_collect_globals_test_1 { } {
 
     # Const string is always available, even when not collected.
     gdb_test "print g_const_string" \
-	" = \"hello world\"$cr" \
+	" = \"hello world\"" \
 	"non collected const string is still printable"
 
     gdb_test "print g_string_p" \
@@ -552,7 +544,7 @@ proc gdb_collect_globals_test_1 { } {
     # variable being set to <unavailable> without error.
     set msg "examining partially collected object"
     gdb_test_multiple "x /10x &struct_b" "$msg" {
-	-re "$hex <struct_b>:${ws}<unavailable>${ws}<unavailable>${ws}<unavailable>${ws}<unavailable>$cr$hex <struct_b\\+16>:${ws}<unavailable>${ws}<unavailable>${ws}0xaaaaaaaa${ws}<unavailable>$cr$hex <struct_b\\+32>:${ws}<unavailable>${ws}<unavailable>$cr$gdb_prompt $" {
+	-re "$hex <struct_b>:${ws}<unavailable>${ws}<unavailable>${ws}<unavailable>${ws}<unavailable>\r\n$hex <struct_b\\+16>:${ws}<unavailable>${ws}<unavailable>${ws}0xaaaaaaaa${ws}<unavailable>\r\n$hex <struct_b\\+32>:${ws}<unavailable>${ws}<unavailable>\r\n$gdb_prompt $" {
 	    pass "$msg"
 	}
 	-re "value is not available" {
@@ -685,10 +677,10 @@ proc gdb_collect_globals_test { } {
 
 	set tracefile [standard_output_file ${testfile}]
 	gdb_test "tsave ${tracefile}.globals.tfile" \
-	    "Trace data saved to file '${tracefile}.globals.tfile'\.\\r" \
+	    "Trace data saved to file '${tracefile}.globals.tfile'\\." \
 	    "tsave ${testfile}.globals.tfile"
 	gdb_test "tsave -ctf ${tracefile}.globals.ctf" \
-	    "Trace data saved to directory '${tracefile}.globals.ctf'\.\\r" \
+	    "Trace data saved to directory '${tracefile}.globals.ctf'\\." \
 	    "save ctf trace file"
 
 	foreach target_name ${trace_file_targets} {
diff --git a/gdb/testsuite/gdb.trace/while-stepping.exp b/gdb/testsuite/gdb.trace/while-stepping.exp
index 21cc2ee8298..c2bb55ea278 100644
--- a/gdb/testsuite/gdb.trace/while-stepping.exp
+++ b/gdb/testsuite/gdb.trace/while-stepping.exp
@@ -137,10 +137,10 @@ check_tracepoint "live"
 gdb_test_no_output "tstop"
 set tracefile [standard_output_file ${testfile}]
 gdb_test "tsave ${tracefile}.tf" \
-    "Trace data saved to file '${tracefile}.tf'\.\\r" \
+    "Trace data saved to file '${tracefile}.tf'\\." \
     "save tfile trace file"
 gdb_test "tsave -ctf ${tracefile}.ctf" \
-    "Trace data saved to directory '${tracefile}.ctf'\.\\r" \
+    "Trace data saved to directory '${tracefile}.ctf'\\." \
     "save ctf trace file"
 
 # Restart GDB and read the trace data in tfile target.
  
Simon Marchi April 28, 2023, 3:57 p.m. UTC | #4
> I've pushed the patch below which fixes all the regressions I see when
> using the native-gdbserver board.
> 
> I'm still testing with the native-extended-gdbserver board, but I'm a
> little short of time, so might not be able to fix any regressions that
> throws up until next week.  So I've pushed this fix for now, and will
> follow up with any additional fixes I find later.
> 
> Sorry for causing the regressions.

Thanks, I'll let you know if there are more remaining failures.

Simon
  
Simon Marchi April 28, 2023, 6:37 p.m. UTC | #5
On 4/28/23 11:57, Simon Marchi via Gdb-patches wrote:
>> I've pushed the patch below which fixes all the regressions I see when
>> using the native-gdbserver board.
>>
>> I'm still testing with the native-extended-gdbserver board, but I'm a
>> little short of time, so might not be able to fix any regressions that
>> throws up until next week.  So I've pushed this fix for now, and will
>> follow up with any additional fixes I find later.
>>
>> Sorry for causing the regressions.
> 
> Thanks, I'll let you know if there are more remaining failures.
> 
> Simon
> 

I still see these two, which are likely related:

FAIL: gdb.trace/collection.exp: collect register locals collectively: run trace experiment: stop trace experiment
FAIL: gdb.trace/pending.exp: ftrace works: stop trace experiment

Simon
  
Andrew Burgess April 28, 2023, 9:50 p.m. UTC | #6
Simon Marchi <simark@simark.ca> writes:

> On 4/28/23 11:57, Simon Marchi via Gdb-patches wrote:
>>> I've pushed the patch below which fixes all the regressions I see when
>>> using the native-gdbserver board.
>>>
>>> I'm still testing with the native-extended-gdbserver board, but I'm a
>>> little short of time, so might not be able to fix any regressions that
>>> throws up until next week.  So I've pushed this fix for now, and will
>>> follow up with any additional fixes I find later.
>>>
>>> Sorry for causing the regressions.
>> 
>> Thanks, I'll let you know if there are more remaining failures.
>> 
>> Simon
>> 
>
> I still see these two, which are likely related:
>
> FAIL: gdb.trace/collection.exp: collect register locals collectively: run trace experiment: stop trace experiment

I think we should accept this regression.  Here's the gdb.log output:

  (gdb) PASS: gdb.trace/collection.exp: collect register locals collectively: run trace experiment: run trace experiment
  tstop
  Trace is not running.
  (gdb) FAIL: gdb.trace/collection.exp: collect register locals collectively: run trace experiment: stop trace experiment

I changed this test form this:

	gdb_test "tstop" \
	    "\[\r\n\]+" \
	    "stop trace experiment"

to this:

	gdb_test_no_output "tstop" \
	    "stop trace experiment"

The 'Trace is not running.' error is what causes the test to fail.  This
test has a bunch of other FAILs, one of which is the 'tstart' preceeding
the above 'tstop':

  (gdb) PASS: gdb.trace/collection.exp: collect register locals collectively: run trace experiment: advance to begin
  tstart
  locf has been optimized out of existence.
  locd has been optimized out of existence.
  Expression pieces exceed word size
  (gdb) FAIL: gdb.trace/collection.exp: collect register locals collectively: run trace experiment: start trace experiment

So clearly, the test script is expecting the tracing to start, but it
doesn't.  Catching things like the above -- where we were missing a
warning/error from GDB was exactly the point of my patch -- so I think
this additional failure is acceptable.

> FAIL: gdb.trace/pending.exp: ftrace works: stop trace experiment

I'm not able to reproduce this one.  On my local machine the
pending_tracepoint_works proc (in pending.exp) exits early as (according
to the comment) the target was unable to install the fast tracepoint.

Could you confirm that the 'tstart' test immediately preceding this
'tstop' test passes successfully please, it's name will be:

  gdb.trace/pending.exp: ftrace works: start trace experiment

If this FAILs then I think, like the one above then it's OK that the
corresponding tstop also FAILs.  If you are seeing the 'tstart' PASS
then could you paste in the corresponding gdb.log snippet and I'll see
if I can spot the problem.

Thanks,
Andrew
  
Tom de Vries April 29, 2023, 3:20 p.m. UTC | #7
On 3/31/23 22:20, Andrew Burgess via Gdb-patches wrote:
> This commit makes two changes to how we match newline characters in
> the gdb_test proc.

Hi,

the -wrap used in gdb_test_multiple is defined in terms of gdb_test 
semantics, but it doesn't seem to have been updated to match the new 
behaviour in gdb_test.

I've filed a PR about this regression ( 
https://sourceware.org/bugzilla/show_bug.cgi?id=30403 ).

Thanks,
- Tom
  
Andrew Burgess May 1, 2023, 2:33 p.m. UTC | #8
Tom de Vries <tdevries@suse.de> writes:

> On 3/31/23 22:20, Andrew Burgess via Gdb-patches wrote:
>> This commit makes two changes to how we match newline characters in
>> the gdb_test proc.
>
> Hi,
>
> the -wrap used in gdb_test_multiple is defined in terms of gdb_test 
> semantics, but it doesn't seem to have been updated to match the new 
> behaviour in gdb_test.
>
> I've filed a PR about this regression ( 
> https://sourceware.org/bugzilla/show_bug.cgi?id=30403 ).

Sorry for any problems caused.  I'm not working today, but if this has
not been addressed, I'll look at this on Tuesday.

Thanks,
Andrew
  
Tom de Vries May 1, 2023, 3:10 p.m. UTC | #9
On 5/1/23 16:33, Andrew Burgess wrote:
> Tom de Vries <tdevries@suse.de> writes:
> 
>> On 3/31/23 22:20, Andrew Burgess via Gdb-patches wrote:
>>> This commit makes two changes to how we match newline characters in
>>> the gdb_test proc.
>>
>> Hi,
>>
>> the -wrap used in gdb_test_multiple is defined in terms of gdb_test
>> semantics, but it doesn't seem to have been updated to match the new
>> behaviour in gdb_test.
>>
>> I've filed a PR about this regression (
>> https://sourceware.org/bugzilla/show_bug.cgi?id=30403 ).
> 
> Sorry for any problems caused.  I'm not working today, but if this has
> not been addressed, I'll look at this on Tuesday.

AFAIU it's a silent regression, so there are no problems in term of 
FAILs, it's just that more work is required.

FWIW, I think the root cause for introducing this regression silently is 
that we try to implement the same thing in two different locations, and 
it's just easy for things to get out of sync.  I recently fixed 
something similar in commit 4fa173cfd79 ("[gdb/testsuite] Fix -wrap in 
presence of -prompt in gdb_test_multiple"), that's why I noticed it.

Thanks,
- Tom
  
Andrew Burgess May 2, 2023, 11:13 a.m. UTC | #10
Tom de Vries <tdevries@suse.de> writes:

> On 5/1/23 16:33, Andrew Burgess wrote:
>> Tom de Vries <tdevries@suse.de> writes:
>> 
>>> On 3/31/23 22:20, Andrew Burgess via Gdb-patches wrote:
>>>> This commit makes two changes to how we match newline characters in
>>>> the gdb_test proc.
>>>
>>> Hi,
>>>
>>> the -wrap used in gdb_test_multiple is defined in terms of gdb_test
>>> semantics, but it doesn't seem to have been updated to match the new
>>> behaviour in gdb_test.
>>>
>>> I've filed a PR about this regression (
>>> https://sourceware.org/bugzilla/show_bug.cgi?id=30403 ).
>> 
>> Sorry for any problems caused.  I'm not working today, but if this has
>> not been addressed, I'll look at this on Tuesday.
>
> AFAIU it's a silent regression, so there are no problems in term of 
> FAILs, it's just that more work is required.
>
> FWIW, I think the root cause for introducing this regression silently is 
> that we try to implement the same thing in two different locations, and 
> it's just easy for things to get out of sync.  I recently fixed 
> something similar in commit 4fa173cfd79 ("[gdb/testsuite] Fix -wrap in 
> presence of -prompt in gdb_test_multiple"), that's why I noticed it.

So I believe the patch below brings gdb_test_multiple with '-wrap' back
into line with gdb_test.  I also updated a couple of other places that
used the same (old) gdb_test pattern.

There were nowhere near as many regressions with this change as with
gdb_test.  Let me know what you think.

Thanks,
Andrew

---

commit 807658d7a9a32632554006e822ae8645cc4cabb6
Author: Andrew Burgess <aburgess@redhat.com>
Date:   Tue May 2 10:56:55 2023 +0100

    gdb/testsuite: more newline pattern cleanup
    
    After this commit:
    
      commit e2f620135d92f7cd670af4e524fffec7ac307666
      Date:   Thu Mar 30 13:26:25 2023 +0100
    
          gdb/testsuite: change newline patterns used in gdb_test
    
    It was pointed out in PR gdb/30403 that the same patterns can be found
    in other lib/gdb.exp procs and that it would probably be a good idea
    if these procs remained in sync with gdb_test.  Actually, the bug
    specifically calls out gdb_test_multiple when using with '-wrap', but
    I found a couple of other locations in gdb_continue_to_breakpoint,
    gdb_test_multiline, get_valueof, and get_local_valueof.
    
    In all these locations one or both of the following issues are
    addressed:
    
      1. A leading pattern of '[\r\n]*' is pointless.  If there is a
      newline it will be matched, but if there is not then the testsuite
      doesn't care.  Also, as expect is happy to skip non-matched output
      at the start of a pattern, if there is a newline expect is happy to
      skip over it before matching the rest.  As such, this leading
      pattern is removed.
    
      2. Using '\[\r\n\]*$gdb_prompt' means that we will swallow
      unexpected blank lines at the end of a command's output, but also,
      if the pattern from the test script ends with a '\r', '\n', or '.'
      then these will partially match the trailing newline, with the
      remainder of the newline matched by the pattern from gdb.exp.  This
      split matching doesn't add any value, it's just something that has
      appeared as a consequence of how gdb.exp was originally written.  In
      this case the '\[\r\n\]*' is replaced with '\r\n'.
    
    I've rerun the testsuite and fixed the regressions that I saw, these
    were places where GDB emits a blank line at the end of the command
    output, which we now need to explicitly match in the test script, this
    was for:
    
      gdb.dwarf2/dw2-out-of-range-end-of-seq.exp
      gdb.guile/guile.exp
      gdb.python/python.exp
    
    Or a location where the test script was matching part of the newline
    sequence, while gdb.exp was previously matching the remainder of the
    newline sequence.  Now we rely on gdb.exp to match the complete
    newline sequence, this was for:
    
      gdb.base/commands.exp
    
    Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30403

diff --git a/gdb/testsuite/gdb.base/commands.exp b/gdb/testsuite/gdb.base/commands.exp
index ec2015ebef5..36918ed1a3f 100644
--- a/gdb/testsuite/gdb.base/commands.exp
+++ b/gdb/testsuite/gdb.base/commands.exp
@@ -725,7 +725,7 @@ maintenance deprecate set qqq_aaa"
 
 proc_with_prefix deprecated_command_alias_help_test {} {
     gdb_test_multiline "define real_command" \
-	"define real_command" "End with a line saying just \"end\".." \
+	"define real_command" "End with a line saying just \"end\"\\." \
 	"print 1" "" \
 	"end" ""
 
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-out-of-range-end-of-seq.exp b/gdb/testsuite/gdb.dwarf2/dw2-out-of-range-end-of-seq.exp
index bd3ea5b5d54..d2c28a87923 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-out-of-range-end-of-seq.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-out-of-range-end-of-seq.exp
@@ -88,7 +88,7 @@ gdb_test_multiple "maint info line-table $srcfile$" $test {
     -re -wrap "END *0x0*1 *$hex *Y *\r\n.*" {
 	fail $gdb_test_name
     }
-    -re -wrap "END *$hex *$hex *Y *" {
+    -re -wrap "END *$hex *$hex *Y *\r\n" {
 	pass $gdb_test_name
     }
 }
diff --git a/gdb/testsuite/gdb.guile/guile.exp b/gdb/testsuite/gdb.guile/guile.exp
index 7d0c063583d..ee8b2718178 100644
--- a/gdb/testsuite/gdb.guile/guile.exp
+++ b/gdb/testsuite/gdb.guile/guile.exp
@@ -63,7 +63,7 @@ gdb_test_multiline "show guile command" \
   "(print 23)" "" \
   "end" "" \
   "end" "" \
-  "show user zzq" "User command \"zzq\":.*  guile.*\\(print 23\\).*  end"
+  "show user zzq" "User command \"zzq\":.*  guile.*\\(print 23\\).*  end\r\n"
 
 gdb_test "source $host_source2_scm" "yes" "source source2.scm"
 
diff --git a/gdb/testsuite/gdb.python/python.exp b/gdb/testsuite/gdb.python/python.exp
index 7e9ddaa6fcd..584e52c0661 100644
--- a/gdb/testsuite/gdb.python/python.exp
+++ b/gdb/testsuite/gdb.python/python.exp
@@ -80,7 +80,7 @@ gdb_test_multiline "show python command" \
   "print (23)" "" \
   "end" "" \
   "end" "" \
-  "show user zzq" "User command \"zzq\":.*  python.*print \\(23\\).*  end"
+  "show user zzq" "User command \"zzq\":.*  python.*print \\(23\\).*  end\r\n"
 
 gdb_test_multiline "indented multi-line python command" \
   "python" "" \
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index aed7e2d043c..50c10333df1 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -818,7 +818,7 @@ proc gdb_continue_to_breakpoint {name {location_pattern .*}} {
 	-re "(?:Breakpoint|Temporary breakpoint) .* (at|in) $location_pattern\r\n$gdb_prompt $" {
 	    pass $full_name
 	}
-	-re "\[\r\n\]*(?:$kfail_pattern)\[\r\n\]+$gdb_prompt $" {
+	-re "(?:$kfail_pattern)\r\n$gdb_prompt $" {
 	    kfail "gdb/25038" $full_name
 	}
     }
@@ -1126,7 +1126,7 @@ proc gdb_test_multiple { command message args } {
 	if { $wrap_pattern } {
 	    # Wrap subst_item as is done for the gdb_test PATTERN argument.
 	    lappend $current_list \
-		"\[\r\n\]*(?:$subst_item)\[\r\n\]+$prompt_regexp"
+		"(?:$subst_item)\r\n$prompt_regexp"
 	    set wrap_pattern 0
 	} else {
 	    lappend $current_list $subst_item
@@ -1384,7 +1384,7 @@ proc gdb_test_multiline { name args } {
     foreach {input result} $args {
 	incr inputnr
 	if {[gdb_test_multiple $input "$name: input $inputnr: $input" {
-	    -re "\[\r\n\]*($result)\[\r\n\]+($gdb_prompt | *>)$" {
+	    -re "($result)\r\n($gdb_prompt | *>)$" {
 		pass $gdb_test_name
 	    }
 	}]} {
@@ -7746,7 +7746,7 @@ proc get_valueof { fmt exp default {test ""} } {
 
     set val ${default}
     gdb_test_multiple "print${fmt} ${exp}" "$test" {
-	-re "\\$\[0-9\]* = (\[^\r\n\]*)\[\r\n\]*$gdb_prompt $" {
+	-re "\\$\[0-9\]* = (\[^\r\n\]*)\r\n$gdb_prompt $" {
 	    set val $expect_out(1,string)
 	    pass "$test"
 	}
@@ -7770,7 +7770,7 @@ proc get_local_valueof { exp default {test ""} } {
 
     set val ${default}
     gdb_test_multiple "info locals ${exp}" "$test" {
-	-re "$exp = (\[^\r\n\]*)\[\r\n\]*$gdb_prompt $" {
+	-re "$exp = (\[^\r\n\]*)\r\n$gdb_prompt $" {
 	    set val $expect_out(1,string)
 	    pass "$test"
 	}
  
Tom de Vries May 2, 2023, 2:48 p.m. UTC | #11
On 5/2/23 13:13, Andrew Burgess wrote:
> Tom de Vries <tdevries@suse.de> writes:
> 
>> On 5/1/23 16:33, Andrew Burgess wrote:
>>> Tom de Vries <tdevries@suse.de> writes:
>>>
>>>> On 3/31/23 22:20, Andrew Burgess via Gdb-patches wrote:
>>>>> This commit makes two changes to how we match newline characters in
>>>>> the gdb_test proc.
>>>>
>>>> Hi,
>>>>
>>>> the -wrap used in gdb_test_multiple is defined in terms of gdb_test
>>>> semantics, but it doesn't seem to have been updated to match the new
>>>> behaviour in gdb_test.
>>>>
>>>> I've filed a PR about this regression (
>>>> https://sourceware.org/bugzilla/show_bug.cgi?id=30403 ).
>>>
>>> Sorry for any problems caused.  I'm not working today, but if this has
>>> not been addressed, I'll look at this on Tuesday.
>>
>> AFAIU it's a silent regression, so there are no problems in term of
>> FAILs, it's just that more work is required.
>>
>> FWIW, I think the root cause for introducing this regression silently is
>> that we try to implement the same thing in two different locations, and
>> it's just easy for things to get out of sync.  I recently fixed
>> something similar in commit 4fa173cfd79 ("[gdb/testsuite] Fix -wrap in
>> presence of -prompt in gdb_test_multiple"), that's why I noticed it.
> 
> So I believe the patch below brings gdb_test_multiple with '-wrap' back
> into line with gdb_test.  I also updated a couple of other places that
> used the same (old) gdb_test pattern.
> 
> There were nowhere near as many regressions with this change as with
> gdb_test.  Let me know what you think.
> 

I've applied the patch and tested it, and saw no regression.  I've also 
reviewed the patch and LGTM.

However, I've now also realized that the ^ bit is missing, which was 
also added in this patch series.

In other words, say we have:
...
gdb_test "print 1" "^.$decimal = 1"
...
which passes fine.

But then we want to annotate the PASS message with the captured 
$decimal, and rewrite into:
...
gdb_test_multiple "print 1" "" {
     -re -wrap "^.($decimal) = 1" {
         set var_nr $expect_output(1,string)
         pass "$gdb_test_name (var_nr: $var_nr)"
     }
}
...
This FAILs because ^ at the start of the pattern is not handled the same 
way by -wrap as by gdb_test.

Thanks,
- Tom
  
Simon Marchi May 2, 2023, 7:16 p.m. UTC | #12
On 4/28/23 17:50, Andrew Burgess wrote:
> Simon Marchi <simark@simark.ca> writes:
> 
>> On 4/28/23 11:57, Simon Marchi via Gdb-patches wrote:
>>>> I've pushed the patch below which fixes all the regressions I see when
>>>> using the native-gdbserver board.
>>>>
>>>> I'm still testing with the native-extended-gdbserver board, but I'm a
>>>> little short of time, so might not be able to fix any regressions that
>>>> throws up until next week.  So I've pushed this fix for now, and will
>>>> follow up with any additional fixes I find later.
>>>>
>>>> Sorry for causing the regressions.
>>>
>>> Thanks, I'll let you know if there are more remaining failures.
>>>
>>> Simon
>>>
>>
>> I still see these two, which are likely related:
>>
>> FAIL: gdb.trace/collection.exp: collect register locals collectively: run trace experiment: stop trace experiment
> 
> I think we should accept this regression.  Here's the gdb.log output:
> 
>   (gdb) PASS: gdb.trace/collection.exp: collect register locals collectively: run trace experiment: run trace experiment
>   tstop
>   Trace is not running.
>   (gdb) FAIL: gdb.trace/collection.exp: collect register locals collectively: run trace experiment: stop trace experiment
> 
> I changed this test form this:
> 
> 	gdb_test "tstop" \
> 	    "\[\r\n\]+" \
> 	    "stop trace experiment"
> 
> to this:
> 
> 	gdb_test_no_output "tstop" \
> 	    "stop trace experiment"
> 
> The 'Trace is not running.' error is what causes the test to fail.  This
> test has a bunch of other FAILs, one of which is the 'tstart' preceeding
> the above 'tstop':
> 
>   (gdb) PASS: gdb.trace/collection.exp: collect register locals collectively: run trace experiment: advance to begin
>   tstart
>   locf has been optimized out of existence.
>   locd has been optimized out of existence.
>   Expression pieces exceed word size
>   (gdb) FAIL: gdb.trace/collection.exp: collect register locals collectively: run trace experiment: start trace experiment
> 
> So clearly, the test script is expecting the tracing to start, but it
> doesn't.  Catching things like the above -- where we were missing a
> warning/error from GDB was exactly the point of my patch -- so I think
> this additional failure is acceptable.

That makes sense (it would have been obvious if I had looked at it, but
didn't really have time).  I'll add it to my list of expected failures,
since it's just the consequence of an existing failure.

>> FAIL: gdb.trace/pending.exp: ftrace works: stop trace experiment
> 
> I'm not able to reproduce this one.  On my local machine the
> pending_tracepoint_works proc (in pending.exp) exits early as (according
> to the comment) the target was unable to install the fast tracepoint.
> 
> Could you confirm that the 'tstart' test immediately preceding this
> 'tstop' test passes successfully please, it's name will be:
> 
>   gdb.trace/pending.exp: ftrace works: start trace experiment
> 
> If this FAILs then I think, like the one above then it's OK that the
> corresponding tstop also FAILs.  If you are seeing the 'tstart' PASS
> then could you paste in the corresponding gdb.log snippet and I'll see
> if I can spot the problem.

The "start trace experiment" fails too, so it's probably the same thing
as the previous one.

Thanks for looking into it!

Simon
  
Andrew Burgess May 5, 2023, 5:01 p.m. UTC | #13
Tom de Vries <tdevries@suse.de> writes:

> On 5/2/23 13:13, Andrew Burgess wrote:
>> Tom de Vries <tdevries@suse.de> writes:
>> 
>>> On 5/1/23 16:33, Andrew Burgess wrote:
>>>> Tom de Vries <tdevries@suse.de> writes:
>>>>
>>>>> On 3/31/23 22:20, Andrew Burgess via Gdb-patches wrote:
>>>>>> This commit makes two changes to how we match newline characters in
>>>>>> the gdb_test proc.
>>>>>
>>>>> Hi,
>>>>>
>>>>> the -wrap used in gdb_test_multiple is defined in terms of gdb_test
>>>>> semantics, but it doesn't seem to have been updated to match the new
>>>>> behaviour in gdb_test.
>>>>>
>>>>> I've filed a PR about this regression (
>>>>> https://sourceware.org/bugzilla/show_bug.cgi?id=30403 ).
>>>>
>>>> Sorry for any problems caused.  I'm not working today, but if this has
>>>> not been addressed, I'll look at this on Tuesday.
>>>
>>> AFAIU it's a silent regression, so there are no problems in term of
>>> FAILs, it's just that more work is required.
>>>
>>> FWIW, I think the root cause for introducing this regression silently is
>>> that we try to implement the same thing in two different locations, and
>>> it's just easy for things to get out of sync.  I recently fixed
>>> something similar in commit 4fa173cfd79 ("[gdb/testsuite] Fix -wrap in
>>> presence of -prompt in gdb_test_multiple"), that's why I noticed it.
>> 
>> So I believe the patch below brings gdb_test_multiple with '-wrap' back
>> into line with gdb_test.  I also updated a couple of other places that
>> used the same (old) gdb_test pattern.
>> 
>> There were nowhere near as many regressions with this change as with
>> gdb_test.  Let me know what you think.
>> 
>
> I've applied the patch and tested it, and saw no regression.  I've also 
> reviewed the patch and LGTM.

Thanks Tom,

I've gone ahead and pushed this patch -- fixing up the newline issues.

>
> However, I've now also realized that the ^ bit is missing, which was 
> also added in this patch series.
>
> In other words, say we have:
> ...
> gdb_test "print 1" "^.$decimal = 1"
> ...
> which passes fine.
>
> But then we want to annotate the PASS message with the captured 
> $decimal, and rewrite into:
> ...
> gdb_test_multiple "print 1" "" {
>      -re -wrap "^.($decimal) = 1" {
>          set var_nr $expect_output(1,string)
>          pass "$gdb_test_name (var_nr: $var_nr)"
>      }
> }
> ...
> This FAILs because ^ at the start of the pattern is not handled the same 
> way by -wrap as by gdb_test.

I'm working on an updated patch that addresses the '^' feature for
gdb_test_multiple.  I'm still testing this locally, and it will probably
be next week now before I post this -- but I will get this done, watch
this space :)

Thanks,
Andrew
  
Andrew Burgess May 9, 2023, 9:54 a.m. UTC | #14
Andrew Burgess <aburgess@redhat.com> writes:

> Tom de Vries <tdevries@suse.de> writes:
>
>> On 5/2/23 13:13, Andrew Burgess wrote:
>>> Tom de Vries <tdevries@suse.de> writes:
>>> 
>>>> On 5/1/23 16:33, Andrew Burgess wrote:
>>>>> Tom de Vries <tdevries@suse.de> writes:
>>>>>
>>>>>> On 3/31/23 22:20, Andrew Burgess via Gdb-patches wrote:
>>>>>>> This commit makes two changes to how we match newline characters in
>>>>>>> the gdb_test proc.
>>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> the -wrap used in gdb_test_multiple is defined in terms of gdb_test
>>>>>> semantics, but it doesn't seem to have been updated to match the new
>>>>>> behaviour in gdb_test.
>>>>>>
>>>>>> I've filed a PR about this regression (
>>>>>> https://sourceware.org/bugzilla/show_bug.cgi?id=30403 ).
>>>>>
>>>>> Sorry for any problems caused.  I'm not working today, but if this has
>>>>> not been addressed, I'll look at this on Tuesday.
>>>>
>>>> AFAIU it's a silent regression, so there are no problems in term of
>>>> FAILs, it's just that more work is required.
>>>>
>>>> FWIW, I think the root cause for introducing this regression silently is
>>>> that we try to implement the same thing in two different locations, and
>>>> it's just easy for things to get out of sync.  I recently fixed
>>>> something similar in commit 4fa173cfd79 ("[gdb/testsuite] Fix -wrap in
>>>> presence of -prompt in gdb_test_multiple"), that's why I noticed it.
>>> 
>>> So I believe the patch below brings gdb_test_multiple with '-wrap' back
>>> into line with gdb_test.  I also updated a couple of other places that
>>> used the same (old) gdb_test pattern.
>>> 
>>> There were nowhere near as many regressions with this change as with
>>> gdb_test.  Let me know what you think.
>>> 
>>
>> I've applied the patch and tested it, and saw no regression.  I've also 
>> reviewed the patch and LGTM.
>
> Thanks Tom,
>
> I've gone ahead and pushed this patch -- fixing up the newline issues.
>
>>
>> However, I've now also realized that the ^ bit is missing, which was 
>> also added in this patch series.
>>
>> In other words, say we have:
>> ...
>> gdb_test "print 1" "^.$decimal = 1"
>> ...
>> which passes fine.
>>
>> But then we want to annotate the PASS message with the captured 
>> $decimal, and rewrite into:
>> ...
>> gdb_test_multiple "print 1" "" {
>>      -re -wrap "^.($decimal) = 1" {
>>          set var_nr $expect_output(1,string)
>>          pass "$gdb_test_name (var_nr: $var_nr)"
>>      }
>> }
>> ...
>> This FAILs because ^ at the start of the pattern is not handled the same 
>> way by -wrap as by gdb_test.
>
> I'm working on an updated patch that addresses the '^' feature for
> gdb_test_multiple.  I'm still testing this locally, and it will probably
> be next week now before I post this -- but I will get this done, watch
> this space :)

Tom,

Below is a patch that extends the '^' support to gdb_test_multiple (when
-wrap is used).

Let me know what you think.

Thanks,
Andrew

---

commit 1355a1d7eca5c1dac1c74c98634389525c78d877
Author: Andrew Burgess <aburgess@redhat.com>
Date:   Tue May 9 10:28:42 2023 +0100

    gdb/testsuite: extend special '^' handling to gdb_test_multiple
    
    The commit:
    
      commit 08ec06d6440745ef9204d39197aa1e732df41056
      Date:   Wed Mar 29 10:41:07 2023 +0100
    
          gdb/testsuite: special case '^' in gdb_test pattern
    
    Added some special handling of '^' to gdb_test -- a leading '^' will
    cause the command regexp to automatically be included in the expected
    output pattern.
    
    It was pointed out that the '-wrap' flag of gdb_test_multiple is
    supposed to work in the same way as gdb_test, and that the recent
    changes for '^' had not been replicated for gdb_test_multiple.  This
    patch addresses this issue.
    
    So, after this commit, the following two constructs should have the
    same meaning:
    
      gdb_test "command" "^output" "test name"
    
      gdb_test_multiple "command" "test name" {
        -re -wrap "^output" {
          pass $gdb_test_name
        }
      }
    
    In both cases the '^' will case gdb.exp to inject a regexp that
    matches 'command' after the '^' and before the 'output', this is in
    addition to adding the $gdb_prompt pattern after 'output' in the
    normal way.
    
    The special '^' handling is only applied when '-wrap' is used, as this
    is the only mode that aims to mimic gdb_test.
    
    While working on this patch I realised that I could actually improve
    the logic for the special '^' handling in the case where the expected
    output pattern is empty.  I replicated these updates for both gdb_test
    and gdb_test_multiple in order to keep these two paths in sync.
    
    There were a small number of tests that needed adjustment after this
    change, mostly just removing command regexps that are now added
    automatically, but the gdb.base/settings.exp case was a little weird
    as it turns out trying to match a single blank line is probably harder
    now than it used to be -- still, I suspect this is a pretty rare case,
    so I think the benefits (improved anchoring) outweigh this small
    downside (IMHO).

diff --git a/gdb/testsuite/gdb.base/bitshift.exp b/gdb/testsuite/gdb.base/bitshift.exp
index adc5996d736..5ea0cd870ed 100644
--- a/gdb/testsuite/gdb.base/bitshift.exp
+++ b/gdb/testsuite/gdb.base/bitshift.exp
@@ -24,19 +24,17 @@ clean_restart
 # expected error.  If WARNING_OR_ERROR is empty, it is expected that
 # GDB prints no text other than the print result.
 proc test_shift {lang cmd result_re {warning_or_error ""}} {
-    set cmd_re [string_to_regexp $cmd]
-
     if {$lang == "go"} {
 	if {$warning_or_error != ""} {
 	    set error_re "[string_to_regexp $warning_or_error]"
 	    gdb_test_multiple $cmd "" {
-		-re -wrap "^$cmd_re\r\n$error_re" {
+		-re -wrap "^$error_re" {
 		    pass $gdb_test_name
 		}
 	    }
 	} else {
 	    gdb_test_multiple $cmd "" {
-		-re -wrap "^$cmd_re\r\n\\$$::decimal$result_re" {
+		-re -wrap "^\\$$::decimal$result_re" {
 		    pass $gdb_test_name
 		}
 	    }
@@ -49,7 +47,7 @@ proc test_shift {lang cmd result_re {warning_or_error ""}} {
 	}
 
 	gdb_test_multiple $cmd "" {
-	    -re -wrap "^$cmd_re\r\n$warning_re\\$$::decimal$result_re" {
+	    -re -wrap "^$warning_re\\$$::decimal$result_re" {
 		pass $gdb_test_name
 	    }
 	}
diff --git a/gdb/testsuite/gdb.base/maint-print-frame-id.exp b/gdb/testsuite/gdb.base/maint-print-frame-id.exp
index 2ad9b6ddfd7..9e88f37205f 100644
--- a/gdb/testsuite/gdb.base/maint-print-frame-id.exp
+++ b/gdb/testsuite/gdb.base/maint-print-frame-id.exp
@@ -33,10 +33,6 @@ proc get_frame_id { level } {
     set id "**unknown**"
 
     gdb_test_multiple "maint print frame-id ${level}" "" {
-	-re "^maint print frame-id\[^\r\n\]+\r\n" {
-	    exp_continue
-	}
-
 	-wrap -re "^frame-id for frame #\[0-9\]+: (\[^\r\n\]+)" {
 	    set id $expect_out(1,string)
 	    pass $gdb_test_name
diff --git a/gdb/testsuite/gdb.base/settings.exp b/gdb/testsuite/gdb.base/settings.exp
index eb127d246d2..1d9ee64ab0d 100644
--- a/gdb/testsuite/gdb.base/settings.exp
+++ b/gdb/testsuite/gdb.base/settings.exp
@@ -542,7 +542,7 @@ proc test-string {variant} {
     if {$variant != "filename"} {
 	# 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"
+	gdb_test -nonl "$show_cmd" "^\r\n" "$show_cmd: show default"
     } else {
 	gdb_test "$show_cmd" "/foo/bar" "$show_cmd: show default"
     }
@@ -574,7 +574,7 @@ proc test-string {variant} {
 	    gdb_test_no_output "$set_cmd"
 	    # 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"
+	    gdb_test -nonl "$show_cmd" "^\r\n" "$show_cmd: empty second time"
 	}
     }
 
diff --git a/gdb/testsuite/gdb.dwarf2/gdb-index-nodebug.exp b/gdb/testsuite/gdb.dwarf2/gdb-index-nodebug.exp
index 5aebd2a8606..be666cb9dfd 100644
--- a/gdb/testsuite/gdb.dwarf2/gdb-index-nodebug.exp
+++ b/gdb/testsuite/gdb.dwarf2/gdb-index-nodebug.exp
@@ -49,7 +49,7 @@ gdb_test_multiple $cmd "try to save gdb index" {
     -re -wrap $no_debug_re {
 	pass $gdb_test_name
     }
-    -re -wrap "^$cmd" {
+    -re -wrap "^" {
 	pass $gdb_test_name
     }
 }
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 50c10333df1..aed29652b87 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -980,6 +980,8 @@ proc fill_in_default_prompt {prompt_regexp with_anchor} {
 #           pass $gdb_test_name
 #       }
 #   }
+# The special handling of '^' that is available in gdb_test is also
+# supported in gdb_test_multiple when -wrap is used.
 #
 # In EXPECT_ARGUMENTS, a pattern flag -early can be used.  It makes sure the
 # pattern is inserted before any implicit pattern added by gdb_test_multiple.
@@ -1125,6 +1127,19 @@ proc gdb_test_multiple { command message args } {
 	set expecting_action 1
 	if { $wrap_pattern } {
 	    # Wrap subst_item as is done for the gdb_test PATTERN argument.
+	    if {[string range $subst_item 0 0] eq "^"} {
+		if {$command ne ""} {
+		    set command_regex [string_to_regexp $command]
+		    set subst_item [string range $subst_item 1 end]
+		    if {[string length "$subst_item"] > 0} {
+			# We have an output pattern (other than the '^'),
+			# add a newline at the start, this will eventually
+			# sit between the command and the output pattern.
+			set subst_item "\r\n${subst_item}"
+		    }
+		    set subst_item "^${command_regex}${subst_item}"
+		}
+	    }
 	    lappend $current_list \
 		"(?:$subst_item)\r\n$prompt_regexp"
 	    set wrap_pattern 0
@@ -1465,10 +1480,16 @@ proc gdb_test { args } {
     # 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"
+	if {$command ne ""} {
+	    set command_regex [string_to_regexp $command]
+	    set pattern [string range $pattern 1 end]
+	    if {[string length "$pattern"] > 0} {
+		# We have an output pattern (other than the '^'), add a
+		# newline at the start, this will eventually sit between the
+		# command and the output pattern.
+		set pattern "\r\n$pattern"
+	    }
+	    set pattern "^${command_regex}${pattern}"
 	}
     }
 
@@ -6167,9 +6188,8 @@ proc with_set { var val body } {
 	perror "Did not manage to set $var"
     } else {
 	# Set var.
-	set cmd "set $var $val"
-	gdb_test_multiple $cmd "" {
-	    -re -wrap "^$cmd" {
+	gdb_test_multiple "set $var $val" "" {
+	    -re -wrap "^" {
 	    }
 	    -re -wrap " is set to \"?$val\"?\\." {
 	    }
@@ -6180,9 +6200,8 @@ proc with_set { var val body } {
 
     # Restore saved setting.
     if { $save != "" } {
-	set cmd "set $var $save"
-	gdb_test_multiple $cmd "" {
-	    -re -wrap "^$cmd" {
+	gdb_test_multiple "set $var $save" "" {
+	    -re -wrap "^" {
 	    }
 	    -re -wrap "is set to \"?$save\"?( \\(\[^)\]*\\))?\\." {
 	    }
@@ -7746,7 +7765,7 @@ proc get_valueof { fmt exp default {test ""} } {
 
     set val ${default}
     gdb_test_multiple "print${fmt} ${exp}" "$test" {
-	-re "\\$\[0-9\]* = (\[^\r\n\]*)\r\n$gdb_prompt $" {
+	-re -wrap "^\\$\[0-9\]* = (\[^\r\n\]*)" {
 	    set val $expect_out(1,string)
 	    pass "$test"
 	}
@@ -7795,7 +7814,7 @@ proc get_integer_valueof { exp default {test ""} } {
 
     set val ${default}
     gdb_test_multiple "print /d ${exp}" "$test" {
-	-re "\\$\[0-9\]* = (\[-\]*\[0-9\]*).*$gdb_prompt $" {
+	-re -wrap "^\\$\[0-9\]* = (\[-\]*\[0-9\]*).*" {
 	    set val $expect_out(1,string)
 	    pass "$test"
 	}
  
Tom de Vries May 10, 2023, 7:22 a.m. UTC | #15
On 5/9/23 11:54, Andrew Burgess wrote:
> Andrew Burgess <aburgess@redhat.com> writes:
> 
>> Tom de Vries <tdevries@suse.de> writes:
>>
>>> On 5/2/23 13:13, Andrew Burgess wrote:
>>>> Tom de Vries <tdevries@suse.de> writes:
>>>>
>>>>> On 5/1/23 16:33, Andrew Burgess wrote:
>>>>>> Tom de Vries <tdevries@suse.de> writes:
>>>>>>
>>>>>>> On 3/31/23 22:20, Andrew Burgess via Gdb-patches wrote:
>>>>>>>> This commit makes two changes to how we match newline characters in
>>>>>>>> the gdb_test proc.
>>>>>>>
>>>>>>> Hi,
>>>>>>>
>>>>>>> the -wrap used in gdb_test_multiple is defined in terms of gdb_test
>>>>>>> semantics, but it doesn't seem to have been updated to match the new
>>>>>>> behaviour in gdb_test.
>>>>>>>
>>>>>>> I've filed a PR about this regression (
>>>>>>> https://sourceware.org/bugzilla/show_bug.cgi?id=30403 ).
>>>>>>
>>>>>> Sorry for any problems caused.  I'm not working today, but if this has
>>>>>> not been addressed, I'll look at this on Tuesday.
>>>>>
>>>>> AFAIU it's a silent regression, so there are no problems in term of
>>>>> FAILs, it's just that more work is required.
>>>>>
>>>>> FWIW, I think the root cause for introducing this regression silently is
>>>>> that we try to implement the same thing in two different locations, and
>>>>> it's just easy for things to get out of sync.  I recently fixed
>>>>> something similar in commit 4fa173cfd79 ("[gdb/testsuite] Fix -wrap in
>>>>> presence of -prompt in gdb_test_multiple"), that's why I noticed it.
>>>>
>>>> So I believe the patch below brings gdb_test_multiple with '-wrap' back
>>>> into line with gdb_test.  I also updated a couple of other places that
>>>> used the same (old) gdb_test pattern.
>>>>
>>>> There were nowhere near as many regressions with this change as with
>>>> gdb_test.  Let me know what you think.
>>>>
>>>
>>> I've applied the patch and tested it, and saw no regression.  I've also
>>> reviewed the patch and LGTM.
>>
>> Thanks Tom,
>>
>> I've gone ahead and pushed this patch -- fixing up the newline issues.
>>
>>>
>>> However, I've now also realized that the ^ bit is missing, which was
>>> also added in this patch series.
>>>
>>> In other words, say we have:
>>> ...
>>> gdb_test "print 1" "^.$decimal = 1"
>>> ...
>>> which passes fine.
>>>
>>> But then we want to annotate the PASS message with the captured
>>> $decimal, and rewrite into:
>>> ...
>>> gdb_test_multiple "print 1" "" {
>>>       -re -wrap "^.($decimal) = 1" {
>>>           set var_nr $expect_output(1,string)
>>>           pass "$gdb_test_name (var_nr: $var_nr)"
>>>       }
>>> }
>>> ...
>>> This FAILs because ^ at the start of the pattern is not handled the same
>>> way by -wrap as by gdb_test.
>>
>> I'm working on an updated patch that addresses the '^' feature for
>> gdb_test_multiple.  I'm still testing this locally, and it will probably
>> be next week now before I post this -- but I will get this done, watch
>> this space :)
> 
> Tom,
> 
> Below is a patch that extends the '^' support to gdb_test_multiple (when
> -wrap is used).
> 
> Let me know what you think.
> 

Hi Andrew,

I've applied the patch and tested it.  I ran into trouble in two recent 
(more recent than your patch) test-cases, gdb.tui/wrap-line.exp and 
gdb.base/wrap-line.exp, which both need updating.

Otherwise LGTM.

Reviewed-by: Tom de Vries <tdevries@suse.de>

Thanks,
- Tom

> Thanks,
> Andrew
> 
> ---
> 
> commit 1355a1d7eca5c1dac1c74c98634389525c78d877
> Author: Andrew Burgess <aburgess@redhat.com>
> Date:   Tue May 9 10:28:42 2023 +0100
> 
>      gdb/testsuite: extend special '^' handling to gdb_test_multiple
>      
>      The commit:
>      
>        commit 08ec06d6440745ef9204d39197aa1e732df41056
>        Date:   Wed Mar 29 10:41:07 2023 +0100
>      
>            gdb/testsuite: special case '^' in gdb_test pattern
>      
>      Added some special handling of '^' to gdb_test -- a leading '^' will
>      cause the command regexp to automatically be included in the expected
>      output pattern.
>      
>      It was pointed out that the '-wrap' flag of gdb_test_multiple is
>      supposed to work in the same way as gdb_test, and that the recent
>      changes for '^' had not been replicated for gdb_test_multiple.  This
>      patch addresses this issue.
>      
>      So, after this commit, the following two constructs should have the
>      same meaning:
>      
>        gdb_test "command" "^output" "test name"
>      
>        gdb_test_multiple "command" "test name" {
>          -re -wrap "^output" {
>            pass $gdb_test_name
>          }
>        }
>      
>      In both cases the '^' will case gdb.exp to inject a regexp that
>      matches 'command' after the '^' and before the 'output', this is in
>      addition to adding the $gdb_prompt pattern after 'output' in the
>      normal way.
>      
>      The special '^' handling is only applied when '-wrap' is used, as this
>      is the only mode that aims to mimic gdb_test.
>      
>      While working on this patch I realised that I could actually improve
>      the logic for the special '^' handling in the case where the expected
>      output pattern is empty.  I replicated these updates for both gdb_test
>      and gdb_test_multiple in order to keep these two paths in sync.
>      
>      There were a small number of tests that needed adjustment after this
>      change, mostly just removing command regexps that are now added
>      automatically, but the gdb.base/settings.exp case was a little weird
>      as it turns out trying to match a single blank line is probably harder
>      now than it used to be -- still, I suspect this is a pretty rare case,
>      so I think the benefits (improved anchoring) outweigh this small
>      downside (IMHO).
> 
> diff --git a/gdb/testsuite/gdb.base/bitshift.exp b/gdb/testsuite/gdb.base/bitshift.exp
> index adc5996d736..5ea0cd870ed 100644
> --- a/gdb/testsuite/gdb.base/bitshift.exp
> +++ b/gdb/testsuite/gdb.base/bitshift.exp
> @@ -24,19 +24,17 @@ clean_restart
>   # expected error.  If WARNING_OR_ERROR is empty, it is expected that
>   # GDB prints no text other than the print result.
>   proc test_shift {lang cmd result_re {warning_or_error ""}} {
> -    set cmd_re [string_to_regexp $cmd]
> -
>       if {$lang == "go"} {
>   	if {$warning_or_error != ""} {
>   	    set error_re "[string_to_regexp $warning_or_error]"
>   	    gdb_test_multiple $cmd "" {
> -		-re -wrap "^$cmd_re\r\n$error_re" {
> +		-re -wrap "^$error_re" {
>   		    pass $gdb_test_name
>   		}
>   	    }
>   	} else {
>   	    gdb_test_multiple $cmd "" {
> -		-re -wrap "^$cmd_re\r\n\\$$::decimal$result_re" {
> +		-re -wrap "^\\$$::decimal$result_re" {
>   		    pass $gdb_test_name
>   		}
>   	    }
> @@ -49,7 +47,7 @@ proc test_shift {lang cmd result_re {warning_or_error ""}} {
>   	}
>   
>   	gdb_test_multiple $cmd "" {
> -	    -re -wrap "^$cmd_re\r\n$warning_re\\$$::decimal$result_re" {
> +	    -re -wrap "^$warning_re\\$$::decimal$result_re" {
>   		pass $gdb_test_name
>   	    }
>   	}
> diff --git a/gdb/testsuite/gdb.base/maint-print-frame-id.exp b/gdb/testsuite/gdb.base/maint-print-frame-id.exp
> index 2ad9b6ddfd7..9e88f37205f 100644
> --- a/gdb/testsuite/gdb.base/maint-print-frame-id.exp
> +++ b/gdb/testsuite/gdb.base/maint-print-frame-id.exp
> @@ -33,10 +33,6 @@ proc get_frame_id { level } {
>       set id "**unknown**"
>   
>       gdb_test_multiple "maint print frame-id ${level}" "" {
> -	-re "^maint print frame-id\[^\r\n\]+\r\n" {
> -	    exp_continue
> -	}
> -
>   	-wrap -re "^frame-id for frame #\[0-9\]+: (\[^\r\n\]+)" {
>   	    set id $expect_out(1,string)
>   	    pass $gdb_test_name
> diff --git a/gdb/testsuite/gdb.base/settings.exp b/gdb/testsuite/gdb.base/settings.exp
> index eb127d246d2..1d9ee64ab0d 100644
> --- a/gdb/testsuite/gdb.base/settings.exp
> +++ b/gdb/testsuite/gdb.base/settings.exp
> @@ -542,7 +542,7 @@ proc test-string {variant} {
>       if {$variant != "filename"} {
>   	# 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"
> +	gdb_test -nonl "$show_cmd" "^\r\n" "$show_cmd: show default"
>       } else {
>   	gdb_test "$show_cmd" "/foo/bar" "$show_cmd: show default"
>       }
> @@ -574,7 +574,7 @@ proc test-string {variant} {
>   	    gdb_test_no_output "$set_cmd"
>   	    # 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"
> +	    gdb_test -nonl "$show_cmd" "^\r\n" "$show_cmd: empty second time"
>   	}
>       }
>   
> diff --git a/gdb/testsuite/gdb.dwarf2/gdb-index-nodebug.exp b/gdb/testsuite/gdb.dwarf2/gdb-index-nodebug.exp
> index 5aebd2a8606..be666cb9dfd 100644
> --- a/gdb/testsuite/gdb.dwarf2/gdb-index-nodebug.exp
> +++ b/gdb/testsuite/gdb.dwarf2/gdb-index-nodebug.exp
> @@ -49,7 +49,7 @@ gdb_test_multiple $cmd "try to save gdb index" {
>       -re -wrap $no_debug_re {
>   	pass $gdb_test_name
>       }
> -    -re -wrap "^$cmd" {
> +    -re -wrap "^" {
>   	pass $gdb_test_name
>       }
>   }
> diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
> index 50c10333df1..aed29652b87 100644
> --- a/gdb/testsuite/lib/gdb.exp
> +++ b/gdb/testsuite/lib/gdb.exp
> @@ -980,6 +980,8 @@ proc fill_in_default_prompt {prompt_regexp with_anchor} {
>   #           pass $gdb_test_name
>   #       }
>   #   }
> +# The special handling of '^' that is available in gdb_test is also
> +# supported in gdb_test_multiple when -wrap is used.
>   #
>   # In EXPECT_ARGUMENTS, a pattern flag -early can be used.  It makes sure the
>   # pattern is inserted before any implicit pattern added by gdb_test_multiple.
> @@ -1125,6 +1127,19 @@ proc gdb_test_multiple { command message args } {
>   	set expecting_action 1
>   	if { $wrap_pattern } {
>   	    # Wrap subst_item as is done for the gdb_test PATTERN argument.
> +	    if {[string range $subst_item 0 0] eq "^"} {
> +		if {$command ne ""} {
> +		    set command_regex [string_to_regexp $command]
> +		    set subst_item [string range $subst_item 1 end]
> +		    if {[string length "$subst_item"] > 0} {
> +			# We have an output pattern (other than the '^'),
> +			# add a newline at the start, this will eventually
> +			# sit between the command and the output pattern.
> +			set subst_item "\r\n${subst_item}"
> +		    }
> +		    set subst_item "^${command_regex}${subst_item}"
> +		}
> +	    }
>   	    lappend $current_list \
>   		"(?:$subst_item)\r\n$prompt_regexp"
>   	    set wrap_pattern 0
> @@ -1465,10 +1480,16 @@ proc gdb_test { args } {
>       # 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"
> +	if {$command ne ""} {
> +	    set command_regex [string_to_regexp $command]
> +	    set pattern [string range $pattern 1 end]
> +	    if {[string length "$pattern"] > 0} {
> +		# We have an output pattern (other than the '^'), add a
> +		# newline at the start, this will eventually sit between the
> +		# command and the output pattern.
> +		set pattern "\r\n$pattern"
> +	    }
> +	    set pattern "^${command_regex}${pattern}"
>   	}
>       }
>   
> @@ -6167,9 +6188,8 @@ proc with_set { var val body } {
>   	perror "Did not manage to set $var"
>       } else {
>   	# Set var.
> -	set cmd "set $var $val"
> -	gdb_test_multiple $cmd "" {
> -	    -re -wrap "^$cmd" {
> +	gdb_test_multiple "set $var $val" "" {
> +	    -re -wrap "^" {
>   	    }
>   	    -re -wrap " is set to \"?$val\"?\\." {
>   	    }
> @@ -6180,9 +6200,8 @@ proc with_set { var val body } {
>   
>       # Restore saved setting.
>       if { $save != "" } {
> -	set cmd "set $var $save"
> -	gdb_test_multiple $cmd "" {
> -	    -re -wrap "^$cmd" {
> +	gdb_test_multiple "set $var $save" "" {
> +	    -re -wrap "^" {
>   	    }
>   	    -re -wrap "is set to \"?$save\"?( \\(\[^)\]*\\))?\\." {
>   	    }
> @@ -7746,7 +7765,7 @@ proc get_valueof { fmt exp default {test ""} } {
>   
>       set val ${default}
>       gdb_test_multiple "print${fmt} ${exp}" "$test" {
> -	-re "\\$\[0-9\]* = (\[^\r\n\]*)\r\n$gdb_prompt $" {
> +	-re -wrap "^\\$\[0-9\]* = (\[^\r\n\]*)" {
>   	    set val $expect_out(1,string)
>   	    pass "$test"
>   	}
> @@ -7795,7 +7814,7 @@ proc get_integer_valueof { exp default {test ""} } {
>   
>       set val ${default}
>       gdb_test_multiple "print /d ${exp}" "$test" {
> -	-re "\\$\[0-9\]* = (\[-\]*\[0-9\]*).*$gdb_prompt $" {
> +	-re -wrap "^\\$\[0-9\]* = (\[-\]*\[0-9\]*).*" {
>   	    set val $expect_out(1,string)
>   	    pass "$test"
>   	}
>
  
Andrew Burgess May 12, 2023, 12:54 p.m. UTC | #16
Tom de Vries <tdevries@suse.de> writes:

> On 5/9/23 11:54, Andrew Burgess wrote:
>> Andrew Burgess <aburgess@redhat.com> writes:
>> 
>>> Tom de Vries <tdevries@suse.de> writes:
>>>
>>>> On 5/2/23 13:13, Andrew Burgess wrote:
>>>>> Tom de Vries <tdevries@suse.de> writes:
>>>>>
>>>>>> On 5/1/23 16:33, Andrew Burgess wrote:
>>>>>>> Tom de Vries <tdevries@suse.de> writes:
>>>>>>>
>>>>>>>> On 3/31/23 22:20, Andrew Burgess via Gdb-patches wrote:
>>>>>>>>> This commit makes two changes to how we match newline characters in
>>>>>>>>> the gdb_test proc.
>>>>>>>>
>>>>>>>> Hi,
>>>>>>>>
>>>>>>>> the -wrap used in gdb_test_multiple is defined in terms of gdb_test
>>>>>>>> semantics, but it doesn't seem to have been updated to match the new
>>>>>>>> behaviour in gdb_test.
>>>>>>>>
>>>>>>>> I've filed a PR about this regression (
>>>>>>>> https://sourceware.org/bugzilla/show_bug.cgi?id=30403 ).
>>>>>>>
>>>>>>> Sorry for any problems caused.  I'm not working today, but if this has
>>>>>>> not been addressed, I'll look at this on Tuesday.
>>>>>>
>>>>>> AFAIU it's a silent regression, so there are no problems in term of
>>>>>> FAILs, it's just that more work is required.
>>>>>>
>>>>>> FWIW, I think the root cause for introducing this regression silently is
>>>>>> that we try to implement the same thing in two different locations, and
>>>>>> it's just easy for things to get out of sync.  I recently fixed
>>>>>> something similar in commit 4fa173cfd79 ("[gdb/testsuite] Fix -wrap in
>>>>>> presence of -prompt in gdb_test_multiple"), that's why I noticed it.
>>>>>
>>>>> So I believe the patch below brings gdb_test_multiple with '-wrap' back
>>>>> into line with gdb_test.  I also updated a couple of other places that
>>>>> used the same (old) gdb_test pattern.
>>>>>
>>>>> There were nowhere near as many regressions with this change as with
>>>>> gdb_test.  Let me know what you think.
>>>>>
>>>>
>>>> I've applied the patch and tested it, and saw no regression.  I've also
>>>> reviewed the patch and LGTM.
>>>
>>> Thanks Tom,
>>>
>>> I've gone ahead and pushed this patch -- fixing up the newline issues.
>>>
>>>>
>>>> However, I've now also realized that the ^ bit is missing, which was
>>>> also added in this patch series.
>>>>
>>>> In other words, say we have:
>>>> ...
>>>> gdb_test "print 1" "^.$decimal = 1"
>>>> ...
>>>> which passes fine.
>>>>
>>>> But then we want to annotate the PASS message with the captured
>>>> $decimal, and rewrite into:
>>>> ...
>>>> gdb_test_multiple "print 1" "" {
>>>>       -re -wrap "^.($decimal) = 1" {
>>>>           set var_nr $expect_output(1,string)
>>>>           pass "$gdb_test_name (var_nr: $var_nr)"
>>>>       }
>>>> }
>>>> ...
>>>> This FAILs because ^ at the start of the pattern is not handled the same
>>>> way by -wrap as by gdb_test.
>>>
>>> I'm working on an updated patch that addresses the '^' feature for
>>> gdb_test_multiple.  I'm still testing this locally, and it will probably
>>> be next week now before I post this -- but I will get this done, watch
>>> this space :)
>> 
>> Tom,
>> 
>> Below is a patch that extends the '^' support to gdb_test_multiple (when
>> -wrap is used).
>> 
>> Let me know what you think.
>> 
>
> Hi Andrew,
>
> I've applied the patch and tested it.  I ran into trouble in two recent 
> (more recent than your patch) test-cases, gdb.tui/wrap-line.exp and 
> gdb.base/wrap-line.exp, which both need updating.

I made the obvious fixes for these two tests, and pushed this patch.

Thanks for the review.

Andrew


>
> Otherwise LGTM.
>
> Reviewed-by: Tom de Vries <tdevries@suse.de>
>
> Thanks,
> - Tom
>
>> Thanks,
>> Andrew
>> 
>> ---
>> 
>> commit 1355a1d7eca5c1dac1c74c98634389525c78d877
>> Author: Andrew Burgess <aburgess@redhat.com>
>> Date:   Tue May 9 10:28:42 2023 +0100
>> 
>>      gdb/testsuite: extend special '^' handling to gdb_test_multiple
>>      
>>      The commit:
>>      
>>        commit 08ec06d6440745ef9204d39197aa1e732df41056
>>        Date:   Wed Mar 29 10:41:07 2023 +0100
>>      
>>            gdb/testsuite: special case '^' in gdb_test pattern
>>      
>>      Added some special handling of '^' to gdb_test -- a leading '^' will
>>      cause the command regexp to automatically be included in the expected
>>      output pattern.
>>      
>>      It was pointed out that the '-wrap' flag of gdb_test_multiple is
>>      supposed to work in the same way as gdb_test, and that the recent
>>      changes for '^' had not been replicated for gdb_test_multiple.  This
>>      patch addresses this issue.
>>      
>>      So, after this commit, the following two constructs should have the
>>      same meaning:
>>      
>>        gdb_test "command" "^output" "test name"
>>      
>>        gdb_test_multiple "command" "test name" {
>>          -re -wrap "^output" {
>>            pass $gdb_test_name
>>          }
>>        }
>>      
>>      In both cases the '^' will case gdb.exp to inject a regexp that
>>      matches 'command' after the '^' and before the 'output', this is in
>>      addition to adding the $gdb_prompt pattern after 'output' in the
>>      normal way.
>>      
>>      The special '^' handling is only applied when '-wrap' is used, as this
>>      is the only mode that aims to mimic gdb_test.
>>      
>>      While working on this patch I realised that I could actually improve
>>      the logic for the special '^' handling in the case where the expected
>>      output pattern is empty.  I replicated these updates for both gdb_test
>>      and gdb_test_multiple in order to keep these two paths in sync.
>>      
>>      There were a small number of tests that needed adjustment after this
>>      change, mostly just removing command regexps that are now added
>>      automatically, but the gdb.base/settings.exp case was a little weird
>>      as it turns out trying to match a single blank line is probably harder
>>      now than it used to be -- still, I suspect this is a pretty rare case,
>>      so I think the benefits (improved anchoring) outweigh this small
>>      downside (IMHO).
>> 
>> diff --git a/gdb/testsuite/gdb.base/bitshift.exp b/gdb/testsuite/gdb.base/bitshift.exp
>> index adc5996d736..5ea0cd870ed 100644
>> --- a/gdb/testsuite/gdb.base/bitshift.exp
>> +++ b/gdb/testsuite/gdb.base/bitshift.exp
>> @@ -24,19 +24,17 @@ clean_restart
>>   # expected error.  If WARNING_OR_ERROR is empty, it is expected that
>>   # GDB prints no text other than the print result.
>>   proc test_shift {lang cmd result_re {warning_or_error ""}} {
>> -    set cmd_re [string_to_regexp $cmd]
>> -
>>       if {$lang == "go"} {
>>   	if {$warning_or_error != ""} {
>>   	    set error_re "[string_to_regexp $warning_or_error]"
>>   	    gdb_test_multiple $cmd "" {
>> -		-re -wrap "^$cmd_re\r\n$error_re" {
>> +		-re -wrap "^$error_re" {
>>   		    pass $gdb_test_name
>>   		}
>>   	    }
>>   	} else {
>>   	    gdb_test_multiple $cmd "" {
>> -		-re -wrap "^$cmd_re\r\n\\$$::decimal$result_re" {
>> +		-re -wrap "^\\$$::decimal$result_re" {
>>   		    pass $gdb_test_name
>>   		}
>>   	    }
>> @@ -49,7 +47,7 @@ proc test_shift {lang cmd result_re {warning_or_error ""}} {
>>   	}
>>   
>>   	gdb_test_multiple $cmd "" {
>> -	    -re -wrap "^$cmd_re\r\n$warning_re\\$$::decimal$result_re" {
>> +	    -re -wrap "^$warning_re\\$$::decimal$result_re" {
>>   		pass $gdb_test_name
>>   	    }
>>   	}
>> diff --git a/gdb/testsuite/gdb.base/maint-print-frame-id.exp b/gdb/testsuite/gdb.base/maint-print-frame-id.exp
>> index 2ad9b6ddfd7..9e88f37205f 100644
>> --- a/gdb/testsuite/gdb.base/maint-print-frame-id.exp
>> +++ b/gdb/testsuite/gdb.base/maint-print-frame-id.exp
>> @@ -33,10 +33,6 @@ proc get_frame_id { level } {
>>       set id "**unknown**"
>>   
>>       gdb_test_multiple "maint print frame-id ${level}" "" {
>> -	-re "^maint print frame-id\[^\r\n\]+\r\n" {
>> -	    exp_continue
>> -	}
>> -
>>   	-wrap -re "^frame-id for frame #\[0-9\]+: (\[^\r\n\]+)" {
>>   	    set id $expect_out(1,string)
>>   	    pass $gdb_test_name
>> diff --git a/gdb/testsuite/gdb.base/settings.exp b/gdb/testsuite/gdb.base/settings.exp
>> index eb127d246d2..1d9ee64ab0d 100644
>> --- a/gdb/testsuite/gdb.base/settings.exp
>> +++ b/gdb/testsuite/gdb.base/settings.exp
>> @@ -542,7 +542,7 @@ proc test-string {variant} {
>>       if {$variant != "filename"} {
>>   	# 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"
>> +	gdb_test -nonl "$show_cmd" "^\r\n" "$show_cmd: show default"
>>       } else {
>>   	gdb_test "$show_cmd" "/foo/bar" "$show_cmd: show default"
>>       }
>> @@ -574,7 +574,7 @@ proc test-string {variant} {
>>   	    gdb_test_no_output "$set_cmd"
>>   	    # 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"
>> +	    gdb_test -nonl "$show_cmd" "^\r\n" "$show_cmd: empty second time"
>>   	}
>>       }
>>   
>> diff --git a/gdb/testsuite/gdb.dwarf2/gdb-index-nodebug.exp b/gdb/testsuite/gdb.dwarf2/gdb-index-nodebug.exp
>> index 5aebd2a8606..be666cb9dfd 100644
>> --- a/gdb/testsuite/gdb.dwarf2/gdb-index-nodebug.exp
>> +++ b/gdb/testsuite/gdb.dwarf2/gdb-index-nodebug.exp
>> @@ -49,7 +49,7 @@ gdb_test_multiple $cmd "try to save gdb index" {
>>       -re -wrap $no_debug_re {
>>   	pass $gdb_test_name
>>       }
>> -    -re -wrap "^$cmd" {
>> +    -re -wrap "^" {
>>   	pass $gdb_test_name
>>       }
>>   }
>> diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
>> index 50c10333df1..aed29652b87 100644
>> --- a/gdb/testsuite/lib/gdb.exp
>> +++ b/gdb/testsuite/lib/gdb.exp
>> @@ -980,6 +980,8 @@ proc fill_in_default_prompt {prompt_regexp with_anchor} {
>>   #           pass $gdb_test_name
>>   #       }
>>   #   }
>> +# The special handling of '^' that is available in gdb_test is also
>> +# supported in gdb_test_multiple when -wrap is used.
>>   #
>>   # In EXPECT_ARGUMENTS, a pattern flag -early can be used.  It makes sure the
>>   # pattern is inserted before any implicit pattern added by gdb_test_multiple.
>> @@ -1125,6 +1127,19 @@ proc gdb_test_multiple { command message args } {
>>   	set expecting_action 1
>>   	if { $wrap_pattern } {
>>   	    # Wrap subst_item as is done for the gdb_test PATTERN argument.
>> +	    if {[string range $subst_item 0 0] eq "^"} {
>> +		if {$command ne ""} {
>> +		    set command_regex [string_to_regexp $command]
>> +		    set subst_item [string range $subst_item 1 end]
>> +		    if {[string length "$subst_item"] > 0} {
>> +			# We have an output pattern (other than the '^'),
>> +			# add a newline at the start, this will eventually
>> +			# sit between the command and the output pattern.
>> +			set subst_item "\r\n${subst_item}"
>> +		    }
>> +		    set subst_item "^${command_regex}${subst_item}"
>> +		}
>> +	    }
>>   	    lappend $current_list \
>>   		"(?:$subst_item)\r\n$prompt_regexp"
>>   	    set wrap_pattern 0
>> @@ -1465,10 +1480,16 @@ proc gdb_test { args } {
>>       # 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"
>> +	if {$command ne ""} {
>> +	    set command_regex [string_to_regexp $command]
>> +	    set pattern [string range $pattern 1 end]
>> +	    if {[string length "$pattern"] > 0} {
>> +		# We have an output pattern (other than the '^'), add a
>> +		# newline at the start, this will eventually sit between the
>> +		# command and the output pattern.
>> +		set pattern "\r\n$pattern"
>> +	    }
>> +	    set pattern "^${command_regex}${pattern}"
>>   	}
>>       }
>>   
>> @@ -6167,9 +6188,8 @@ proc with_set { var val body } {
>>   	perror "Did not manage to set $var"
>>       } else {
>>   	# Set var.
>> -	set cmd "set $var $val"
>> -	gdb_test_multiple $cmd "" {
>> -	    -re -wrap "^$cmd" {
>> +	gdb_test_multiple "set $var $val" "" {
>> +	    -re -wrap "^" {
>>   	    }
>>   	    -re -wrap " is set to \"?$val\"?\\." {
>>   	    }
>> @@ -6180,9 +6200,8 @@ proc with_set { var val body } {
>>   
>>       # Restore saved setting.
>>       if { $save != "" } {
>> -	set cmd "set $var $save"
>> -	gdb_test_multiple $cmd "" {
>> -	    -re -wrap "^$cmd" {
>> +	gdb_test_multiple "set $var $save" "" {
>> +	    -re -wrap "^" {
>>   	    }
>>   	    -re -wrap "is set to \"?$save\"?( \\(\[^)\]*\\))?\\." {
>>   	    }
>> @@ -7746,7 +7765,7 @@ proc get_valueof { fmt exp default {test ""} } {
>>   
>>       set val ${default}
>>       gdb_test_multiple "print${fmt} ${exp}" "$test" {
>> -	-re "\\$\[0-9\]* = (\[^\r\n\]*)\r\n$gdb_prompt $" {
>> +	-re -wrap "^\\$\[0-9\]* = (\[^\r\n\]*)" {
>>   	    set val $expect_out(1,string)
>>   	    pass "$test"
>>   	}
>> @@ -7795,7 +7814,7 @@ proc get_integer_valueof { exp default {test ""} } {
>>   
>>       set val ${default}
>>       gdb_test_multiple "print /d ${exp}" "$test" {
>> -	-re "\\$\[0-9\]* = (\[-\]*\[0-9\]*).*$gdb_prompt $" {
>> +	-re -wrap "^\\$\[0-9\]* = (\[-\]*\[0-9\]*).*" {
>>   	    set val $expect_out(1,string)
>>   	    pass "$test"
>>   	}
>>
  

Patch

diff --git a/gdb/testsuite/gdb.ada/varsize_limit.exp b/gdb/testsuite/gdb.ada/varsize_limit.exp
index ceb0c8594a7..64f2e3fa289 100644
--- a/gdb/testsuite/gdb.ada/varsize_limit.exp
+++ b/gdb/testsuite/gdb.ada/varsize_limit.exp
@@ -31,7 +31,7 @@  if {![runto "vsizelim.adb:$bp_location"]} {
 }
 
 gdb_test "set varsize-limit 16" \
-    "Warning: command 'set varsize-limit' is deprecated.\r\nUse 'set max-value-size'."
+    "Warning: command 'set varsize-limit' is deprecated.\r\nUse 'set max-value-size'\\.\r\n"
 
 gdb_test "print small" " = \"1234567890\""
 
diff --git a/gdb/testsuite/gdb.base/call-rt-st.exp b/gdb/testsuite/gdb.base/call-rt-st.exp
index 63db4c56d57..d9c9abe604f 100644
--- a/gdb/testsuite/gdb.base/call-rt-st.exp
+++ b/gdb/testsuite/gdb.base/call-rt-st.exp
@@ -56,7 +56,7 @@  gdb_test "break loop_count" \
     "breakpoint loop_count"
 
 gdb_test "continue" \
-    "Continuing\\..*Breakpoint.*loop_count \\(\\) at.*call-rt-st.c:$stop_line\[ \t\r\n\]+$stop_line\[\t \]+for \\(index=0; index.4; index..\\);.*\[\r\n \]+" \
+    "Continuing\\..*Breakpoint.*loop_count \\(\\) at.*call-rt-st.c:$stop_line\[ \t\r\n\]+$stop_line\[\t \]+for \\(index=0; index.4; index..\\);.*" \
     "continue to loop_count"
 
 gdb_test_multiple "finish" "finish out from loop count" {
diff --git a/gdb/testsuite/gdb.base/charset.exp b/gdb/testsuite/gdb.base/charset.exp
index 1387e171882..34b4c7134b9 100644
--- a/gdb/testsuite/gdb.base/charset.exp
+++ b/gdb/testsuite/gdb.base/charset.exp
@@ -496,8 +496,8 @@  gdb_test_no_output "set target-charset UTF-8"
 gdb_test "print \"\\242\"" " = \"\\\\242\"" \
   "non-representable target character"
 
-gdb_test "print '\\x'" "\\\\x escape without a following hex digit."
-gdb_test "print '\\u'" "\\\\u escape without a following hex digit."
+gdb_test "print '\\x'" "\\\\x escape without a following hex digit"
+gdb_test "print '\\u'" "\\\\u escape without a following hex digit"
 gdb_test "print '\\9'" " = \[0-9\]+ '9'"
 
 # An octal escape can only be 3 digits.
diff --git a/gdb/testsuite/gdb.base/default.exp b/gdb/testsuite/gdb.base/default.exp
index 7e73db0576a..3c5e8b7598d 100644
--- a/gdb/testsuite/gdb.base/default.exp
+++ b/gdb/testsuite/gdb.base/default.exp
@@ -386,8 +386,8 @@  gdb_test "overlay list"   "No sections are mapped."
 gdb_test "overlay map"    "Overlay debugging not enabled.*" "overlay map #1"
 gdb_test "overlay unmap"  "Overlay debugging not enabled.*" "overlay unmap #1"
 gdb_test_no_output "overlay manual" "overlay manual #2"
-gdb_test "overlay map"    "Argument required: name of an overlay section." "overlay map #2"
-gdb_test "overlay unmap"  "Argument required: name of an overlay section." "overlay unmap #2"
+gdb_test "overlay map"    "Argument required: name of an overlay section" "overlay map #2"
+gdb_test "overlay unmap"  "Argument required: name of an overlay section" "overlay unmap #2"
 
 #test print "p" abbreviation
 gdb_test "p" "The history is empty." "print \"p\" abbreviation"
diff --git a/gdb/testsuite/gdb.base/display.exp b/gdb/testsuite/gdb.base/display.exp
index 79ef4d894e8..6978aedff43 100644
--- a/gdb/testsuite/gdb.base/display.exp
+++ b/gdb/testsuite/gdb.base/display.exp
@@ -191,11 +191,11 @@  gdb_test "printf \"%p\\n\", 1" "0x1"
 # play with "print", too
 #
 gdb_test "print/k j" ".*Undefined output format.*"
-gdb_test "print/d j" " = 0\[\\r\\n\]+"   "debug test output 1"
-gdb_test "print/r j" " = 0\[\\r\\n\]+"   "debug test output 1a"
-gdb_test "print/x j" " = 0x0\[\\r\\n\]+" "debug test output 2"
-gdb_test "print/r j" " = 0x0\[\\r\\n\]+" "debug test output 2a"
-gdb_test "print j"   " = 0\[\\r\\n\]+"   "debug test output 3"
+gdb_test "print/d j" " = 0"   "debug test output 1"
+gdb_test "print/r j" " = 0"   "debug test output 1a"
+gdb_test "print/x j" " = 0x0" "debug test output 2"
+gdb_test "print/r j" " = 0x0" "debug test output 2a"
+gdb_test "print j"   " = 0"   "debug test output 3"
 
 # x/0 j doesn't produce any output and terminates PA64 process when testing
 gdb_test_no_output "x/0 j"
diff --git a/gdb/testsuite/gdb.base/foll-fork.exp b/gdb/testsuite/gdb.base/foll-fork.exp
index df5dab056c2..b0ba156e3db 100644
--- a/gdb/testsuite/gdb.base/foll-fork.exp
+++ b/gdb/testsuite/gdb.base/foll-fork.exp
@@ -234,7 +234,7 @@  proc_with_prefix catch_fork_child_follow {second_inferior} {
     # Verify that the catchpoint is mentioned in an "info breakpoints",
     # and further that the catchpoint mentions no process id.
     gdb_test "info breakpoints" \
-	".*catchpoint.*keep y.*fork\[\r\n\]+" \
+	".*catchpoint.*keep y.*fork" \
 	"info breakpoints before fork"
 
     gdb_test "continue" \
diff --git a/gdb/testsuite/gdb.base/info-macros.exp b/gdb/testsuite/gdb.base/info-macros.exp
index 38eb35f1df8..fd4a99c9794 100644
--- a/gdb/testsuite/gdb.base/info-macros.exp
+++ b/gdb/testsuite/gdb.base/info-macros.exp
@@ -33,22 +33,22 @@  gdb_test "info macro  -- -all" \
 	 "The symbol `-all' has no definition .*\r\nat .*$srcfile:\[0-9\]+"
 
 gdb_test "info macro -all --" \
-	 "You must follow.*with the name.*you want to see.*\[^\r\n\]*\[\r\n\]"
+	 "You must follow.*with the name.*you want to see.*\[^\r\n\]*"
 
 gdb_test "info macro -all  --" \
-	 "You must follow.*with the name.*you want to see.*\[^\r\n\]*\[\r\n\]"
+	 "You must follow.*with the name.*you want to see.*\[^\r\n\]*"
 
 gdb_test "info macro  -all  --" \
-	 "You must follow.*with the name.*you want to see.*\[^\r\n\]*\[\r\n\]"
+	 "You must follow.*with the name.*you want to see.*\[^\r\n\]*"
 
 gdb_test "info macro --" \
-	 "You must follow.*with the name.*you want to see.*\[^\r\n\]*\[\r\n\]"
+	 "You must follow.*with the name.*you want to see.*\[^\r\n\]*"
 
 gdb_test "info macro -- " \
-	 "You must follow.*with the name.*you want to see.*\[^\r\n\]*\[\r\n\]" \
+	 "You must follow.*with the name.*you want to see.*\[^\r\n\]*" \
 	 "info macro -- <EOL>"
 gdb_test "info macro  -- " \
-	 "You must follow.*with the name.*you want to see.*\[^\r\n\]*\[\r\n\]" \
+	 "You must follow.*with the name.*you want to see.*\[^\r\n\]*" \
 	 "info macro  -- <EOL>"
 
 gdb_test "info macro -invalid-option" \
diff --git a/gdb/testsuite/gdb.base/pc-fp.exp b/gdb/testsuite/gdb.base/pc-fp.exp
index e7ebd3804cb..466a6d62395 100644
--- a/gdb/testsuite/gdb.base/pc-fp.exp
+++ b/gdb/testsuite/gdb.base/pc-fp.exp
@@ -53,4 +53,4 @@  gdb_test "info register \$fp" "${valueof_fp}.*"
 # Regression test for
 # http://sourceware.org/bugzilla/show_bug.cgi?id=12659
 gdb_test "info register pc fp" \
-    "pc +${valueof_pc}\[ \t\]+${valueof_pc} <.*>\[\r\n\]+fp +${valueof_fp}\[ \t\]+${valueof_fp}\[\r\n\]+"
+    "pc +${valueof_pc}\[ \t\]+${valueof_pc} <.*>\[\r\n\]+fp +${valueof_fp}\[ \t\]+${valueof_fp}"
diff --git a/gdb/testsuite/gdb.base/pending.exp b/gdb/testsuite/gdb.base/pending.exp
index be54fb1ce08..d7d3735000a 100644
--- a/gdb/testsuite/gdb.base/pending.exp
+++ b/gdb/testsuite/gdb.base/pending.exp
@@ -225,7 +225,7 @@  gdb_test "continue" \
 
 gdb_test "continue" \
 ".*Breakpoint.*pendfunc1.*at.*pendshr.c:$bp2_loc.*
-\[$\]1 = 1." \
+\\\$1 = 1" \
 "continue to resolved breakpoint 1"
 
 #
diff --git a/gdb/testsuite/gdb.base/rtld-step.exp b/gdb/testsuite/gdb.base/rtld-step.exp
index f2cf0b14996..9a6c76d191a 100644
--- a/gdb/testsuite/gdb.base/rtld-step.exp
+++ b/gdb/testsuite/gdb.base/rtld-step.exp
@@ -140,7 +140,7 @@  gdb_test "step" {baz \(.*?\);} "step into foo 1"
 gdb_test "finish" {Run till exit.*bar \(\).*baz.*} "finish out of foo 1"
 gdb_test "next" {foo \(2\);} "next over baz in bar"
 gdb_test "step" {baz \(.*?\);} "step into foo 2"
-gdb_test "next" "\}\[\r\n\]+" "next over baz in foo"
-gdb_test "step" "bar \\(\\).*}\[\r\n\]+.*" "step out of foo back into bar"
+gdb_test "next" "\}" "next over baz in foo"
+gdb_test "step" "bar \\(\\).*}" "step out of foo back into bar"
 
 gdb_continue_to_end
diff --git a/gdb/testsuite/gdb.base/setshow.exp b/gdb/testsuite/gdb.base/setshow.exp
index 86821ca1db0..8c160aa560e 100644
--- a/gdb/testsuite/gdb.base/setshow.exp
+++ b/gdb/testsuite/gdb.base/setshow.exp
@@ -297,10 +297,10 @@  proc_with_prefix test_setshow_history {} {
 	"The filename in which to record the command history is \"[string_to_regexp $HOME]/foobar.baz\"..*" \
 	"show history filename (~/foobar.baz)"
     gdb_test "p \$_gdb_setting(\"history filename\")" \
-	" = \"[string_to_regexp $HOME]/foobar.baz\"..*" \
+	" = \"[string_to_regexp $HOME]/foobar.baz\"" \
 	"_gdb_setting history filename"
     gdb_test "p \$_gdb_setting_str(\"history filename\")" \
-	" = \"[string_to_regexp $HOME]/foobar.baz\"..*" \
+	" = \"[string_to_regexp $HOME]/foobar.baz\"" \
 	"_gdb_setting_str history filename"
 
     #get current working directory
diff --git a/gdb/testsuite/gdb.base/until.exp b/gdb/testsuite/gdb.base/until.exp
index e1a1765ec2e..4a1a07dae7a 100644
--- a/gdb/testsuite/gdb.base/until.exp
+++ b/gdb/testsuite/gdb.base/until.exp
@@ -39,7 +39,7 @@  gdb_test "until $bp_location1" \
 # Verify that a malformed "advance" is gracefully caught.
 #
 gdb_test "until 80 then stop" \
-    "malformed linespec error: unexpected string, \"then stop\"." \
+    "malformed linespec error: unexpected string, \"then stop\"" \
     "malformed until"
 
 # Rerun up to factorial, outer invocation
diff --git a/gdb/testsuite/gdb.base/watch-bitfields.exp b/gdb/testsuite/gdb.base/watch-bitfields.exp
index ce2aee2ac18..95573caa7dd 100644
--- a/gdb/testsuite/gdb.base/watch-bitfields.exp
+++ b/gdb/testsuite/gdb.base/watch-bitfields.exp
@@ -44,9 +44,9 @@  proc watch { expr } {
 proc expect_watchpoint { expr old new } {
     with_test_prefix "$expr: $old->$new" {
 	set expr_re [string_to_regexp $expr]
-	gdb_test "print $expr" "\\$\\d+ = $old\\s" "print expression before"
+	gdb_test "print $expr" "\\$\\d+ = $old" "print expression before"
 	gdb_test "continue" "$expr_re\\s.*Old value = $old\\s+New value = $new\\s.*"
-	gdb_test "print $expr" "\\$\\d+ = $new\\s" "print expression after"
+	gdb_test "print $expr" "\\$\\d+ = $new" "print expression after"
     }
 }
 
diff --git a/gdb/testsuite/gdb.base/wrong_frame_bt_full.exp b/gdb/testsuite/gdb.base/wrong_frame_bt_full.exp
index 2ab0133cfe6..5321cdcbac6 100644
--- a/gdb/testsuite/gdb.base/wrong_frame_bt_full.exp
+++ b/gdb/testsuite/gdb.base/wrong_frame_bt_full.exp
@@ -51,6 +51,4 @@  if ![runto opaque_routine] {
 # correctly when frame #0 (the frame which does not have any debugging
 # info) is the selected frame.
 
-gdb_test "bt full" \
-         ".*\[\r\n\]+ *my_table = \\{0, 1, 2\\}\[\r\n\]+.*"
-
+gdb_test "bt full" ".*\[\r\n\]+ *my_table = \\{0, 1, 2\\}"
diff --git a/gdb/testsuite/gdb.btrace/buffer-size.exp b/gdb/testsuite/gdb.btrace/buffer-size.exp
index e632ba56cf9..616c7f170e5 100644
--- a/gdb/testsuite/gdb.btrace/buffer-size.exp
+++ b/gdb/testsuite/gdb.btrace/buffer-size.exp
@@ -30,8 +30,8 @@  if ![runto_main] {
 
 gdb_test_no_output "set record btrace bts buffer-size 1"
 gdb_test_no_output "set record btrace pt buffer-size 1"
-gdb_test "show record btrace bts buffer-size" "The record/replay bts buffer size is 1\.\r"
-gdb_test "show record btrace pt buffer-size" "The record/replay pt buffer size is 1\.\r"
+gdb_test "show record btrace bts buffer-size" "The record/replay bts buffer size is 1\."
+gdb_test "show record btrace pt buffer-size" "The record/replay pt buffer size is 1\."
 
 gdb_test_no_output "record btrace"
 gdb_test "info record" [multi_line \
diff --git a/gdb/testsuite/gdb.btrace/function_call_history.exp b/gdb/testsuite/gdb.btrace/function_call_history.exp
index e71e48fc0ca..de4cdf9783d 100644
--- a/gdb/testsuite/gdb.btrace/function_call_history.exp
+++ b/gdb/testsuite/gdb.btrace/function_call_history.exp
@@ -187,7 +187,7 @@  set expected_range [multi_line \
 gdb_test "record function-call-history 4,10" $expected_range
 gdb_test "record function-call-history 4,+7" $expected_range
 gdb_test "record function-call-history 10,-7" $expected_range
-gdb_test "record function-call-history 4,4" "4\tinc\r"
+gdb_test "record function-call-history 4,4" "4\tinc"
 
 # set bp after fib recursion and continue
 set bp_location [gdb_get_line_number "bp.2" $testfile.c]
diff --git a/gdb/testsuite/gdb.btrace/instruction_history.exp b/gdb/testsuite/gdb.btrace/instruction_history.exp
index 35b43d68434..f6c1fae720f 100644
--- a/gdb/testsuite/gdb.btrace/instruction_history.exp
+++ b/gdb/testsuite/gdb.btrace/instruction_history.exp
@@ -69,7 +69,7 @@  gdb_test "record instruction-history 3,7" [multi_line \
   "4\t   0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tdec    %eax" \
   "5\t   0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tjmp    0x\[0-9a-f\]+ <loop\\+\[0-9\]+>" \
   "6\t   0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tcmp    \\\$0x0,%eax" \
-  "7\t   0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tje     0x\[0-9a-f\]+ <loop\\+\[0-9\]+>\r" \
+  "7\t   0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tje     0x\[0-9a-f\]+ <loop\\+\[0-9\]+>" \
   ]
 
 gdb_test "record instruction-history /f 3,+5" [multi_line \
@@ -77,7 +77,7 @@  gdb_test "record instruction-history /f 3,+5" [multi_line \
   "4\t   0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tdec    %eax" \
   "5\t   0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tjmp    0x\[0-9a-f\]+ <loop\\+\[0-9\]+>" \
   "6\t   0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tcmp    \\\$0x0,%eax" \
-  "7\t   0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tje     0x\[0-9a-f\]+ <loop\\+\[0-9\]+>\r" \
+  "7\t   0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tje     0x\[0-9a-f\]+ <loop\\+\[0-9\]+>" \
   ]
 
 gdb_test "record instruction-history /p 7,-5" [multi_line \
@@ -85,7 +85,7 @@  gdb_test "record instruction-history /p 7,-5" [multi_line \
   "4\t   0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tdec    %eax" \
   "5\t   0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tjmp    0x\[0-9a-f\]+ <loop\\+\[0-9\]+>" \
   "6\t   0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tcmp    \\\$0x0,%eax" \
-  "7\t   0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tje     0x\[0-9a-f\]+ <loop\\+\[0-9\]+>\r" \
+  "7\t   0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tje     0x\[0-9a-f\]+ <loop\\+\[0-9\]+>" \
   ]
 
 gdb_test "record instruction-history /pf 3,7" [multi_line \
@@ -93,10 +93,10 @@  gdb_test "record instruction-history /pf 3,7" [multi_line \
   "4\t   0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tdec    %eax" \
   "5\t   0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tjmp    0x\[0-9a-f\]+ <loop\\+\[0-9\]+>" \
   "6\t   0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tcmp    \\\$0x0,%eax" \
-  "7\t   0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tje     0x\[0-9a-f\]+ <loop\\+\[0-9\]+>\r" \
+  "7\t   0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tje     0x\[0-9a-f\]+ <loop\\+\[0-9\]+>" \
   ]
 
-gdb_test "record instruction-history 3,3" "3\t   0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tje     0x\[0-9a-f\]+ <loop\\+\[0-9\]+>\r"
+gdb_test "record instruction-history 3,3" "3\t   0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tje     0x\[0-9a-f\]+ <loop\\+\[0-9\]+>"
 
 # the following tests are checking the iterators
 # to avoid lots of regexps, we just check the number of lines that
diff --git a/gdb/testsuite/gdb.btrace/record_goto.exp b/gdb/testsuite/gdb.btrace/record_goto.exp
index 240e18f67d6..1817ac07f51 100644
--- a/gdb/testsuite/gdb.btrace/record_goto.exp
+++ b/gdb/testsuite/gdb.btrace/record_goto.exp
@@ -149,7 +149,7 @@  gdb_test "record goto 2" ".*fun4 \\(\\) at record_goto.c:40.*"
 gdb_test "record function-call-history /ci -" [multi_line \
   "1\tmain\tinst 1,1" \
   "2\t  fun4\tinst 2,4" \
-  "3\t    fun1\tinst 5,8\r" \
+  "3\t    fun1\tinst 5,8" \
   ] "function-call-history from 2 backwards"
 
 # check that we're filling up the context correctly
@@ -173,7 +173,7 @@  gdb_test "record function-call-history /ci" [multi_line \
 gdb_test "record instruction-history" [multi_line \
   "38.*" \
   "39.*" \
-  "40.*\r" \
+  "40.*" \
   ] "instruction-history from end forwards"
 
 # we should get the exact same history from the second to last instruction
@@ -183,12 +183,12 @@  gdb_test "record goto 39" ".*fun4 \\(\\) at record_goto.c:44.*"
 gdb_test "record function-call-history /ci" [multi_line \
   "14\t      fun2\tinst 35,36" \
   "15\t    fun3\tinst 37,38" \
-  "16\t  fun4\tinst 39,40\r" \
+  "16\t  fun4\tinst 39,40" \
   ] "function-call-history from 39 forwards"
 
 # check that we're filling up the context correctly
 gdb_test "record instruction-history" [multi_line \
   "38.*" \
   "39.*" \
-  "40.*\r" \
+  "40.*" \
   ] "instruction-history from 39 forwards"
diff --git a/gdb/testsuite/gdb.cp/incomplete-type-overload.exp b/gdb/testsuite/gdb.cp/incomplete-type-overload.exp
index 050bd98cf56..01201ecd396 100644
--- a/gdb/testsuite/gdb.cp/incomplete-type-overload.exp
+++ b/gdb/testsuite/gdb.cp/incomplete-type-overload.exp
@@ -172,5 +172,5 @@  gdb_test "print foo(inc)"\
 	 "The type. 'incomplete .' isn't fully known to GDB.*"\
 	 "unsuccessful because declaration"
 gdb_test "print foo(ip)"\
-	 "Cannot resolve function foo to any overloaded instance."\
+	 "Cannot resolve function foo to any overloaded instance"\
 	 "unsuccessful because incorrect"
diff --git a/gdb/testsuite/gdb.cp/maint.exp b/gdb/testsuite/gdb.cp/maint.exp
index 59dccfbb3bd..36a48e5637d 100644
--- a/gdb/testsuite/gdb.cp/maint.exp
+++ b/gdb/testsuite/gdb.cp/maint.exp
@@ -21,8 +21,8 @@ 
 # Test the help messages.
 
 proc test_help {} {
-    set first_component_help "Print the first class/namespace component of NAME"
-    set namespace_help "Deprecated placeholder for removed functionality."
+    set first_component_help "Print the first class/namespace component of NAME\\."
+    set namespace_help "Deprecated placeholder for removed functionality\\."
 
     test_prefix_command_help {"maintenance cplus"} {
         "C\\+\\+ maintenance commands\.\[\r\n\]+"
@@ -36,8 +36,8 @@  proc test_help {} {
 
     gdb_test "maint cp" $multiple_help_body
 
-    gdb_test "help maint cp first_component" "${first_component_help}."
-    gdb_test "help maint cp namespace" "${namespace_help}."
+    gdb_test "help maint cp first_component" "${first_component_help}"
+    gdb_test "help maint cp namespace" "${namespace_help}"
 }
 
 # This is used when NAME should contain only a single component.  Be
diff --git a/gdb/testsuite/gdb.cp/ovldbreak.exp b/gdb/testsuite/gdb.cp/ovldbreak.exp
index 62e45f50d0e..fd8268a5791 100644
--- a/gdb/testsuite/gdb.cp/ovldbreak.exp
+++ b/gdb/testsuite/gdb.cp/ovldbreak.exp
@@ -241,11 +241,11 @@  for {set idx 0} {$idx < [llength $overloads]} {incr idx} {
 }
 
 # Verify the breakpoints.
-set bptable "Num\[\t \]+Type\[\t \]+Disp Enb Address\[\t \]+What.*\[\r\n]+"
-append bptable "\[0-9\]+\[\t \]+breakpoint\[\t \]+keep\[\t \]y\[\t \]+$hex\[\t \]+in main(\\((|void)\\))? at.*$srcfile:49\[\r\n\]+"
-append bptable "\[\t \]+breakpoint already hit 1 time\[\r\n\]+."
+set bptable "Num\[\t \]+Type\[\t \]+Disp Enb Address\[\t \]+What\\s*\r\n"
+append bptable "\[0-9\]+\[\t \]+breakpoint\[\t \]+keep\[\t \]y\[\t \]+$hex\[\t \]+in main(\\((|void)\\))? at.*$srcfile:49\r\n"
+append bptable "\[\t \]+breakpoint already hit 1 time"
 foreach ovld $overloads {
-    append bptable [format "\[0-9\]+\[\t \]+breakpoint\[\t \]+keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(%s\\) at.*$srcfile:%d\[\r\n\]+" $ovld \
+    append bptable [format "\r\n\[0-9\]+\[\t \]+breakpoint\[\t \]+keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(%s\\) at.*$srcfile:%d" $ovld \
 			$line($type_map("$ovld"))]
 }
 gdb_test "info break" $bptable "breakpoint info (after setting one-by-one)"
@@ -366,12 +366,12 @@  gdb_expect {
 }
 
 # Create the breakpoint table for "info breakpoint".
-set bptable "Num\[\t \]+Type\[\t \]+Disp Enb Address\[\t \]+What.*\[\r\n]+"
-append bptable "\[0-9\]+\[\t \]+breakpoint\[\t \]+keep\[\t \]y\[\t \]+<MULTIPLE>.*\[\r\n\]+"
+set bptable "Num\[\t \]+Type\[\t \]+Disp Enb Address\[\t \]+What\\s*\r\n"
+append bptable "\[0-9\]+\[\t \]+breakpoint\[\t \]+keep\[\t \]y\[\t \]+<MULTIPLE>\\s*"
 foreach ovld {void char signed_char unsigned_char short_int \
 		  unsigned_short_int int unsigned_int long_int \
 		  unsigned_long_int float double} {
-  append bptable [format "\[0-9\]+.\[0-9\]+\[\t \]+y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(%s\\) at.*$srcfile:%d\[\r\n\]+" \
+  append bptable [format "\r\n\[0-9\]+.\[0-9\]+\[\t \]+y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(%s\\) at.*$srcfile:%d" \
 		      $types($ovld) $line($ovld)]
 }
 
diff --git a/gdb/testsuite/gdb.cp/userdef.exp b/gdb/testsuite/gdb.cp/userdef.exp
index f04a441c54d..ac453179da2 100644
--- a/gdb/testsuite/gdb.cp/userdef.exp
+++ b/gdb/testsuite/gdb.cp/userdef.exp
@@ -67,9 +67,9 @@  gdb_test "print one / two" "\\\$\[0-9\]* = {x = 0, y = 0}"
 
 gdb_test "print one % two" "\\\$\[0-9\]* = {x = 2, y = 3}"
 
-gdb_test "print one && two" "\\\$\[0-9\]* = 1\[\r\n\]"
+gdb_test "print one && two" "\\\$\[0-9\]* = 1"
 
-gdb_test "print one || two" "\\\$\[0-9\]* = 1\[\r\n\]"
+gdb_test "print one || two" "\\\$\[0-9\]* = 1"
 
 gdb_test "print one & two" "\\\$\[0-9\]* = {x = 0, y = 1}"
 
@@ -77,18 +77,18 @@  gdb_test "print one | two" "\\\$\[0-9\]* = {x = 6, y = 7}"
 
 gdb_test "print one ^ two" "\\\$\[0-9\]* = {x = 6, y = 6}"
 
-gdb_test "print one < two" "\\\$\[0-9\]* = 1\[\r\n\]"
+gdb_test "print one < two" "\\\$\[0-9\]* = 1"
 
-gdb_test "print one <= two" "\\\$\[0-9\]* = 1\[\r\n\]"
+gdb_test "print one <= two" "\\\$\[0-9\]* = 1"
 
-gdb_test "print one > two" "\\\$\[0-9\]* = 0\[\r\n\]"
+gdb_test "print one > two" "\\\$\[0-9\]* = 0"
 
-gdb_test "print one >= two" "\\\$\[0-9\]* = 0\[\r\n\]"
+gdb_test "print one >= two" "\\\$\[0-9\]* = 0"
 
-gdb_test "print one == two" "\\\$\[0-9\]* = 0\[\r\n\]"
-gdb_test "print one.operator== (two)" "\\\$\[0-9\]* = 0\[\r\n\]"
+gdb_test "print one == two" "\\\$\[0-9\]* = 0"
+gdb_test "print one.operator== (two)" "\\\$\[0-9\]* = 0"
 
-gdb_test "print one != two" "\\\$\[0-9\]* = 1\[\r\n\]"
+gdb_test "print one != two" "\\\$\[0-9\]* = 1"
 
 # Can't really check the output of this one without knowing
 # target integer width.  Make sure we don't try to call
@@ -98,7 +98,7 @@  gdb_test "print one << 31" "\\\$\[0-9\]* = {x = -?\[0-9\]*, y = -?\[0-9\]*}"
 # Should be fine even on < 32-bit targets.
 gdb_test "print one >> 31" "\\\$\[0-9\]* = {x = 0, y = 0}"
 
-gdb_test "print !one" "\\\$\[0-9\]* = 0\[\r\n\]"
+gdb_test "print !one" "\\\$\[0-9\]* = 0"
 
 # Assumes 2's complement.  So does everything...
 gdb_test "print +one" "\\\$\[0-9\]* = {x = 2, y = 3}"
diff --git a/gdb/testsuite/gdb.cp/virtfunc.exp b/gdb/testsuite/gdb.cp/virtfunc.exp
index 445befddf28..908c969741b 100644
--- a/gdb/testsuite/gdb.cp/virtfunc.exp
+++ b/gdb/testsuite/gdb.cp/virtfunc.exp
@@ -228,7 +228,7 @@  proc test_virtual_calls {} {
 proc make_one_vtable_result {name args} {
     global hex
 
-    set nls "\[\r\n\]+"
+    set nls "\r\n"
 
     set result "vtable for '${name}' @ $hex .subobject @ $hex.:$nls"
     set count 0
@@ -237,9 +237,20 @@  proc make_one_vtable_result {name args} {
 	incr count
     }
 
+    # Remove the last instance of $nls.
+    if {$count > 0} {
+	set result [string range $result 0 end-[string length $nls]]
+    }
+
+    verbose -log "APB: result: '$result'"
+
     return $result
 }
 
+proc vtable_seq { args } {
+    return [join "\r\n\r\n" $args]
+}
+
 # Test "info vtbl".
 
 proc test_info_vtbl {} {
@@ -255,12 +266,12 @@  proc test_info_vtbl {} {
     set vt_D2 [make_one_vtable_result D "non-virtual thunk to E::vg" D::vd]
     set vt_E [make_one_vtable_result E E::f E::vg E::vv]
 
-    gdb_test "info vtbl a" "${vt_A}${vt_V}"
-    gdb_test "info vtbl b" "${vt_B}${vt_V}"
+    gdb_test "info vtbl a" [vtable_seq ${vt_A} ${vt_V}]
+    gdb_test "info vtbl b" [vtable_seq ${vt_B} ${vt_V}]
     gdb_test "info vtbl c" "${vt_V}"
-    gdb_test "info vtbl d" "${vt_D}${vt_V}"
-    gdb_test "info vtbl e" "${vt_E}${vt_D2}${vt_V2}"
-    gdb_test "info vtbl pEe" "${vt_E}${vt_D2}${vt_V2}"
+    gdb_test "info vtbl d" [vtable_seq ${vt_D} ${vt_V}]
+    gdb_test "info vtbl e" [vtable_seq ${vt_E} ${vt_D2} ${vt_V2}]
+    gdb_test "info vtbl pEe" [vtable_seq ${vt_E} ${vt_D2} ${vt_V2}]
 
     gdb_test "info vtbl" "Argument required.*"
     gdb_test "info vtbl va" \
diff --git a/gdb/testsuite/gdb.guile/scm-breakpoint.exp b/gdb/testsuite/gdb.guile/scm-breakpoint.exp
index a9e656ddfc0..baa80b4c37c 100644
--- a/gdb/testsuite/gdb.guile/scm-breakpoint.exp
+++ b/gdb/testsuite/gdb.guile/scm-breakpoint.exp
@@ -179,7 +179,7 @@  proc_with_prefix test_bkpt_cond_and_cmds { } {
     gdb_scm_test_silent_cmd "guile (define blist (breakpoints))" \
 	"get breakpoint list 6"
     gdb_test "guile (print (breakpoint-commands (list-ref blist (- (length blist) 1))))" \
-	"print \"Command for breakpoint has been executed.\".*print result"
+	"print \"Command for breakpoint has been executed.\".*print result\r\n"
 }
 
 proc_with_prefix test_bkpt_invisible { } {
diff --git a/gdb/testsuite/gdb.guile/scm-cmd.exp b/gdb/testsuite/gdb.guile/scm-cmd.exp
index 25a9780a4d5..afcb17c2096 100644
--- a/gdb/testsuite/gdb.guile/scm-cmd.exp
+++ b/gdb/testsuite/gdb.guile/scm-cmd.exp
@@ -93,7 +93,7 @@  gdb_test_multiline "input command to throw error" \
     "    (throw-user-error \"you lose! ~a\" arg))))" "" \
     "end" ""
 
-gdb_test "test-error-cmd ugh" "ERROR: you lose! ugh" "call error command"
+gdb_test "test-error-cmd ugh" "ERROR: you lose! ugh\r\n" "call error command"
 
 # Test string->argv.
 
diff --git a/gdb/testsuite/gdb.opt/inline-break.exp b/gdb/testsuite/gdb.opt/inline-break.exp
index 4c1fb052b5c..9446ef5b6b4 100644
--- a/gdb/testsuite/gdb.opt/inline-break.exp
+++ b/gdb/testsuite/gdb.opt/inline-break.exp
@@ -74,7 +74,11 @@  proc break_info_1 {num args} {
 	}
 
 	#  Add function/source file info.
-	append result "in $func at .*$source${end}"
+	append result "in $func at .*$source"
+
+	if {$i < $locs} {
+	    append result ${end}
+	}
     }
 
     return $result
diff --git a/gdb/testsuite/gdb.python/py-breakpoint.exp b/gdb/testsuite/gdb.python/py-breakpoint.exp
index ab81b7ade85..76094c95d10 100644
--- a/gdb/testsuite/gdb.python/py-breakpoint.exp
+++ b/gdb/testsuite/gdb.python/py-breakpoint.exp
@@ -57,7 +57,7 @@  proc_with_prefix test_bkpt_basic { } {
     gdb_test "python print (blist\[0\])" \
 	"<gdb.Breakpoint object at $hex>" "Check obj exists @main"
     gdb_test "python print (blist\[0\].location)" \
-	"main." "Check breakpoint location @main"
+	"main" "Check breakpoint location @main"
     gdb_test "python print (blist\[0\].pending)" "False" \
 	"Check pending status of main breakpoint"
 
@@ -75,7 +75,7 @@  proc_with_prefix test_bkpt_basic { } {
     gdb_test "python print (blist\[0\])" \
 	"<gdb.Breakpoint object at $hex>" "Check obj exists @main 2"
     gdb_test "python print (blist\[0\].location)" \
-	"main." "Check breakpoint location @main 2"
+	"main" "Check breakpoint location @main 2"
     gdb_test "python print (blist\[1\])" \
 	"<gdb.Breakpoint object at $hex>" "Check obj exists @mult_line"
 
@@ -206,7 +206,7 @@  proc_with_prefix test_bkpt_cond_and_cmds { } {
     gdb_py_test_silent_cmd "python last_bp = blist\[len(blist)-1\]" \
 	"Find last breakpoint" 0
     gdb_test "python print (last_bp.commands)" \
-	"print \"Command for breakpoint has been executed.\".*print result"
+	"print \"Command for breakpoint has been executed.\".*print result\r\n"
 
     gdb_test_no_output "python last_bp.commands = 'echo hi\\necho there'" \
 	"set commands"
diff --git a/gdb/testsuite/gdb.reverse/machinestate-precsave.exp b/gdb/testsuite/gdb.reverse/machinestate-precsave.exp
index fd53806e467..5c953807584 100644
--- a/gdb/testsuite/gdb.reverse/machinestate-precsave.exp
+++ b/gdb/testsuite/gdb.reverse/machinestate-precsave.exp
@@ -105,11 +105,11 @@  with_test_prefix "module global variable, reverse" {
     gdb_test "tbreak $breakloc" "$srcfile, line $breakloc.*"
     gdb_test "reverse-continue" "$srcfile:$breakloc.*" "reverse to $breakloc"
 
-    gdb_test "print aglobal" " = 0$newline"  "module global reverse-breakpoint"
+    gdb_test "print aglobal" " = 0"  "module global reverse-breakpoint"
     gdb_test "step"          " module global post-change .*"
-    gdb_test "print aglobal" " = 1$newline"  "module global forward past bp"
+    gdb_test "print aglobal" " = 1"  "module global forward past bp"
     gdb_test "reverse-step"  "$newline$breakloc.*"
-    gdb_test "print aglobal" " = 0$newline"  "module global reverse-step to bp"
+    gdb_test "print aglobal" " = 0"  "module global reverse-step to bp"
 }
 
 # Module static variable, reverse
@@ -120,11 +120,11 @@  with_test_prefix "module static variable, reverse" {
     gdb_test "tbreak $breakloc" "$srcfile, line $breakloc.*"
     gdb_test "reverse-continue" "$srcfile:$breakloc.*" "reverse to $breakloc"
 
-    gdb_test "print astatic" " = 0$newline"  "module static reverse-breakpoint"
+    gdb_test "print astatic" " = 0"  "module static reverse-breakpoint"
     gdb_test "step"          " module static post-change .*"
-    gdb_test "print astatic" " = 1$newline"  "module static forward"
+    gdb_test "print astatic" " = 1"  "module static forward"
     gdb_test "reverse-step"  "$newline$breakloc.*"
-    gdb_test "print astatic" " = 0$newline"  "module static reverse-step"
+    gdb_test "print astatic" " = 0"  "module static reverse-step"
 }
 
 # Function static variable, reverse
@@ -135,11 +135,11 @@  with_test_prefix "function static variable, reverse" {
     gdb_test "tbreak $breakloc" "$srcfile, line $breakloc.*"
     gdb_test "reverse-continue" "$srcfile:$breakloc.*" "reverse to $breakloc"
 
-    gdb_test "print a"      " = 0$newline"  "function static reverse-breakpoint"
+    gdb_test "print a"      " = 0"  "function static reverse-breakpoint"
     gdb_test "step"         " function static post-change .*"
-    gdb_test "print a"      " = 1$newline"  "function static forward"
+    gdb_test "print a"      " = 1"  "function static forward"
     gdb_test "reverse-step" "$newline$breakloc.*"
-    gdb_test "print a"      " = 0$newline"  "function static reverse-step"
+    gdb_test "print a"      " = 0"  "function static reverse-step"
 }
 
 # Auto variable, reverse
@@ -150,11 +150,11 @@  with_test_prefix "auto variable, reverse" {
     gdb_test "tbreak $breakloc" "$srcfile, line $breakloc.*"
     gdb_test "reverse-continue" "$srcfile:$breakloc.*" "reverse to $breakloc"
 
-    gdb_test "print a"      " = 0$newline"  "auto var reverse-breakpoint"
+    gdb_test "print a"      " = 0"  "auto var reverse-breakpoint"
     gdb_test "step"         " auto post-change .*"
-    gdb_test "print a"      " = 1$newline"  "auto var forward"
+    gdb_test "print a"      " = 1"  "auto var forward"
     gdb_test "reverse-step" "$newline$breakloc.*"
-    gdb_test "print a"      " = 0$newline"  "auto var reverse-step"
+    gdb_test "print a"      " = 0"  "auto var reverse-step"
 }
 
 # Register variable, reverse
@@ -165,12 +165,12 @@  with_test_prefix "register variable, reverse" {
     gdb_test "tbreak $breakloc" "$srcfile, line $breakloc.*"
     gdb_test "reverse-continue" "$srcfile:$breakloc.*" "reverse to $breakloc"
 
-    gdb_test "print a"      " = 0$newline"  "register var reverse-breakpoint"
+    gdb_test "print a"      " = 0"  "register var reverse-breakpoint"
     gdb_test "step"         " register post-change .*"
-    gdb_test "print a"      " = 1$newline"  \
+    gdb_test "print a"      " = 1"  \
 	"register var step post-change, first time"
     gdb_test "reverse-step" "$newline$breakloc.*"
-    gdb_test "print a"      " = 0$newline"  "register var reverse step-to"
+    gdb_test "print a"      " = 0"  "register var reverse step-to"
 }
 
 # Proceed to beginning of main
@@ -189,12 +189,12 @@  with_test_prefix "register variable, forward" {
     gdb_test "tbreak $breakloc" "$srcfile, line $breakloc.*"
     gdb_test "continue"         "$srcfile:$breakloc.*" "forward to $breakloc"
 
-    gdb_test "print a"      " = 0$newline"  "register var forward-breakpoint"
+    gdb_test "print a"      " = 0"  "register var forward-breakpoint"
     gdb_test "reverse-step" "hide.*"
     gdb_test "step"         "$newline$breakloc.*" "step, 1"
-    gdb_test "print a"      " = 0$newline"  "register var forward step-to"
+    gdb_test "print a"      " = 0"  "register var forward step-to"
     gdb_test "step"         " register post-change .*" "step, 2"
-    gdb_test "print a"      " = 1$newline" \
+    gdb_test "print a"      " = 1" \
 	"register var step post-change, second time"
 }
 
@@ -206,12 +206,12 @@  with_test_prefix "auto variable, forward" {
     gdb_test "tbreak $breakloc" "$srcfile, line $breakloc.*"
     gdb_test "continue"         "$srcfile:$breakloc.*" "forward to $breakloc"
 
-    gdb_test "print a"      " = 0$newline"  "auto var forward-breakpoint"
+    gdb_test "print a"      " = 0"  "auto var forward-breakpoint"
     gdb_test "reverse-step" "hide.*"
     gdb_test "step"         "$newline$breakloc.*" "step, 1"
-    gdb_test "print a"      " = 0$newline"  "auto var forward step-to"
+    gdb_test "print a"      " = 0"  "auto var forward step-to"
     gdb_test "step"         " auto post-change .*" "step, 2"
-    gdb_test "print a"      " = 1$newline"  "auto var step post-change"
+    gdb_test "print a"      " = 1"  "auto var step post-change"
 }
 
 # Function static variable, forward
@@ -222,12 +222,12 @@  with_test_prefix "function static variable, forward" {
     gdb_test "tbreak $breakloc" "$srcfile, line $breakloc.*"
     gdb_test "continue"         "$srcfile:$breakloc.*" "forward to $breakloc"
 
-    gdb_test "print a"      " = 0$newline"  "function static forward-breakpoint"
+    gdb_test "print a"      " = 0"  "function static forward-breakpoint"
     gdb_test "reverse-step" "hide.*"
     gdb_test "step"         "$newline$breakloc.*" "step, 1"
-    gdb_test "print a"      " = 0$newline"  "function static forward step-to"
+    gdb_test "print a"      " = 0"  "function static forward step-to"
     gdb_test "step"         " function static post-change .*" "step, 2"
-    gdb_test "print a"      " = 1$newline"  "function static step post-change"
+    gdb_test "print a"      " = 1"  "function static step post-change"
 }
 
 # Module static variable, forward
@@ -238,12 +238,12 @@  with_test_prefix "module static variable, forward" {
     gdb_test "tbreak $breakloc" "$srcfile, line $breakloc.*"
     gdb_test "continue"         "$srcfile:$breakloc.*" "forward to $breakloc"
 
-    gdb_test "print astatic" " = 0$newline"  "module static forward-breakpoint"
+    gdb_test "print astatic" " = 0"  "module static forward-breakpoint"
     gdb_test "reverse-step"  "hide.*"
     gdb_test "step"          "$newline$breakloc.*" "step, 1"
-    gdb_test "print astatic" " = 0$newline"  "module static forward step-to"
+    gdb_test "print astatic" " = 0"  "module static forward step-to"
     gdb_test "step"          " module static post-change .*" "step, 2"
-    gdb_test "print astatic" " = 1$newline"  "module static step post-change"
+    gdb_test "print astatic" " = 1"  "module static step post-change"
 }
 
 # Module global variable, forward
@@ -254,11 +254,11 @@  with_test_prefix "module global variable, forward" {
     gdb_test "tbreak $breakloc" "$srcfile, line $breakloc.*"
     gdb_test "continue"         "$srcfile:$breakloc.*" "forward to $breakloc"
 
-    gdb_test "print aglobal" " = 0$newline"  "module global forward-breakpoint"
+    gdb_test "print aglobal" " = 0"  "module global forward-breakpoint"
     gdb_test "reverse-step"  "hide.*"
     gdb_test "step"          "$newline$breakloc.*" "step, 1"
-    gdb_test "print aglobal" " = 0$newline"  "module global forward step-to"
+    gdb_test "print aglobal" " = 0"  "module global forward step-to"
     gdb_test "step"          " module global post-change .*" "step, 2"
-    gdb_test "print aglobal" " = 1$newline"  "module global step post-change"
+    gdb_test "print aglobal" " = 1"  "module global step post-change"
 }
 
diff --git a/gdb/testsuite/gdb.reverse/machinestate.exp b/gdb/testsuite/gdb.reverse/machinestate.exp
index 68412b47d3b..60d8f33a022 100644
--- a/gdb/testsuite/gdb.reverse/machinestate.exp
+++ b/gdb/testsuite/gdb.reverse/machinestate.exp
@@ -80,11 +80,11 @@  with_test_prefix "module global variable, reverse" {
     gdb_test "tbreak $breakloc" "$srcfile, line $breakloc.*"
     gdb_test "reverse-continue" "$srcfile:$breakloc.*" "reverse to $breakloc"
 
-    gdb_test "print aglobal" " = 0$newline"  "module global reverse-breakpoint"
+    gdb_test "print aglobal" " = 0"  "module global reverse-breakpoint"
     gdb_test "step"          " module global post-change .*"
-    gdb_test "print aglobal" " = 1$newline"  "module global forward past bp"
+    gdb_test "print aglobal" " = 1"  "module global forward past bp"
     gdb_test "reverse-step"  "$newline$breakloc.*"
-    gdb_test "print aglobal" " = 0$newline"  "module global reverse-step to bp"
+    gdb_test "print aglobal" " = 0"  "module global reverse-step to bp"
 }
 
 # Module static variable, reverse
@@ -95,11 +95,11 @@  with_test_prefix "module static variable, reverse" {
     gdb_test "tbreak $breakloc" "$srcfile, line $breakloc.*"
     gdb_test "reverse-continue" "$srcfile:$breakloc.*" "reverse to $breakloc"
 
-    gdb_test "print astatic" " = 0$newline"  "module static reverse-breakpoint"
+    gdb_test "print astatic" " = 0"  "module static reverse-breakpoint"
     gdb_test "step"          " module static post-change .*"
-    gdb_test "print astatic" " = 1$newline"  "module static forward"
+    gdb_test "print astatic" " = 1"  "module static forward"
     gdb_test "reverse-step"  "$newline$breakloc.*"
-    gdb_test "print astatic" " = 0$newline"  "module static reverse-step"
+    gdb_test "print astatic" " = 0"  "module static reverse-step"
 }
 
 # Function static variable, reverse
@@ -110,11 +110,11 @@  with_test_prefix "function static variable, reverse" {
     gdb_test "tbreak $breakloc" "$srcfile, line $breakloc.*"
     gdb_test "reverse-continue" "$srcfile:$breakloc.*" "reverse to $breakloc"
 
-    gdb_test "print a"      " = 0$newline"  "function static reverse-breakpoint"
+    gdb_test "print a"      " = 0"  "function static reverse-breakpoint"
     gdb_test "step"         " function static post-change .*"
-    gdb_test "print a"      " = 1$newline"  "function static forward"
+    gdb_test "print a"      " = 1"  "function static forward"
     gdb_test "reverse-step" "$newline$breakloc.*"
-    gdb_test "print a"      " = 0$newline"  "function static reverse-step"
+    gdb_test "print a"      " = 0"  "function static reverse-step"
 }
 
 # Auto variable, reverse
@@ -125,11 +125,11 @@  with_test_prefix "auto variable, reverse" {
     gdb_test "tbreak $breakloc" "$srcfile, line $breakloc.*"
     gdb_test "reverse-continue" "$srcfile:$breakloc.*" "reverse to $breakloc"
 
-    gdb_test "print a"      " = 0$newline"  "auto var reverse-breakpoint"
+    gdb_test "print a"      " = 0"  "auto var reverse-breakpoint"
     gdb_test "step"         " auto post-change .*"
-    gdb_test "print a"      " = 1$newline"  "auto var forward"
+    gdb_test "print a"      " = 1"  "auto var forward"
     gdb_test "reverse-step" "$newline$breakloc.*"
-    gdb_test "print a"      " = 0$newline"  "auto var reverse-step"
+    gdb_test "print a"      " = 0"  "auto var reverse-step"
 }
 
 # Register variable, reverse
@@ -140,11 +140,11 @@  with_test_prefix "register variable, reverse" {
     gdb_test "tbreak $breakloc" "$srcfile, line $breakloc.*"
     gdb_test "reverse-continue" "$srcfile:$breakloc.*" "reverse to $breakloc"
 
-    gdb_test "print a"      " = 0$newline"  "register var reverse-breakpoint"
+    gdb_test "print a"      " = 0"  "register var reverse-breakpoint"
     gdb_test "step"         " register post-change .*"
-    gdb_test "print a"      " = 1$newline"  "register var step post-change"
+    gdb_test "print a"      " = 1"  "register var step post-change"
     gdb_test "reverse-step" "$newline$breakloc.*"
-    gdb_test "print a"      " = 0$newline" \
+    gdb_test "print a"      " = 0" \
 	"register var reverse step-to, first time"
 }
 
@@ -164,12 +164,12 @@  with_test_prefix "register variable, forward" {
     gdb_test "tbreak $breakloc" "$srcfile, line $breakloc.*"
     gdb_test "continue"         "$srcfile:$breakloc.*" "forward to $breakloc"
 
-    gdb_test "print a"      " = 0$newline"  "register var forward-breakpoint"
+    gdb_test "print a"      " = 0"  "register var forward-breakpoint"
     gdb_test "reverse-step" "hide.*"
     gdb_test "step"         "$newline$breakloc.*" "step, 1"
-    gdb_test "print a"      " = 0$newline"  "register var forward step-to"
+    gdb_test "print a"      " = 0"  "register var forward step-to"
     gdb_test "step"         " register post-change .*" "step, 2"
-    gdb_test "print a"      " = 1$newline" \
+    gdb_test "print a"      " = 1" \
 	"register var step post-change, second time"
 }
 
@@ -181,12 +181,12 @@  with_test_prefix "auto variable, forward" {
     gdb_test "tbreak $breakloc" "$srcfile, line $breakloc.*"
     gdb_test "continue"         "$srcfile:$breakloc.*" "forward to $breakloc"
 
-    gdb_test "print a"      " = 0$newline"  "auto var forward-breakpoint"
+    gdb_test "print a"      " = 0"  "auto var forward-breakpoint"
     gdb_test "reverse-step" "hide.*"
     gdb_test "step"         "$newline$breakloc.*" "step, 1"
-    gdb_test "print a"      " = 0$newline"  "auto var forward step-to"
+    gdb_test "print a"      " = 0"  "auto var forward step-to"
     gdb_test "step"         " auto post-change .*" "step, 2"
-    gdb_test "print a"      " = 1$newline"  "auto var step post-change"
+    gdb_test "print a"      " = 1"  "auto var step post-change"
 }
 
 # Function static variable, forward
@@ -197,12 +197,12 @@  with_test_prefix "function static variable, forward" {
     gdb_test "tbreak $breakloc" "$srcfile, line $breakloc.*"
     gdb_test "continue"         "$srcfile:$breakloc.*" "forward to $breakloc"
 
-    gdb_test "print a"      " = 0$newline"  "function static forward-breakpoint"
+    gdb_test "print a"      " = 0"  "function static forward-breakpoint"
     gdb_test "reverse-step" "hide.*"
     gdb_test "step"         "$newline$breakloc.*" "step, 1"
-    gdb_test "print a"      " = 0$newline"  "function static forward step-to"
+    gdb_test "print a"      " = 0"  "function static forward step-to"
     gdb_test "step"         " function static post-change .*" "step, 2"
-    gdb_test "print a"      " = 1$newline"  "function static step post-change"
+    gdb_test "print a"      " = 1"  "function static step post-change"
 }
 
 # Module static variable, forward
@@ -213,12 +213,12 @@  with_test_prefix "module static variable, forward" {
     gdb_test "tbreak $breakloc" "$srcfile, line $breakloc.*"
     gdb_test "continue"         "$srcfile:$breakloc.*" "forward to $breakloc"
 
-    gdb_test "print astatic" " = 0$newline"  "module static forward-breakpoint"
+    gdb_test "print astatic" " = 0"  "module static forward-breakpoint"
     gdb_test "reverse-step"  "hide.*"
     gdb_test "step"          "$newline$breakloc.*" "step, 1"
-    gdb_test "print astatic" " = 0$newline"  "module static forward step-to"
+    gdb_test "print astatic" " = 0"  "module static forward step-to"
     gdb_test "step"          " module static post-change .*" "step, 2"
-    gdb_test "print astatic" " = 1$newline"  "module static step post-change"
+    gdb_test "print astatic" " = 1"  "module static step post-change"
 }
 
 # Module global variable, forward
@@ -229,10 +229,10 @@  with_test_prefix "module global variable, forward" {
     gdb_test "tbreak $breakloc" "$srcfile, line $breakloc.*"
     gdb_test "continue"         "$srcfile:$breakloc.*" "forward to $breakloc"
 
-    gdb_test "print aglobal" " = 0$newline"  "module global forward-breakpoint"
+    gdb_test "print aglobal" " = 0"  "module global forward-breakpoint"
     gdb_test "reverse-step"  "hide.*"
     gdb_test "step"          "$newline$breakloc.*" "step, 1"
-    gdb_test "print aglobal" " = 0$newline"  "module global forward step-to"
+    gdb_test "print aglobal" " = 0"  "module global forward step-to"
     gdb_test "step"          " module global post-change .*" "step, 2"
-    gdb_test "print aglobal" " = 1$newline"  "module global step post-change"
+    gdb_test "print aglobal" " = 1"  "module global step post-change"
 }
diff --git a/gdb/testsuite/gdb.stabs/exclfwd.exp b/gdb/testsuite/gdb.stabs/exclfwd.exp
index e7ee9385919..a6e6ff86046 100644
--- a/gdb/testsuite/gdb.stabs/exclfwd.exp
+++ b/gdb/testsuite/gdb.stabs/exclfwd.exp
@@ -40,14 +40,14 @@  set eol "\[ \t\]*\[\n\r\]+"
 gdb_test "ptype v1" "type = struct a {$eol
     int x;$eol
     int y;$eol
-}$eol"
+}"
 
 if {[test_debug_format "stabs"]} {
     setup_kfail "gdb/1602" *-*-*
 }
 gdb_test "ptype v2" "type = struct a {$eol
     const char .c;$eol
-}$eol"
+}"
 
 if {[test_debug_format "stabs"]} {
     setup_kfail "gdb/1603" *-*-*
diff --git a/gdb/testsuite/gdb.threads/foll-fork-other-thread.exp b/gdb/testsuite/gdb.threads/foll-fork-other-thread.exp
index 0186a38fed9..73bea594e15 100644
--- a/gdb/testsuite/gdb.threads/foll-fork-other-thread.exp
+++ b/gdb/testsuite/gdb.threads/foll-fork-other-thread.exp
@@ -60,7 +60,7 @@  proc do_test { fork_func follow target-non-stop non-stop displaced-stepping } {
     # Verify that the catchpoint is mentioned in an "info breakpoints",
     # and further that the catchpoint mentions no process id.
     gdb_test "info breakpoints" \
-	".*catchpoint.*keep y.*fork\[\r\n\]+" \
+	".*catchpoint.*keep y.*fork" \
 	"info breakpoints before fork"
 
     gdb_test "continue" \
diff --git a/gdb/testsuite/gdb.threads/gcore-thread.exp b/gdb/testsuite/gdb.threads/gcore-thread.exp
index 97d67b7a217..d606e19deb1 100644
--- a/gdb/testsuite/gdb.threads/gcore-thread.exp
+++ b/gdb/testsuite/gdb.threads/gcore-thread.exp
@@ -51,7 +51,7 @@  clean_restart ${testfile}
 set horiz "\[^\n\r\]*"
 
 # regexp for newline
-set nl "\[\r\n\]+"
+set nl "\r\n"
 
 set timeout 30
 
@@ -138,7 +138,7 @@  proc load_core { filename } {
 
     # The thread2 thread should be marked as the current thread.
 
-    gdb_test "info threads" "\\* ${horiz} thread2 .*${nl}" \
+    gdb_test "info threads" "\\* ${horiz} thread2 .*" \
 	    "thread2 is current thread in corefile"
 }
 
diff --git a/gdb/testsuite/gdb.trace/actions.exp b/gdb/testsuite/gdb.trace/actions.exp
index ffc3250577f..2a2158886d8 100644
--- a/gdb/testsuite/gdb.trace/actions.exp
+++ b/gdb/testsuite/gdb.trace/actions.exp
@@ -71,48 +71,51 @@  gdb_trace_setactions "5.1b: set actions for first tracepoint" \
 	"collect gdb_char_test" "^$"
 
 gdb_test "info tracepoints" \
-    "Num     Type\[ \]+Disp Enb Address\[ \]+What.*
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_c_test at .*$srcfile:\[0-9\]+.
-\[\t \]+collect gdb_char_test.
-\[\t \]+not installed on target.
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_asm_test at .*$srcfile:\[0-9\]+.
-\[\t \]+not installed on target.
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_recursion_test at .*$srcfile:\[0-9\]+.
-\[\t \]+not installed on target." \
-		"5.1c: verify actions set for first tracepoint"
+    [multi_line \
+	 "Num     Type\[ \]+Disp Enb Address\[ \]+What\\s*" \
+	 "\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_c_test at .*$srcfile:\[0-9\]+" \
+	 "\[\t \]+collect gdb_char_test" \
+	 "\[\t \]+not installed on target" \
+	 "\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_asm_test at .*$srcfile:\[0-9\]+" \
+	 "\[\t \]+not installed on target" \
+	 "\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_recursion_test at .*$srcfile:\[0-9\]+" \
+	 "\[\t \]+not installed on target"] \
+    "5.1c: verify actions set for first tracepoint"
 
 gdb_trace_setactions "5.1d: set actions for second tracepoint" \
 	"$trcpt2" \
 	"collect gdb_short_test" "^$"
 
 gdb_test "info tracepoints" \
-    "Num     Type\[ \]+Disp Enb Address\[ \]+What.*
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_c_test at .*$srcfile:\[0-9\]+.
-\[\t \]+collect gdb_char_test.
-\[\t \]+not installed on target.
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_asm_test at .*$srcfile:\[0-9\]+.
-\[\t \]+collect gdb_short_test.
-\[\t \]+not installed on target.
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_recursion_test at .*$srcfile:\[0-9\]+.
-\[\t \]+not installed on target." \
-		"5.1e: verify actions set for second tracepoint"
+    [multi_line \
+	 "Num     Type\[ \]+Disp Enb Address\[ \]+What\\s*" \
+	 "\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_c_test at .*$srcfile:\[0-9\]+" \
+	 "\[\t \]+collect gdb_char_test" \
+	 "\[\t \]+not installed on target" \
+	 "\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_asm_test at .*$srcfile:\[0-9\]+" \
+	 "\[\t \]+collect gdb_short_test" \
+	 "\[\t \]+not installed on target" \
+	 "\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_recursion_test at .*$srcfile:\[0-9\]+" \
+	 "\[\t \]+not installed on target"] \
+    "5.1e: verify actions set for second tracepoint"
 
 gdb_trace_setactions "5.2a: set actions for last (default) tracepoint" \
 	"" \
 	"collect gdb_long_test" "^$"
 
 gdb_test "info tracepoints" \
-    "Num     Type\[ \]+Disp Enb Address\[ \]+What.*
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_c_test at .*$srcfile:\[0-9\]+.
-\[\t \]+collect gdb_char_test.
-\[\t \]+not installed on target.
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_asm_test at .*$srcfile:\[0-9\]+.
-\[\t \]+collect gdb_short_test.
-\[\t \]+not installed on target.
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_recursion_test at .*$srcfile:\[0-9\]+.
-\[\t \]+collect gdb_long_test.
-\[\t \]+not installed on target." \
-		"5.2b: verify actions set for second tracepoint"
+    [multi_line \
+	 "Num     Type\[ \]+Disp Enb Address\[ \]+What\\s*" \
+	 "\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_c_test at .*$srcfile:\[0-9\]+" \
+	 "\[\t \]+collect gdb_char_test" \
+	 "\[\t \]+not installed on target" \
+	 "\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_asm_test at .*$srcfile:\[0-9\]+" \
+	 "\[\t \]+collect gdb_short_test" \
+	 "\[\t \]+not installed on target" \
+	 "\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_recursion_test at .*$srcfile:\[0-9\]+" \
+	 "\[\t \]+collect gdb_long_test" \
+	 "\[\t \]+not installed on target"] \
+    "5.2b: verify actions set for second tracepoint"
 
 # 5.3 replace actions set earlier
 
@@ -121,17 +124,18 @@  gdb_trace_setactions "5.3a: reset actions for first tracepoint" \
 	"collect gdb_struct1_test" "^$"
 
 gdb_test "info tracepoints" \
-    "Num     Type\[ \]+Disp Enb Address\[ \]+What.*
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_c_test at .*$srcfile:\[0-9\]+.
-\[\t \]+collect gdb_struct1_test.
-\[\t \]+not installed on target.
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_asm_test at .*$srcfile:\[0-9\]+.
-\[\t \]+collect gdb_short_test.
-\[\t \]+not installed on target.
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_recursion_test at .*$srcfile:\[0-9\]+.
-\[\t \]+collect gdb_long_test.
-\[\t \]+not installed on target." \
-		"5.3b: verify actions set for first tracepoint"
+    [multi_line \
+	 "Num     Type\[ \]+Disp Enb Address\[ \]+What\\s*" \
+	 "\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_c_test at .*$srcfile:\[0-9\]+" \
+	 "\[\t \]+collect gdb_struct1_test" \
+	 "\[\t \]+not installed on target" \
+	 "\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_asm_test at .*$srcfile:\[0-9\]+" \
+	 "\[\t \]+collect gdb_short_test" \
+	 "\[\t \]+not installed on target" \
+	 "\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_recursion_test at .*$srcfile:\[0-9\]+" \
+	 "\[\t \]+collect gdb_long_test" \
+	 "\[\t \]+not installed on target"] \
+    "5.3b: verify actions set for first tracepoint"
 
 #
 # test end command (all by itself)
@@ -217,17 +221,18 @@  gdb_trace_setactions "5.10a: set teval action for second tracepoint" \
 	"teval \$tsv += 1" "^$"
 
 gdb_test "info tracepoints" \
-    "Num     Type\[ \]+Disp Enb Address\[ \]+What.*
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_c_test at .*$srcfile:\[0-9\]+.
-\[\t \]+teval gdb_char_test.
-\[\t \]+not installed on target.
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_asm_test at .*$srcfile:\[0-9\]+.
-\[\t \]+teval \\\$tsv \\\+= 1.
-\[\t \]+not installed on target.
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_recursion_test at .*$srcfile:\[0-9\]+.
-\[\t \]+collect gdb_long_test.
-\[\t \]+not installed on target." \
-		"5.10a: verify teval actions set for two tracepoints"
+    [multi_line \
+	 "Num     Type\[ \]+Disp Enb Address\[ \]+What\\s*" \
+	 "\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_c_test at .*$srcfile:\[0-9\]+" \
+	 "\[\t \]+teval gdb_char_test" \
+	 "\[\t \]+not installed on target" \
+	 "\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_asm_test at .*$srcfile:\[0-9\]+" \
+	 "\[\t \]+teval \\\$tsv \\\+= 1" \
+	 "\[\t \]+not installed on target" \
+	 "\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_recursion_test at .*$srcfile:\[0-9\]+" \
+	 "\[\t \]+collect gdb_long_test" \
+	 "\[\t \]+not installed on target"] \
+    "5.10a: verify teval actions set for two tracepoints"
 
 # Load the binary to the target too.
 gdb_load $binfile
diff --git a/gdb/testsuite/gdb.trace/deltrace.exp b/gdb/testsuite/gdb.trace/deltrace.exp
index a849d96f432..2142dc99f50 100644
--- a/gdb/testsuite/gdb.trace/deltrace.exp
+++ b/gdb/testsuite/gdb.trace/deltrace.exp
@@ -50,14 +50,15 @@  gdb_test "trace gdb_asm_test" "Tracepoint \[0-9\]+ at .*" "set tracepoint 2"
 gdb_test "trace $testline1"   "Tracepoint \[0-9\]+ at .*" "set tracepoint 3"
 
 gdb_test "info tracepoints" \
-    "Num     Type\[ \]+Disp Enb Address\[ \]+What.*
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_c_test at .*$srcfile:\[0-9\]+.
-\[\t \]+not installed on target.
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_asm_test at .*$srcfile:\[0-9\]+.
-\[\t \]+not installed on target.
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_recursion_test at .*$srcfile:\[0-9\]+.
-\[\t \]+not installed on target." \
-			"3.1a: set three tracepoints"
+    [multi_line \
+	 "Num     Type\[ \]+Disp Enb Address\[ \]+What\\s*" \
+	 "\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_c_test at .*$srcfile:\[0-9\]+" \
+	 "\[\t \]+not installed on target" \
+	 "\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_asm_test at .*$srcfile:\[0-9\]+" \
+	 "\[\t \]+not installed on target" \
+	 "\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_recursion_test at .*$srcfile:\[0-9\]+" \
+	 "\[\t \]+not installed on target"] \
+    "3.1a: set three tracepoints"
 
 gdb_test "delete tracepoints" \
     "" \
@@ -77,14 +78,15 @@  if {$trcpt1 <= 0 || $trcpt2 <= 0 || $trcpt3 <= 0} {
 }
 
 gdb_test "info tracepoints" \
-    "Num     Type\[ \]+Disp Enb Address\[ \]+What.*
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_c_test at .*$srcfile:\[0-9\]+.
-\[\t \]+not installed on target.
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_asm_test at .*$srcfile:\[0-9\]+.
-\[\t \]+not installed on target.
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_recursion_test at .*$srcfile:\[0-9\]+.
-\[\t \]+not installed on target." \
-			"3.2a: set three tracepoints"
+    [multi_line \
+	 "Num     Type\[ \]+Disp Enb Address\[ \]+What\\s*" \
+	 "\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_c_test at .*$srcfile:\[0-9\]+" \
+	 "\[\t \]+not installed on target" \
+	 "\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_asm_test at .*$srcfile:\[0-9\]+" \
+	 "\[\t \]+not installed on target" \
+	 "\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_recursion_test at .*$srcfile:\[0-9\]+" \
+	 "\[\t \]+not installed on target"] \
+    "3.2a: set three tracepoints"
 
 #gdb_test_no_output "delete tracepoint $trcpt1" ""
 gdb_test_multiple "delete tracepoint $trcpt1" "3.2b: delete first tracepoint" {
@@ -100,12 +102,13 @@  gdb_test_multiple "delete tracepoint $trcpt1" "3.2b: delete first tracepoint" {
 }
 
 gdb_test "info tracepoints" \
-    "Num     Type\[ \]+Disp Enb Address\[ \]+What.*
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_asm_test at .*$srcfile:\[0-9\]+.
-\[\t \]+not installed on target.
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_recursion_test at .*$srcfile:\[0-9\]+.
-\[\t \]+not installed on target." \
-			"3.2c: verify delete first tracepoint"
+    [multi_line \
+	 "Num     Type\[ \]+Disp Enb Address\[ \]+What\\s*" \
+	 "\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_asm_test at .*$srcfile:\[0-9\]+" \
+	 "\[\t \]+not installed on target" \
+	 "\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_recursion_test at .*$srcfile:\[0-9\]+" \
+	 "\[\t \]+not installed on target"] \
+    "3.2c: verify delete first tracepoint"
 
 #gdb_test_no_output "delete tracepoint $trcpt2" ""
 gdb_test_multiple "delete tracepoint $trcpt2" "3.2d: delete second tracepoint" {
@@ -121,10 +124,11 @@  gdb_test_multiple "delete tracepoint $trcpt2" "3.2d: delete second tracepoint" {
 }
 
 gdb_test "info tracepoints" \
-    "Num     Type\[ \]+Disp Enb Address\[ \]+What.*
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_recursion_test at .*$srcfile:\[0-9\]+.
-\[\t \]+not installed on target." \
-			"3.2e: verify delete second tracepoint"
+    [multi_line \
+	 "Num     Type\[ \]+Disp Enb Address\[ \]+What\\s*" \
+	 "\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_recursion_test at .*$srcfile:\[0-9\]+" \
+	 "\[\t \]+not installed on target"] \
+    "3.2e: verify delete second tracepoint"
 
 #gdb_test_no_output "delete tracepoint $trcpt3" ""
 gdb_test_multiple "delete tracepoint $trcpt3" "3.2f: delete third tracepoint" {
@@ -155,14 +159,15 @@  if {$trcpt1 <= 0 || $trcpt2 <= 0 || $trcpt3 <= 0} {
 }
 
 gdb_test "info tracepoints" \
-    "Num     Type\[ \]+Disp Enb Address\[ \]+What.*
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_c_test at .*$srcfile:\[0-9\]+.
-\[\t \]+not installed on target.
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_asm_test at .*$srcfile:\[0-9\]+.
-\[\t \]+not installed on target.
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_recursion_test at .*$srcfile:\[0-9\]+.
-\[\t \]+not installed on target." \
-			"3.3a: set three tracepoints"
+    [multi_line \
+	 "Num     Type\[ \]+Disp Enb Address\[ \]+What\\s*" \
+	 "\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_c_test at .*$srcfile:\[0-9\]+" \
+	 "\[\t \]+not installed on target" \
+	 "\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_asm_test at .*$srcfile:\[0-9\]+" \
+	 "\[\t \]+not installed on target" \
+	 "\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_recursion_test at .*$srcfile:\[0-9\]+" \
+	 "\[\t \]+not installed on target"] \
+    "3.3a: set three tracepoints"
 
 #gdb_test_no_output "delete tracepoint $trcpt1 $trcpt2 $trcpt3" ""
 gdb_test_multiple "delete tracepoint $trcpt1 $trcpt2 $trcpt3" \
diff --git a/gdb/testsuite/gdb.trace/infotrace.exp b/gdb/testsuite/gdb.trace/infotrace.exp
index 83660bed7a5..97ef66b8df2 100644
--- a/gdb/testsuite/gdb.trace/infotrace.exp
+++ b/gdb/testsuite/gdb.trace/infotrace.exp
@@ -49,20 +49,20 @@  gdb_test "info tracepoints" \
 \[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_c_test at .*$srcfile:\[0-9\]+.
 \[\t \]+not installed on target.
 \[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_asm_test at .*$srcfile:\[0-9\]+.
-\[\t \]+not installed on target." \
+\[\t \]+not installed on target" \
     "2.1: info tracepoints (all)"
 
 # 2.2 info tracepoint (specific)
 gdb_test "info tracepoint $c_test_num" \
     "Num     Type\[ \]+Disp Enb Address\[ \]+What.*
 \[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_c_test at .*$srcfile:\[0-9\]+.
-\[\t \]+not installed on target." \
+\[\t \]+not installed on target" \
     "2.2a: info tracepoint $c_test_num (gdb_c_test)"
 
 gdb_test "info tracepoint $asm_test_num" \
     "Num     Type\[ \]+Disp Enb Address\[ \]+What.*
 \[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_asm_test at .*$srcfile:\[0-9\]+.
-\[\t \]+not installed on target." \
+\[\t \]+not installed on target" \
     "2.2b: info tracepoint $asm_test_num (gdb_asm_test)"
 
 # 2.3 info tracepoint (invalid tracepoint number)
diff --git a/gdb/testsuite/gdb.trace/passcount.exp b/gdb/testsuite/gdb.trace/passcount.exp
index f2b70c3f3ad..e09849303f3 100644
--- a/gdb/testsuite/gdb.trace/passcount.exp
+++ b/gdb/testsuite/gdb.trace/passcount.exp
@@ -60,7 +60,7 @@  gdb_test "info tracepoints" \
 \[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_asm_test at .*$srcfile:\[0-9\]+.
 \[\t \]+not installed on target.
 \[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_recursion_test at .*$srcfile:\[0-9\]+.
-\[\t \]+not installed on target." \
+\[\t \]+not installed on target" \
 			"4.1a: set three tracepoints, passcounts all zero"
 
 gdb_test "passcount 2 $trcpt1" \
@@ -75,7 +75,7 @@  gdb_test "info tracepoints" \
 \[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_asm_test at .*$srcfile:\[0-9\]+.
 \[\t \]+not installed on target.
 \[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_recursion_test at .*$srcfile:\[0-9\]+.
-\[\t \]+not installed on target." \
+\[\t \]+not installed on target" \
 	"4.1c: verify 1st tracepoint's passcount set to two"
 
 gdb_test "passcount 4 $trcpt2" \
@@ -91,7 +91,7 @@  gdb_test "info tracepoints" \
 \[\t \]+pass count 4 .
 \[\t \]+not installed on target.
 \[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_recursion_test at .*$srcfile:\[0-9\]+.
-\[\t \]+not installed on target." \
+\[\t \]+not installed on target" \
 	"4.1c: verify 2nd tracepoint's passcount set to four"
 
 # 4.2 passcount of last (default) tracepoint
@@ -191,7 +191,7 @@  gdb_test "info tracepoints" \
 \[\t \]+not installed on target.
 \[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_recursion_test at .*$srcfile:\[0-9\]+.
 \[\t \]+pass count 4 .
-\[\t \]+not installed on target."  \
+\[\t \]+not installed on target"  \
 	"4.6: verify passcount to zero"
 
 # 4.7 (test a very large passcount)
diff --git a/gdb/testsuite/gdb.trace/tracecmd.exp b/gdb/testsuite/gdb.trace/tracecmd.exp
index 3fed8dad2ec..9d0310188f2 100644
--- a/gdb/testsuite/gdb.trace/tracecmd.exp
+++ b/gdb/testsuite/gdb.trace/tracecmd.exp
@@ -58,7 +58,7 @@  gdb_test "trace $srcfile:$testline2" \
 	"Tracepoint $decimal at $hex: file.*$srcfile, line $testline2." \
 	"1.1a: set tracepoint at sourceline"
 gdb_test "info trace" "in gdb_recursion_test.*$srcfile:$testline2.
-\[\t \]+not installed on target." \
+\[\t \]+not installed on target" \
 	"1.1b: trace sourcefile:line"
 
 # 1.2 trace invalid source line
@@ -82,7 +82,7 @@  gdb_test "trace gdb_recursion_test" \
 	"Tracepoint $decimal at $hex: file.*$srcfile, line $testline1." \
 	"1.4a: trace function by name"
 gdb_test "info trace" "in gdb_recursion_test.*$srcfile:$testline1.
-\[\t \]+not installed on target." \
+\[\t \]+not installed on target" \
 	"1.4b: trace function by name"
 
 # 1.5 trace non-existant function
@@ -120,7 +120,7 @@  gdb_test "trace \*gdb_recursion_test" \
 	"Tracepoint $decimal at .*$c_test_addr.*" \
 	"1.7a: trace at function label (before prologue)"
 gdb_test "info trace" "$c_test_addr.*in gdb_recursion_test.*:$baseline.
-\[\t \]+not installed on target." \
+\[\t \]+not installed on target" \
 	"1.7b: verify trace at specific address"
 
 # 1.8 trace at invalid address
@@ -139,7 +139,7 @@  gdb_test "trace gdb_recursion_test if q1 > 0" \
 	"1.11a: conditional tracepoint"
 gdb_test "info trace" "in gdb_recursion_test.*$srcfile:$testline1.
 \[\t \]+trace only if q1 > 0.
-\[\t \]+not installed on target." \
+\[\t \]+not installed on target" \
 	"1.11b: verify conditional tracepoint"
 
 # 1.12 set tracepoint in prologue
diff --git a/gdb/testsuite/gdb.trace/while-stepping.exp b/gdb/testsuite/gdb.trace/while-stepping.exp
index 995b5a083a4..21cc2ee8298 100644
--- a/gdb/testsuite/gdb.trace/while-stepping.exp
+++ b/gdb/testsuite/gdb.trace/while-stepping.exp
@@ -44,7 +44,7 @@  if {$trcpt1 <= 0} {
 gdb_test "info tracepoints" \
     "Num     Type\[ \]+Disp Enb Address\[ \]+What.*
 \[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_c_test at .*$srcfile:\[0-9\]+.
-\[\t \]+not installed on target." \
+\[\t \]+not installed on target" \
 	"5.12: set a tracepoint, stepcount is zero"
 
 set stepcount 12
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 626841a4f0a..d3245ec3b43 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -1453,13 +1453,13 @@  proc gdb_test { args } {
     }
 
     set prompt [fill_in_default_prompt $prompt [expr !${no-prompt-anchor}]]
-    set nl [expr ${nonl} ? {""} : {"\[\r\n\]+"}]
+    set nl [expr ${nonl} ? {""} : {"\r\n"}]
 
     set saw_question 0
 
     set user_code {}
     lappend user_code {
-	-re "\[\r\n\]*(?:$pattern)$nl$prompt" {
+	-re "(?:$pattern)$nl$prompt" {
 	    if { $question != "" & !$saw_question} {
 		fail $message
 	    } elseif {!$nopass} {