aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuinevere Larsen <guinevere@redhat.com>2025-04-09 15:08:13 -0300
committerGuinevere Larsen <guinevere@redhat.com>2025-04-11 09:17:58 -0300
commitda9ffdece9b30cec63bb890c4e36575648b3f222 (patch)
treec91891b3b810b2dc7ce93ccf8bc7269755f4dd40
parentea0498f46e440199907213d920b7964d4fc38dc5 (diff)
downloadgdb-da9ffdece9b30cec63bb890c4e36575648b3f222.zip
gdb-da9ffdece9b30cec63bb890c4e36575648b3f222.tar.gz
gdb-da9ffdece9b30cec63bb890c4e36575648b3f222.tar.bz2
gdb/testsuite: fix gdb.base/dlmopen-ns-ids.exp racy test
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, the test was changed so that we consume all of the output of the command "info sharedlibrary", but only set the namespace ID for the first occurrence of the SO we're looking for. The command now also gets the solib name as a parameter, to reduce the amount of output. Co-Authored-By: Tom de Vries <tdevries@suse.de> Approved-By: Tom de Vries <tdevries@suse.de>
-rw-r--r--gdb/testsuite/gdb.base/dlmopen-ns-ids.exp20
1 files changed, 11 insertions, 9 deletions
diff --git a/gdb/testsuite/gdb.base/dlmopen-ns-ids.exp b/gdb/testsuite/gdb.base/dlmopen-ns-ids.exp
index 03b7a52..3ddc07e 100644
--- a/gdb/testsuite/gdb.base/dlmopen-ns-ids.exp
+++ b/gdb/testsuite/gdb.base/dlmopen-ns-ids.exp
@@ -24,7 +24,8 @@ require allow_dlmopen_tests
standard_testfile -main.c -lib.c
set srcfile_lib $srcfile2
-set binfile_lib [standard_output_file dlmopen-lib.so]
+set so_name dlmopen-lib.so
+set binfile_lib [standard_output_file $so_name]
if { [build_executable "build shlib" $binfile_lib $srcfile_lib \
[list debug shlib]] == -1 } {
@@ -41,18 +42,19 @@ if { [build_executable "failed to build" $testfile $srcfile \
# for the so
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" {
+ set lib_regexp [string_to_regexp ${::binfile_lib}]
+ gdb_test_multiple "info sharedlibrary $::so_name" "get SO namespace" -lbl {
+ -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]+${lib_regexp}(?=\r\n)" {
+ if {$ns == -1} {
+ set ns $expect_out(1,string)
+ }
exp_continue
}
+ -re -wrap "" {
+ }
}
return $ns
}