From: Guinevere Larsen <guinevere@redhat.com>
To: gdb-patches@sourceware.org
Cc: Guinevere Larsen <guinevere@redhat.com>
Subject: [PATCH] gdb/testsuite: fix gdb.base/dlmopen-ns-ids.exp racy test
Date: Wed, 9 Apr 2025 15:25:10 -0300 [thread overview]
Message-ID: <20250409182510.1629742-1-guinevere@redhat.com> (raw)
The recently included gdb.base/dlmopen-ns-ids.exp test can sometimes
fail the call to get_integer_valueof when trying to check the namespace
ID of the fourth dlopened SO, for apparently no reason.
What's happening is that the call to get_first_so_ns doesn't necessarily
consume the GDB prompt, and so get_integer_valueof will see the prompt
immediately and not find the value the test is looking for.
To fix this, a call to gdb_test is added to the end of get_first_so_ns
to consume the prompt if it wasn't consumed by the previous
gdb_test_multiple call. If the namespace was found (and so ns is not
-1), we can guarantee that the prompt was not consumed.
I tried several other ways to solve that problem, but they each caused
different problems:
* using -wrap in the second block of the gdb_test_multiple resulted in
every call timing out
* reducing the output with a pattern on the "info shared" call and
adding -wrap caused the line to not be recognized
* using exp_continue caused the value of ns to be overwritten, returning
the last SO_NS, instead of the first
With all these problems, adding the gdb_test call seemed the least
fragile option.
---
gdb/testsuite/gdb.base/dlmopen-ns-ids.exp | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/gdb/testsuite/gdb.base/dlmopen-ns-ids.exp b/gdb/testsuite/gdb.base/dlmopen-ns-ids.exp
index 03b7a527af5..5c65162d98f 100644
--- a/gdb/testsuite/gdb.base/dlmopen-ns-ids.exp
+++ b/gdb/testsuite/gdb.base/dlmopen-ns-ids.exp
@@ -45,7 +45,7 @@ proc get_first_so_ns {} {
-re "From\\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.*" {
+ -re "^$::hex\\s+$::hex\\s+\\\[\\\[($::decimal)\\\]\\\]\\s+\[^\r\n]+$::binfile_lib\r\n" {
set ns $expect_out(1,string)
}
-re "^$::gdb_prompt $" {
@@ -54,6 +54,14 @@ proc get_first_so_ns {} {
exp_continue
}
}
+ # Clear the prompt from the previous test, if it was not consumed.
+ # This can't be done in the previous test because we need to leave on
+ # the first occurrence of the library, otherwise we'll overwrite the
+ # namespace found, and just adding gdb_prompt to the end of the success
+ # case caused several timeouts.
+ if {$ns != -1} {
+ gdb_test -nopass "" ".*"
+ }
return $ns
}
base-commit: d8c3e4901650e35ddf5083f693b8a21b9d24fcc6
--
2.49.0
next reply other threads:[~2025-04-09 18:25 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-09 18:25 Guinevere Larsen [this message]
2025-04-10 4:40 ` Tom de Vries
2025-04-10 8:11 ` Tom de Vries
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=20250409182510.1629742-1-guinevere@redhat.com \
--to=guinevere@redhat.com \
--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