From: Tom de Vries <tdevries@suse.de>
To: Guinevere Larsen <guinevere@redhat.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH] gdb/testsuite: fix gdb.base/dlmopen-ns-ids.exp racy test
Date: Thu, 10 Apr 2025 10:11:28 +0200 [thread overview]
Message-ID: <27d87d8d-2bf9-45db-87b3-6e2d5a843eb9@suse.de> (raw)
In-Reply-To: <d38bd78a-3f51-4820-868e-3804aa3ad193@suse.de>
On 4/10/25 06:40, Tom de Vries wrote:
> On 4/9/25 20:25, Guinevere Larsen wrote:
>> * using exp_continue caused the value of ns to be overwritten, returning
>> the last SO_NS, instead of the first
>
> Hi Gwen,
>
> my guess is that this is the right solution, and that you can just check
> for $ns == -1 to make sure only the first value is picked.
I tried this out, and got it working, after fixing the following.
There is a problem with the gdb_test_multiple.
It uses -lbl, which is the style of processing one line at a time, with
\r\n at the start, and (?=\r\n) at the end, which matches but not
consumes it (lookahead), always leaving an \r\n at the start of the next
line.
This matches what -wrap (which is based on gdb_test) does which requires
an \r\n before the prompt.
I got the test-case working using:
...
diff --git a/gdb/testsuite/gdb.base/dlmopen-ns-ids.exp
b/gdb/testsuite/gdb.base/dlmopen-ns-ids.exp
index 03b7a527af5..d3584a0a402 100644
--- a/gdb/testsuite/gdb.base/dlmopen-ns-ids.exp
+++ b/gdb/testsuite/gdb.base/dlmopen-ns-ids.exp
@@ -42,17 +42,17 @@ if { [build_executable "failed to build" $testfile
$srcfile \
proc get_first_so_ns {} {
set ns -1
gdb_test_multiple "info sharedlibrary" "get SO namespace" -lbl {
- -re "From\\s+To\\s+\(NS\\s+\)?Syms\\s+Read\\s+Shared Object Library\r\n" {
+ -re "\r\nFrom\\s+To\\s+\(NS\\s+\)?Syms\\s+Read\\s+Shared Object
Library(?=\r\n)" {
exp_continue
}
- -re
"^$::hex\\s+$::hex\\s+\\\[\\\[($::decimal)\\\]\\\]\\s+\[^\r\n]+$::binfile_lib.*"
{
- set ns $expect_out(1,string)
- }
- -re "^$::gdb_prompt $" {
- }
- -re "^\[^\r\n\]+\r\n" {
+ -re
"\r\n$::hex\\s+$::hex\\s+\\\[\\\[($::decimal)\\\]\\\]\\s+\[^\r\n]+${::binfile_lib}(?=\r\n
)" {
+ if { $ns == -1 } {
+ set ns $expect_out(1,string)
+ }
exp_continue
}
+ -re -wrap "" {
+ }
}
return $ns
}
...
I also think that binfile_lib needs to be wrapped in string_to_regexp.
Thanks,
- Tom
next prev parent reply other threads:[~2025-04-10 8:11 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-09 18:25 Guinevere Larsen
2025-04-10 4:40 ` Tom de Vries
2025-04-10 8:11 ` Tom de Vries [this message]
2025-04-10 12:43 ` Guinevere Larsen
2025-04-10 13:01 ` [PATCH v2] " Guinevere Larsen
2025-04-11 10:26 ` Tom de Vries
2025-04-11 12:32 ` Guinevere Larsen
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=27d87d8d-2bf9-45db-87b3-6e2d5a843eb9@suse.de \
--to=tdevries@suse.de \
--cc=gdb-patches@sourceware.org \
--cc=guinevere@redhat.com \
/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