Skip to content

Commit 1b9a9c3

Browse files
committed
[gdb/testsuite] Fix race in gdb.base/add-symbol-file-attach.exp
When running test-case gdb.base/add-symbol-file-attach.exp with target board unix/-m32, we run into: ... (gdb) attach 3955^M Attaching to process 3955^M Load new symbol table from "add-symbol-file-attach"? (y or n) y^M Reading symbols from add-symbol-file-attach/add-symbol-file-attach...^M Reading symbols from /lib/libm.so.6...^M Reading symbols from /usr/lib/debug/lib/libm-2.31.so-i386.debug...^M Reading symbols from /lib/libc.so.6...^M Reading symbols from /usr/lib/debug/lib/libc-2.31.so-i386.debug...^M Reading symbols from /lib/ld-linux.so.2...^M Reading symbols from /usr/lib/debug/lib/ld-2.31.so-i386.debug...^M 0xf7f53549 in __kernel_vsyscall ()^M (gdb) FAIL: gdb.base/add-symbol-file-attach.exp: attach ... The test fails because this regexp is used: ... -re ".*in \[_A-Za-z0-9\]*pause.*$gdb_prompt $" { ... The regexp attempts to detect that the exec is somewhere in pause (): ... int main (int argc, char **argv) { pause (); return 0; } ... but when the exec is blocked in pause, the backtrace is: ... (gdb) bt #0 0xf7fd2549 in __kernel_vsyscall () #1 0xf7d84966 in __libc_pause () at ../sysdeps/unix/sysv/linux/pause.c:29 #2 0x0804844c in main (argc=1, argv=0xffffce84) at /data/vries/gdb/src/gdb/testsuite/gdb.base/add-symbol-file-attach.c:26 ... We could simply extend the regexp to also match __kernel_vsyscall, but the more fundamental problem is that the test is racy. The attach can happen before the exec is blocked in pause (), somewhere in the dynamic linker resolving the call to pause, in main or even earlier. Note that for the test-case to be effective, the exec is not required to be in pause (). I added a "while (1);" loop at the start of main, reverted the patch fixing the corresponding PR and reproduced the problem it's supposed to detect. Fix this by simply matching the "Reading symbols from" line, similar to what an earlier test is doing. While we're at it, rewrite the earlier test to also use the -wrap idiom. Tested on x86_64-linux.
1 parent 0f020d9 commit 1b9a9c3

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

gdb/testsuite/gdb.base/add-symbol-file-attach.exp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ gdb_test_multiple "add-symbol-file $binfile" $test {
5757
send_gdb "y\n"
5858
exp_continue
5959
}
60-
-re "Reading symbols from.*$gdb_prompt $" {
60+
-re -wrap "Reading symbols from .*" {
6161
pass $test
6262
}
6363
}
@@ -71,7 +71,7 @@ gdb_test_multiple "attach $testpid" $test {
7171
send_gdb "y\n"
7272
exp_continue
7373
}
74-
-re ".*in \[_A-Za-z0-9\]*pause.*$gdb_prompt $" {
74+
-re -wrap "Reading symbols from .*" {
7575
pass $test
7676
}
7777
}

0 commit comments

Comments
 (0)