From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Subject: [PATCH] [gdb/testsuite] Fix gdb.python/py-selected-context.exp regexp
Date: Mon, 3 Aug 2026 10:07:21 +0200 [thread overview]
Message-ID: <20260803080721.859964-1-tdevries@suse.de> (raw)
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
next reply other threads:[~2026-08-03 8:07 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-03 8:07 Tom de Vries [this message]
2026-08-19 8:36 ` Tom de Vries
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260803080721.859964-1-tdevries@suse.de \
--to=tdevries@suse.de \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox