[binutils-gdb] [gdb/testsuite] Fix gdb.base/attach-deleted-exec.exp with NFS

Tom de Vries vries@sourceware.org
Mon Sep 23 05:53:16 GMT 2024


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=5cd2a23195293a5006841ab80543f1df04ffd39e

commit 5cd2a23195293a5006841ab80543f1df04ffd39e
Author: Tom de Vries <tdevries@suse.de>
Date:   Mon Sep 23 07:53:20 2024 +0200

    [gdb/testsuite] Fix gdb.base/attach-deleted-exec.exp with NFS
    
    With test-case gdb.base/attach-deleted-exec.exp I ran into:
    ...
    (gdb) attach 121552^M
    Attaching to process 121552^M
    Reading symbols .../attach-deleted-exec/.nfs00000000044ff2ef00000086...^M
    Reading symbols from /lib64/libm.so.6...^M
    (No debugging symbols found in /lib64/libm.so.6)^M
    Reading symbols from /lib64/libc.so.6...^M
    (No debugging symbols found in /lib64/libc.so.6)^M
    Reading symbols from /lib64/ld64.so.2...^M
    (No debugging symbols found in /lib64/ld64.so.2)^M
    0x00007fff947cc838 in clock_nanosleep@@GLIBC_2.17 () from /lib64/libc.so.6^M
    (gdb) FAIL: $exp: attach to process with deleted executable
    ....
    
    The .nfs file indicates:
    - that the file has been removed on the NFS server, and
    - that the file is still open on the NFS client.
    
    Fix this by detecting this situation, and declaring the test for filename
    /proc/PID/exe unsupported.
    
    Tested on:
    - x86_64-linux (setup without NFS)
    - ppc64le-linux (setup with NFS)
    
    PR testsuite/32130
    Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32130

Diff:
---
 gdb/testsuite/gdb.base/attach-deleted-exec.exp | 24 +++++++++++++++++++++---
 1 file changed, 21 insertions(+), 3 deletions(-)

diff --git a/gdb/testsuite/gdb.base/attach-deleted-exec.exp b/gdb/testsuite/gdb.base/attach-deleted-exec.exp
index 3e31c36bcc4..11961153fe7 100644
--- a/gdb/testsuite/gdb.base/attach-deleted-exec.exp
+++ b/gdb/testsuite/gdb.base/attach-deleted-exec.exp
@@ -45,9 +45,27 @@ clean_restart
 
 # Attach.  GDB should spot that the executable is gone and fallback to
 # use /proc/PID/exe.
-gdb_test "attach $testpid" \
-    "Attaching to process $decimal\r\nReading symbols from /proc/${testpid}/exe\\.\\.\\..*" \
-    "attach to process with deleted executable"
+set test "attach to process with deleted executable"
+set re \
+    [multi_line \
+	 "Attaching to process $decimal" \
+	 "Reading symbols from (\[^\r\n\]+)[string_to_regexp ...]" \
+	 ".*"]
+set filename ""
+gdb_test_multiple "attach $testpid" $test {
+    -re -wrap $re {
+	set filename $expect_out(1,string)
+	pass $gdb_test_name
+    }
+}
+
+set test "filename /proc/PID/exe"
+set re_nfs \[^\r\n\]+[string_to_regexp /.nfs]\[^\r\n\]+
+if { [regexp $re_nfs $filename] } {
+    unsupported $test
+} else {
+    gdb_assert { [string equal $filename /proc/${testpid}/exe] } $test
+}
 
 # Cleanup.
 kill_wait_spawned_process $test_spawn_id


More information about the Gdb-cvs mailing list