Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] [gdb/testsuite] Fix gdb.python/py-selected-context.exp regexp
@ 2026-08-03  8:07 Tom de Vries
  2026-08-19  8:36 ` Tom de Vries
  0 siblings, 1 reply; 2+ messages in thread
From: Tom de Vries @ 2026-08-03  8:07 UTC (permalink / raw)
  To: gdb-patches

On ppc64-linux, with test-case gdb.python/py-selected-context.exp I run into:
...
(gdb) info inferiors^M
  Num  Description       Connection           Executable        ^M
  1    <null>                                                   ^M
* 2    <null>                                                   ^M
(gdb) FAIL: $exp: check inferior 2 was selected
...

In contrast, on x86_64-linux, I get:
...
(gdb) info inferiors^M
  Num  Description       Connection           Executable        ^M
  1    <null>                                                   ^M
* 2    <null>                                                   ^M
(gdb) PASS: $exp: check inferior 2 was selected
...

The output is identical, so it's surprising that there's a different
outcome.

The proc doing the check is:
...
proc check_inferior { inf testname } {
    gdb_test "info inferiors" \
	"\r\n\\*\\s+[string_to_regexp $inf]\\s+\[^\r\n\]*(?=\r\n)" \
	$testname
}
...

The problem seems to be triggered by the lookahead part '(?=\r\n)': removing
it makes the test pass.

By switching on some debugging in gdb_test_multiple, we get this info:
...
Looking to match ""(?:\r\n\*\s+2\s+[^\r\n]*(?=\r\n))\r\n\(gdb\) $""
...
which shows that the lookahead '(?=\r\n)' is immediately followed by a '\r\n',
making the lookahead superfluous.

Still, the test should not fail.  This may be an expect bug, or a
miscompilation of expect.  I've filed a testsuite PR [1] about it for further
investigation.

But, there's another problem with the regexp.

If we use the same proc to try to match inferior 1, we get a FAIL on both
setups:
...
(gdb) info inferiors^M
  Num  Description       Connection           Executable        ^M
* 1    <null>                                                   ^M
  2    <null>                                                   ^M
(gdb) FAIL: $exp: check inferior 1 was selected
...

The problem is that the regexp doesn't allow a line after the matching line.

Fix this this by appending '.*' to the regexp.

Doing so also has the effect that we no longer run into the expect problem.

While we're at it, rewrite the regexp to a more modern form, and drop the
unnecessary string_to_regexp:
...
	[multi_line \
	     "" \
	     [subst_vars {[*]\s+$inf\s+[^\r\n]*(?=\r\n).*}]]
...

Tested on x86_64-linux and ppc64-linux.

[1] https://sourceware.org/pipermail/gdb-prs/2026q3/047709.html
---
 gdb/testsuite/gdb.python/py-selected-context.exp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/gdb/testsuite/gdb.python/py-selected-context.exp b/gdb/testsuite/gdb.python/py-selected-context.exp
index 28b9b456003..07ace151f26 100644
--- a/gdb/testsuite/gdb.python/py-selected-context.exp
+++ b/gdb/testsuite/gdb.python/py-selected-context.exp
@@ -46,7 +46,9 @@ proc event_regexp { inferior {thread "None"} {frame "None"}} {
 # inferior.  INF should be an inferior number, e.g. '1', '2', etc.
 proc check_inferior { inf testname } {
     gdb_test "info inferiors" \
-	"\r\n\\*\\s+[string_to_regexp $inf]\\s+\[^\r\n\]*(?=\r\n)" \
+	[multi_line \
+	     "" \
+	     [subst_vars {[*]\s+$inf\s+[^\r\n]*(?=\r\n).*}]] \
 	$testname
 }
 

base-commit: dde72c6764ecdd5a6af7295c1087c87bbaa7cfec
-- 
2.51.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] [gdb/testsuite] Fix gdb.python/py-selected-context.exp regexp
  2026-08-03  8:07 [PATCH] [gdb/testsuite] Fix gdb.python/py-selected-context.exp regexp Tom de Vries
@ 2026-08-19  8:36 ` Tom de Vries
  0 siblings, 0 replies; 2+ messages in thread
From: Tom de Vries @ 2026-08-19  8:36 UTC (permalink / raw)
  To: gdb-patches

On 8/3/26 10:07 AM, Tom de Vries wrote:
> Still, the test should not fail.  This may be an expect bug, or a
> miscompilation of expect.  I've filed a testsuite PR [1] about it for further
> investigation.


I've pushed this, with an update to this text to reflect that indeed 
there was an expect bug:
...
Still, the test should not fail.  It fails due to an expect bug [1][2].
...

Thanks,
- Tom

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-08-19  8:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-03  8:07 [PATCH] [gdb/testsuite] Fix gdb.python/py-selected-context.exp regexp Tom de Vries
2026-08-19  8:36 ` Tom de Vries

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox