[1/5,gdb/testsuite] Fix some test-cases for check-read1 (gdb_test_lines)

Message ID 20241010072510.25545-1-tdevries@suse.de
State Committed
Headers
Series [1/5,gdb/testsuite] Fix some test-cases for check-read1 (gdb_test_lines) |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_gdb_build--master-arm success Build passed
linaro-tcwg-bot/tcwg_gdb_check--master-arm success Test passed
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 success Test passed

Commit Message

Tom de Vries Oct. 10, 2024, 7:25 a.m. UTC
  I ran the testsuite in an environment simulating a stressed system in
combination with check-read1.  This exposes a few more FAILs.

Fix some by using gdb_test_lines, as well as related gdb_get_lines.

Tested on x86_64-linux.
---
 .../premature-dummy-frame-removal.exp         | 14 ++--
 gdb/testsuite/gdb.btrace/exception.exp        | 28 ++++----
 gdb/testsuite/gdb.cp/overload.exp             | 69 +++++++++----------
 gdb/testsuite/gdb.python/py-framefilter.exp   | 22 +++---
 gdb/testsuite/gdb.reverse/sigall-precsave.exp |  4 +-
 .../gdb.server/bkpt-other-inferior.exp        | 30 ++++----
 gdb/testsuite/gdb.server/ext-run.exp          |  4 +-
 7 files changed, 83 insertions(+), 88 deletions(-)


base-commit: 1001055e3552760015661dd9b081435051fe1340
  

Comments

Metzger, Markus T Oct. 10, 2024, 7:35 a.m. UTC | #1
Hello Tom,

>diff --git a/gdb/testsuite/gdb.btrace/exception.exp
>b/gdb/testsuite/gdb.btrace/exception.exp
>index 61cc6c904b6..f27e40f2bcd 100755
>--- a/gdb/testsuite/gdb.btrace/exception.exp
>+++ b/gdb/testsuite/gdb.btrace/exception.exp
>@@ -64,17 +64,17 @@ gdb_expect_list "flat" "\r\n$gdb_prompt $" [list \
>   ]
>
> # show the branch trace with calls indented
>-send_gdb "record function-call-history /c 1\n"
>-gdb_expect_list "indented" "\r\n$gdb_prompt $" [list \
>-  [multi_line \
>-    "1\tmain\\(\\)" \
>-    "2\t  test\\(\\)" \
>-    "3\t    foo\\(\\)" \
>-    "4\t      bar\\(\\)" \
>-    "5\t        bad\\(\\)\r" \
>-  ] "" \
>-  [multi_line \
>-    "\[0-9\]*\t  test\\(\\)" \
>-    "\[0-9\]*\tmain\\(\\)" \
>-  ] "" \
>-  ]
>+set lines [gdb_get_lines "record function-call-history /c 1"]
>+set re1 \
>+    [multi_line \
>+	 "1\tmain\\(\\)" \
>+	 "2\t  test\\(\\)" \
>+	 "3\t    foo\\(\\)" \
>+	 "4\t      bar\\(\\)" \
>+	 "5\t        bad\\(\\)\r"]
>+set re2 \
>+    [multi_line \
>+	 "\[0-9\]*\t  test\\(\\)" \
>+	 "\[0-9\]*\tmain\\(\\)"]
>+
>+gdb_assert { [regexp $re1.*$re2 $lines] } "indented"

Could this be handled by gdb_test_sequence instead?

If not, should another gdb_test_<something> be introduced to implement
the testing pattern you applied here?

Regards,
Markus.

Intel Deutschland GmbH
Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Sean Fennelly, Jeffrey Schneiderman, Tiffany Doon Silva
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928
  
Tom de Vries Oct. 10, 2024, 8:08 a.m. UTC | #2
On 10/10/24 09:35, Metzger, Markus T wrote:
> Hello Tom,
> 
>> diff --git a/gdb/testsuite/gdb.btrace/exception.exp
>> b/gdb/testsuite/gdb.btrace/exception.exp
>> index 61cc6c904b6..f27e40f2bcd 100755
>> --- a/gdb/testsuite/gdb.btrace/exception.exp
>> +++ b/gdb/testsuite/gdb.btrace/exception.exp
>> @@ -64,17 +64,17 @@ gdb_expect_list "flat" "\r\n$gdb_prompt $" [list \
>>    ]
>>
>> # show the branch trace with calls indented
>> -send_gdb "record function-call-history /c 1\n"
>> -gdb_expect_list "indented" "\r\n$gdb_prompt $" [list \
>> -  [multi_line \
>> -    "1\tmain\\(\\)" \
>> -    "2\t  test\\(\\)" \
>> -    "3\t    foo\\(\\)" \
>> -    "4\t      bar\\(\\)" \
>> -    "5\t        bad\\(\\)\r" \
>> -  ] "" \
>> -  [multi_line \
>> -    "\[0-9\]*\t  test\\(\\)" \
>> -    "\[0-9\]*\tmain\\(\\)" \
>> -  ] "" \
>> -  ]
>> +set lines [gdb_get_lines "record function-call-history /c 1"]
>> +set re1 \
>> +    [multi_line \
>> +	 "1\tmain\\(\\)" \
>> +	 "2\t  test\\(\\)" \
>> +	 "3\t    foo\\(\\)" \
>> +	 "4\t      bar\\(\\)" \
>> +	 "5\t        bad\\(\\)\r"]
>> +set re2 \
>> +    [multi_line \
>> +	 "\[0-9\]*\t  test\\(\\)" \
>> +	 "\[0-9\]*\tmain\\(\\)"]
>> +
>> +gdb_assert { [regexp $re1.*$re2 $lines] } "indented"
> 
> Could this be handled by gdb_test_sequence instead?
> 

Hi Markus,

thanks for the review.

Proc gdb_test_sequence is a wrapper around gdb_expect_list, so it has 
the same problem.

I avoid using gdb_test_sequence because it does not work well with large 
outputs (as demonstrated by this test-case, and other test-cases in the 
same patch).  It does solve part of the problem: rather that matching 
^$re1.*$re2 in one action, it splits this up in two actions, matching 
^$re1 and .*$re2, but the .* part can still be large and produce timeouts.

> If not, should another gdb_test_<something> be introduced to implement
> the testing pattern you applied here?

Um, I'm not entirely sure this is what you mean, but gdb_get_lines was 
factored out of gdb_test_lines, and in this case this could be used 
instead, giving a more regular:
...
gdb_test_lines "record function-call-history /c 1" \
     "indented" $re1.*$re2
...

I'll fix this in my local branch.

Thanks,
- Tom
  
Metzger, Markus T Oct. 10, 2024, 8:27 a.m. UTC | #3
Hello Tom,

>>> # show the branch trace with calls indented
>>> -send_gdb "record function-call-history /c 1\n"
>>> -gdb_expect_list "indented" "\r\n$gdb_prompt $" [list \
>>> -  [multi_line \
>>> -    "1\tmain\\(\\)" \
>>> -    "2\t  test\\(\\)" \
>>> -    "3\t    foo\\(\\)" \
>>> -    "4\t      bar\\(\\)" \
>>> -    "5\t        bad\\(\\)\r" \
>>> -  ] "" \
>>> -  [multi_line \
>>> -    "\[0-9\]*\t  test\\(\\)" \
>>> -    "\[0-9\]*\tmain\\(\\)" \
>>> -  ] "" \
>>> -  ]
>>> +set lines [gdb_get_lines "record function-call-history /c 1"]
>>> +set re1 \
>>> +    [multi_line \
>>> +	 "1\tmain\\(\\)" \
>>> +	 "2\t  test\\(\\)" \
>>> +	 "3\t    foo\\(\\)" \
>>> +	 "4\t      bar\\(\\)" \
>>> +	 "5\t        bad\\(\\)\r"]
>>> +set re2 \
>>> +    [multi_line \
>>> +	 "\[0-9\]*\t  test\\(\\)" \
>>> +	 "\[0-9\]*\tmain\\(\\)"]
>>> +
>>> +gdb_assert { [regexp $re1.*$re2 $lines] } "indented"
>>
>> Could this be handled by gdb_test_sequence instead?
>>
>Proc gdb_test_sequence is a wrapper around gdb_expect_list, so it has
>the same problem.
>
>I avoid using gdb_test_sequence because it does not work well with large
>outputs (as demonstrated by this test-case, and other test-cases in the
>same patch).  It does solve part of the problem: rather that matching
>^$re1.*$re2 in one action, it splits this up in two actions, matching
>^$re1 and .*$re2, but the .* part can still be large and produce timeouts.

We're not really interested in the .* part so it's a pity we're storing it.

IIRC I ended up using gdb_test_multiple in other contexts where I wanted
to discard some huge irrelevant output in the middle that caused sporadic
buffer overflows.  That output was uniform so I could write an extra -re
case for it.

IIUC gdb_expect_list tries to match one pattern at a time.  Could we add a
generic -re at the end of the gdb_expect that matches and discards one line?

Since the multi-line pattern we want to match appears first, I hope it would
also match first and we don't end up with the discard pattern discarding one
line of the output we want to match at a time so that the multi-line pattern
doesn't get a chance to match.

>> If not, should another gdb_test_<something> be introduced to implement
>> the testing pattern you applied here?
>
>Um, I'm not entirely sure this is what you mean, but gdb_get_lines was
>factored out of gdb_test_lines, and in this case this could be used
>instead, giving a more regular:
>...
>gdb_test_lines "record function-call-history /c 1" \
>     "indented" $re1.*$re2

Would that allow us to keep the original structure of the test?

Thanks,
Markus.
Intel Deutschland GmbH
Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Sean Fennelly, Jeffrey Schneiderman, Tiffany Doon Silva
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928
  
Tom de Vries Oct. 10, 2024, 8:46 a.m. UTC | #4
On 10/10/24 10:27, Metzger, Markus T wrote:
> Hello Tom,
> 
>>>> # show the branch trace with calls indented
>>>> -send_gdb "record function-call-history /c 1\n"
>>>> -gdb_expect_list "indented" "\r\n$gdb_prompt $" [list \
>>>> -  [multi_line \
>>>> -    "1\tmain\\(\\)" \
>>>> -    "2\t  test\\(\\)" \
>>>> -    "3\t    foo\\(\\)" \
>>>> -    "4\t      bar\\(\\)" \
>>>> -    "5\t        bad\\(\\)\r" \
>>>> -  ] "" \
>>>> -  [multi_line \
>>>> -    "\[0-9\]*\t  test\\(\\)" \
>>>> -    "\[0-9\]*\tmain\\(\\)" \
>>>> -  ] "" \
>>>> -  ]
>>>> +set lines [gdb_get_lines "record function-call-history /c 1"]
>>>> +set re1 \
>>>> +    [multi_line \
>>>> +	 "1\tmain\\(\\)" \
>>>> +	 "2\t  test\\(\\)" \
>>>> +	 "3\t    foo\\(\\)" \
>>>> +	 "4\t      bar\\(\\)" \
>>>> +	 "5\t        bad\\(\\)\r"]
>>>> +set re2 \
>>>> +    [multi_line \
>>>> +	 "\[0-9\]*\t  test\\(\\)" \
>>>> +	 "\[0-9\]*\tmain\\(\\)"]
>>>> +
>>>> +gdb_assert { [regexp $re1.*$re2 $lines] } "indented"
>>>
>>> Could this be handled by gdb_test_sequence instead?
>>>
>> Proc gdb_test_sequence is a wrapper around gdb_expect_list, so it has
>> the same problem.
>>
>> I avoid using gdb_test_sequence because it does not work well with large
>> outputs (as demonstrated by this test-case, and other test-cases in the
>> same patch).  It does solve part of the problem: rather that matching
>> ^$re1.*$re2 in one action, it splits this up in two actions, matching
>> ^$re1 and .*$re2, but the .* part can still be large and produce timeouts.
> 
> We're not really interested in the .* part so it's a pity we're storing it.
> 

True, though from my experience of writing this series, in some cases 
that seems to be factors faster than leaving it in the matching buffer.

> IIRC I ended up using gdb_test_multiple in other contexts where I wanted
> to discard some huge irrelevant output in the middle that caused sporadic
> buffer overflows.  That output was uniform so I could write an extra -re
> case for it.
> 
> IIUC gdb_expect_list tries to match one pattern at a time.  Could we add a
> generic -re at the end of the gdb_expect that matches and discards one line?
> 
> Since the multi-line pattern we want to match appears first, I hope it would
> also match first and we don't end up with the discard pattern discarding one
> line of the output we want to match at a time so that the multi-line pattern
> doesn't get a chance to match.
> 

Well, gdb_test and gdb_test_multiple have functionality to match 
line-by-line, using -lbl.  But that means multi-line patterns (like say 
-re -wrap "bla") don't work reliably.

Sometimes we can work around this by massaging the regexps.

In the case of patch "[gdb/testsuite] Fix gdb.threads/ia64-sigill.exp 
with check-read1" from this series, I couldn't so I wrote a custom 
line-by-line clause:
...
         -re "\r\n\[^\r\n\]*(?=\r\n\[^\r\n\]*\r\n)" {
             exp_continue
         }
...
that still allows matching two lines.

>>> If not, should another gdb_test_<something> be introduced to implement
>>> the testing pattern you applied here?
>>
>> Um, I'm not entirely sure this is what you mean, but gdb_get_lines was
>> factored out of gdb_test_lines, and in this case this could be used
>> instead, giving a more regular:
>> ...
>> gdb_test_lines "record function-call-history /c 1" \
>>      "indented" $re1.*$re2
> 
> Would that allow us to keep the original structure of the test?

Sorry, I don't understand what you mean.  What do you consider the 
original structure that's no longer there?  What is your concern?

Thanks,
- Tom
  
Metzger, Markus T Oct. 10, 2024, 9:03 a.m. UTC | #5
>>> Um, I'm not entirely sure this is what you mean, but gdb_get_lines was
>>> factored out of gdb_test_lines, and in this case this could be used
>>> instead, giving a more regular:
>>> ...
>>> gdb_test_lines "record function-call-history /c 1" \
>>>      "indented" $re1.*$re2
>>
>> Would that allow us to keep the original structure of the test?
>
>Sorry, I don't understand what you mean.  What do you consider the
>original structure that's no longer there?  What is your concern?

The original code used

gdb_expect_list "indented" "\r\n$gdb_prompt $" [list \
  [multi_line \
    "1\tmain\\(\\)" \
    "2\t  test\\(\\)" \
    "3\t    foo\\(\\)" \
    "4\t      bar\\(\\)" \
    "5\t        bad\\(\\)\r" \
  ] "" \
  [multi_line \
    "\[0-9\]*\t  test\\(\\)" \
    "\[0-9\]*\tmain\\(\\)" \
  ] "" \
  ]

I was wondering if we could turn this into

gdb_test_lines "record function-call-history /c 1" \
     "indented" \
  [multi_line \
    "1\tmain\\(\\)" \
    "2\t  test\\(\\)" \
    "3\t    foo\\(\\)" \
    "4\t      bar\\(\\)" \
    "5\t        bad\\(\\)\r" \
  ] \
  .*\
  [multi_line \
    "\[0-9\]*\t  test\\(\\)" \
    "\[0-9\]*\tmain\\(\\)" \
  ]

Regards,
Markus.
Intel Deutschland GmbH
Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Sean Fennelly, Jeffrey Schneiderman, Tiffany Doon Silva
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928
  
Tom de Vries Oct. 10, 2024, 11:01 a.m. UTC | #6
On 10/10/24 11:03, Metzger, Markus T wrote:
> I was wondering if we could turn this into
> 
> gdb_test_lines "record function-call-history /c 1" \
>       "indented" \
>    [multi_line \
>      "1\tmain\\(\\)" \
>      "2\t  test\\(\\)" \
>      "3\t    foo\\(\\)" \
>      "4\t      bar\\(\\)" \
>      "5\t        bad\\(\\)\r" \
>    ] \
>    .*\
>    [multi_line \
>      "\[0-9\]*\t  test\\(\\)" \
>      "\[0-9\]*\tmain\\(\\)" \
>    ]


Proc gdb_test_lines only takes a single regexp argument, and this passes 
3 of them.

I can fix that by doing (btw also using $decimal as additional cleanup):
...
gdb_test_lines "record function-call-history /c 1" \
     "indented" \
     [multi_line \
          "1\tmain\\(\\)" \
          "2\t  test\\(\\)" \
          "3\t    foo\\(\\)" \
          "4\t      bar\\(\\)" \
          "5\t        bad\\(\\)" \
          ".*" \
          "$decimal\t  test\\(\\)" \
          "$decimal\tmain\\(\\)"]
...

Thanks,
- Tom
  
Metzger, Markus T Oct. 10, 2024, 12:55 p.m. UTC | #7
>> I was wondering if we could turn this into
>>
>> gdb_test_lines "record function-call-history /c 1" \
>>       "indented" \
>>    [multi_line \
>>      "1\tmain\\(\\)" \
>>      "2\t  test\\(\\)" \
>>      "3\t    foo\\(\\)" \
>>      "4\t      bar\\(\\)" \
>>      "5\t        bad\\(\\)\r" \
>>    ] \
>>    .*\
>>    [multi_line \
>>      "\[0-9\]*\t  test\\(\\)" \
>>      "\[0-9\]*\tmain\\(\\)" \
>>    ]
>
>
>Proc gdb_test_lines only takes a single regexp argument, and this passes
>3 of them.
>
>I can fix that by doing (btw also using $decimal as additional cleanup):
>...
>gdb_test_lines "record function-call-history /c 1" \
>     "indented" \
>     [multi_line \
>          "1\tmain\\(\\)" \
>          "2\t  test\\(\\)" \
>          "3\t    foo\\(\\)" \
>          "4\t      bar\\(\\)" \
>          "5\t        bad\\(\\)" \
>          ".*" \
>          "$decimal\t  test\\(\\)" \
>          "$decimal\tmain\\(\\)"]
>...

Thanks, that looks good.

Markus.
Intel Deutschland GmbH
Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Sean Fennelly, Jeffrey Schneiderman, Tiffany Doon Silva
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928
  
Tom de Vries Oct. 25, 2024, 4:14 a.m. UTC | #8
On 10/10/24 09:25, Tom de Vries wrote:
> I ran the testsuite in an environment simulating a stressed system in
> combination with check-read1.  This exposes a few more FAILs.
> 
> Fix some by using gdb_test_lines, as well as related gdb_get_lines.
> 

I've pushed this series.

Thanks,
- Tom
  

Patch

diff --git a/gdb/testsuite/gdb.base/premature-dummy-frame-removal.exp b/gdb/testsuite/gdb.base/premature-dummy-frame-removal.exp
index 19e28bb6631..c813fbeb3d2 100644
--- a/gdb/testsuite/gdb.base/premature-dummy-frame-removal.exp
+++ b/gdb/testsuite/gdb.base/premature-dummy-frame-removal.exp
@@ -80,12 +80,10 @@  gdb_test_multiple "p some_func ()" "" {
 # debug, to format of which isn't fixed.  All we care about is that
 # GDB is still running afterwards.
 #
-# All of the debug output makes this really slow when testing with the
-# special read1 version of expect, hence the timeout factor.
-with_read1_timeout_factor 10 {
-    gdb_test_no_output "set debug frame on"
-    gdb_test "p some_func ()" ".*" \
-	"repeat p some_func () with frame debug on"
-    gdb_test_no_output "set debug frame off"
-}
+gdb_test_no_output "set debug frame on"
+gdb_test_lines "p some_func ()" \
+    "repeat p some_func () with frame debug on" \
+    ".*"
+gdb_test_no_output "set debug frame off"
+
 gdb_test "p 1 + 2 + 3" " = 6"
diff --git a/gdb/testsuite/gdb.btrace/exception.exp b/gdb/testsuite/gdb.btrace/exception.exp
index 61cc6c904b6..f27e40f2bcd 100755
--- a/gdb/testsuite/gdb.btrace/exception.exp
+++ b/gdb/testsuite/gdb.btrace/exception.exp
@@ -64,17 +64,17 @@  gdb_expect_list "flat" "\r\n$gdb_prompt $" [list \
   ]
 
 # show the branch trace with calls indented
-send_gdb "record function-call-history /c 1\n"
-gdb_expect_list "indented" "\r\n$gdb_prompt $" [list \
-  [multi_line \
-    "1\tmain\\(\\)" \
-    "2\t  test\\(\\)" \
-    "3\t    foo\\(\\)" \
-    "4\t      bar\\(\\)" \
-    "5\t        bad\\(\\)\r" \
-  ] "" \
-  [multi_line \
-    "\[0-9\]*\t  test\\(\\)" \
-    "\[0-9\]*\tmain\\(\\)" \
-  ] "" \
-  ]
+set lines [gdb_get_lines "record function-call-history /c 1"]
+set re1 \
+    [multi_line \
+	 "1\tmain\\(\\)" \
+	 "2\t  test\\(\\)" \
+	 "3\t    foo\\(\\)" \
+	 "4\t      bar\\(\\)" \
+	 "5\t        bad\\(\\)\r"]
+set re2 \
+    [multi_line \
+	 "\[0-9\]*\t  test\\(\\)" \
+	 "\[0-9\]*\tmain\\(\\)"]
+
+gdb_assert { [regexp $re1.*$re2 $lines] } "indented"
diff --git a/gdb/testsuite/gdb.cp/overload.exp b/gdb/testsuite/gdb.cp/overload.exp
index ef26ae57a7f..da9deefb790 100644
--- a/gdb/testsuite/gdb.cp/overload.exp
+++ b/gdb/testsuite/gdb.cp/overload.exp
@@ -89,42 +89,39 @@  set re_synth	"foo & operator=\\(foo const ?&\\);"
 
 gdb_test "print foo_instance1" "\\$\[0-9\]+ = \{ifoo = 111, ccpfoo = 0x0\}"
 
-gdb_test_multiple "ptype foo_instance1" "ptype foo_instance1" {
-    -re "type = $re_class${ws}$XX_fields${ws}$re_synth${ws}$re_dtor${ws}$re_ctor${ws}$re_methods$nl\}$nl$gdb_prompt $" {
-	# gcc 2.95.3 -gstabs+, no "const" on "const char *"
-	# TODO: gdb.base/constvar.exp has XFAILed this kind of problem for a
-	# long time, but an XFAIL really needs an external bug report.
-	# -- chastain 2003-12-31
-	# setup_xfail "*-*-*"
-	# fail "ptype foo_instance1"
-	# TODO: this should be a KFAIL.
-	pass "ptype foo_instance1 (shorter match)"
-    }
-    -re "type = $re_class${ws}$re_fields${ws}$re_synth${ws}$re_dtor${ws}$re_ctor${ws}$re_methods$nl\}$nl$gdb_prompt $" {
-	# gcc 2.95.3 -gstabs+ if "const char *" ever gets fixed
-	pass "ptype foo_instance1"
-    }
-    -re "type = $re_class${ws}$re_fields${ws}$re_ctor${ws}$XX_dtor${ws}$re_methods$nl\}$nl$gdb_prompt $" {
-	# gcc 3.3.2 -gdwarf-2, "~foo(int)"
-	# TODO: kfail this
-	# kfail "gdb/1113" "ptype foo_instance1"
-	pass "ptype foo_instance1 (shorter match)"
-    }
-    -re "type = $re_class${ws}$re_fields${ws}$re_ctor${ws}$re_dtor${ws}$re_methods$nl\}$nl$gdb_prompt $" {
-	# gcc 3.3.2 -gdwarf-2, if the dtor bug gets fixed
-	# gcc HEAD -gdwarf-2 (abi-2)
-	# TODO: just pass this
-	pass "ptype foo_instance1 (shorter match)"
-    }
-    -re "type = $re_class${ws}$re_fields${ws}$re_synth${ws}$re_ctor${ws}$re_dtor${ws}$re_methods$nl\}$nl$gdb_prompt $" {
-	# gcc 3.3.2 -gstabs+
-	# TODO: enough with the "shorter match"
-	pass "ptype foo_instance1 (shorter match)"
-    }
-    -re "type = $re_class${ws}$re_fields${ws}$re_ctor${ws}$re_dtor${ws}$re_methods${ws}$re_synth$nl\}$nl$gdb_prompt $" {
-	# gcc HEAD -gstabs+ (abi-2)
-	pass "ptype foo_instance1 (shorter match)"
-    }
+set lines [gdb_get_lines "ptype foo_instance1"]
+set test "ptype foo_instance1 output"
+if { [regexp "^type = $re_class${ws}$XX_fields${ws}$re_synth${ws}$re_dtor${ws}$re_ctor${ws}$re_methods$nl\}\r\n$" $lines] } {
+    # gcc 2.95.3 -gstabs+, no "const" on "const char *"
+    # TODO: gdb.base/constvar.exp has XFAILed this kind of problem for a
+    # long time, but an XFAIL really needs an external bug report.
+    # -- chastain 2003-12-31
+    # setup_xfail "*-*-*"
+    # fail "ptype foo_instance1"
+    # TODO: this should be a KFAIL.
+    pass "$test (shorter match)"
+} elseif { [regexp "^type = $re_class${ws}$re_fields${ws}$re_synth${ws}$re_dtor${ws}$re_ctor${ws}$re_methods$nl\}\r\n$" $lines] } {
+    # gcc 2.95.3 -gstabs+ if "const char *" ever gets fixed
+    pass "$test"
+} elseif { [regexp "^type = $re_class${ws}$re_fields${ws}$re_ctor${ws}$XX_dtor${ws}$re_methods$nl\}\r\n$" $lines] } {
+    # gcc 3.3.2 -gdwarf-2, "~foo(int)"
+    # TODO: kfail this
+    # kfail "gdb/1113" "ptype foo_instance1"
+    pass "$test (shorter match)"
+} elseif { [regexp "^type = $re_class${ws}$re_fields${ws}$re_ctor${ws}$re_dtor${ws}$re_methods$nl\}\r\n$" $lines] } {
+    # gcc 3.3.2 -gdwarf-2, if the dtor bug gets fixed
+    # gcc HEAD -gdwarf-2 (abi-2)
+    # TODO: just pass this
+    pass "$test (shorter match)"
+} elseif { [regexp "^type = $re_class${ws}$re_fields${ws}$re_synth${ws}$re_ctor${ws}$re_dtor${ws}$re_methods$nl\}\r\n$" $lines] } {
+    # gcc 3.3.2 -gstabs+
+    # TODO: enough with the "shorter match"
+    pass "$test (shorter match)"
+} elseif { [regexp "^type = $re_class${ws}$re_fields${ws}$re_ctor${ws}$re_dtor${ws}$re_methods${ws}$re_synth$nl\}\r\n$" $lines] } {
+    # gcc HEAD -gstabs+ (abi-2)
+    pass "$test (shorter match)"
+} else {
+    fail $test
 }
 
 # Print variables and method calls.
diff --git a/gdb/testsuite/gdb.python/py-framefilter.exp b/gdb/testsuite/gdb.python/py-framefilter.exp
index 374d352c981..3a325bd6e0b 100644
--- a/gdb/testsuite/gdb.python/py-framefilter.exp
+++ b/gdb/testsuite/gdb.python/py-framefilter.exp
@@ -82,11 +82,10 @@  gdb_breakpoint [gdb_get_line_number "Inner test breakpoint"]
 gdb_continue_to_breakpoint "Inner test breakpoint"
 
 # Test multiple local blocks.
-gdb_test "bt full no-filters" \
+gdb_test_lines "bt full no-filters" "" \
     ".*#0.*end_func.*h = 9.*f = 42.*g = 19.*bar = $hex \"Inside block x2\".*d = 15.*e = 14.*foo = $hex \"Inside block\".*str = $hex \"The End\".*st2 = $hex \"Is Near\".*b = 12.*c = 5.*"
-gdb_test "bt full" \
-    ".*#0.*cnuf_dne.*h = 9.*f = 42.*g = 19.*bar = $hex \"Inside block x2\".*d = 15.*e = 14.*foo = $hex \"Inside block\".*str = $hex \"The End\".*st2 = $hex \"Is Near\".*b = 12.*c = 5.*" \
-    "bt full with filters"
+gdb_test_lines "bt full" "bt full with filters" \
+    ".*#0.*cnuf_dne.*h = 9.*f = 42.*g = 19.*bar = $hex \"Inside block x2\".*d = 15.*e = 14.*foo = $hex \"Inside block\".*str = $hex \"The End\".*st2 = $hex \"Is Near\".*b = 12.*c = 5.*"
 
 # Test pagination can be aborted even for frame filters.
 gdb_test_no_output "set height 5" "pagination quit - set height limited"
@@ -161,15 +160,12 @@  gdb_test "bt -2" \
 gdb_test "bt 3" \
     ".*#0.*end_func.*#1.*in funca \\(\\).*#2.*in funcb \\(j=10\\)\[^#\]*More stack frames follow.*" \
     "bt 3 with frame-filter Reverse disabled"
-gdb_test "bt no-filter full" \
-    ".*#0.*end_func.*str = $hex \"The End\".*st2 = $hex \"Is Near\".*b = 12.*c = 5.*#1.*in funca \\(\\).*#2.*in funcb \\(j=10\\).*bar = \{a = 42, b = 84\}.*" \
-    "bt no-filters full with Reverse disabled"
-gdb_test "bt full" \
-    ".*#0.*end_func.*str = $hex \"The End\".*st2 = $hex \"Is Near\".*b = 12.*c = 5.*#1.*in funca \\(\\).*#2.*in funcb \\(j=10\\).*bar = \{a = 42, b = 84\}.*#22.*in func1 \\(\\).*#23.*in func2 \\(f=3\\).*elided = $hex \"Elided frame\".*fb = \{nothing = $hex \"Elided Foo Bar\", f = 84, s = 38\}.*bf = $hex.*" \
-    "bt full with Reverse disabled"
-gdb_test "bt full hide" \
-    ".*#0.*end_func.*str = $hex \"The End\".*st2 = $hex \"Is Near\".*b = 12.*c = 5.*#1.*in funca \\(\\).*#2.*in funcb \\(j=10\\).*bar = \{a = 42, b = 84\}.*#22.*in func1 \\(\\)\[^#\]*#24.*in func3 \\(i=3\\).*" \
-    "bt full hide with Reverse disabled"
+gdb_test_lines "bt no-filter full" "bt no-filters full with Reverse disabled" \
+    ".*#0.*end_func.*str = $hex \"The End\".*st2 = $hex \"Is Near\".*b = 12.*c = 5.*#1.*in funca \\(\\).*#2.*in funcb \\(j=10\\).*bar = \{a = 42, b = 84\}.*"
+gdb_test_lines "bt full" "bt full with Reverse disabled" \
+    ".*#0.*end_func.*str = $hex \"The End\".*st2 = $hex \"Is Near\".*b = 12.*c = 5.*#1.*in funca \\(\\).*#2.*in funcb \\(j=10\\).*bar = \{a = 42, b = 84\}.*#22.*in func1 \\(\\).*#23.*in func2 \\(f=3\\).*elided = $hex \"Elided frame\".*fb = \{nothing = $hex \"Elided Foo Bar\", f = 84, s = 38\}.*bf = $hex.*"
+gdb_test_lines "bt full hide" "bt full hide with Reverse disabled" \
+    ".*#0.*end_func.*str = $hex \"The End\".*st2 = $hex \"Is Near\".*b = 12.*c = 5.*#1.*in funca \\(\\).*#2.*in funcb \\(j=10\\).*bar = \{a = 42, b = 84\}.*#22.*in func1 \\(\\)\[^#\]*#24.*in func3 \\(i=3\\).*"
 
 # Re-enable Reverse
 gdb_test_no_output "enable frame-filter global Reverse" \
diff --git a/gdb/testsuite/gdb.reverse/sigall-precsave.exp b/gdb/testsuite/gdb.reverse/sigall-precsave.exp
index aab4551c874..902772a4ef1 100644
--- a/gdb/testsuite/gdb.reverse/sigall-precsave.exp
+++ b/gdb/testsuite/gdb.reverse/sigall-precsave.exp
@@ -155,7 +155,7 @@  gdb_test "break $breakloc" \
     "breakpoint at end of main"
 
 # Signal handlers must be disabled
-gdb_test "handle all nostop noprint"
+gdb_test_lines "handle all nostop noprint" "" ""
 
 # The list of signals that the program generates, in the order they
 # are generated.
@@ -276,7 +276,7 @@  gdb_test "record restore $precsave" \
     "reload precord save file"
 
 # Signal handlers must be re-enabled
-gdb_test "handle all stop print"
+gdb_test_lines "handle all stop print" "" ""
 
 # Make the first signal SIGABRT because it is always supported.
 set sig_supported 1
diff --git a/gdb/testsuite/gdb.server/bkpt-other-inferior.exp b/gdb/testsuite/gdb.server/bkpt-other-inferior.exp
index 78d1ae029cb..46c07d1926a 100644
--- a/gdb/testsuite/gdb.server/bkpt-other-inferior.exp
+++ b/gdb/testsuite/gdb.server/bkpt-other-inferior.exp
@@ -77,19 +77,23 @@  foreach inf_sel {1 2} {
 
 	gdb_test_no_output "set debug remote 1"
 
-	gdb_test_multiple "break -q main" "set breakpoint" {
-	    -re "Sending packet: \\\$qXfer:auxv:read.*$gdb_prompt $" {
-		# Symbol lookup may access the target to read AUXV in
-		# order to determine the debug base for SVR4 linker
-		# namespaces.
-		xfail "$gdb_test_name"
-	    }
-	    -re "Sending packet.*$gdb_prompt $" {
-		fail "$gdb_test_name"
-	    }
-	    -re "^break -q main\r\nBreakpoint .* at .*$gdb_prompt $" {
-		pass "$gdb_test_name"
-	    }
+	set lines [gdb_get_lines "break -q main"]
+
+	set test "set breakpoint"
+	set re_xfail \
+	    [string_to_regexp {Sending packet: $qXfer:auxv:read}]
+	if { [regexp $re_xfail $lines] } {
+	    # Symbol lookup may access the target to read AUXV in
+	    # order to determine the debug base for SVR4 linker
+	    # namespaces.
+	    xfail $test
+	} elseif { [regexp "Sending packet:" $lines] } {
+	    fail $test
+	} else {
+	    set re \
+		"Breakpoint $decimal at $hex: \[^\r\n\]+"
+	    set re "^$re\r\n$"
+	    gdb_assert { [regexp $re $lines] } $test
 	}
 
 	gdb_test_no_output "set debug remote 0"
diff --git a/gdb/testsuite/gdb.server/ext-run.exp b/gdb/testsuite/gdb.server/ext-run.exp
index 6f7b5bdf446..296af984703 100644
--- a/gdb/testsuite/gdb.server/ext-run.exp
+++ b/gdb/testsuite/gdb.server/ext-run.exp
@@ -58,8 +58,8 @@  if { [istarget *-*-linux*] } {
     if { $do_xml_test } {
 	# This is done in a way to avoid the timeout that can occur from
 	# applying .* regexp to large output.
-	gdb_test_sequence "info os processes" "get process list" \
-	    { "pid +user +command" "1 +root +\[/a-z\]*(init|systemd|bash)" }
+	gdb_test_lines "info os processes" "get process list" \
+	    "^pid +user +command.*\r\n1 +root +\[/a-z\]*(init|systemd|bash)"
     }
 }