From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2205) id B491B38485BC; Mon, 9 May 2022 10:01:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B491B38485BC Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Tom de Vries To: gdb-cvs@sourceware.org Subject: [binutils-gdb] [gdb/testsuite] Handle pipe2 syscall in gdb.base/catch-syscall.exp X-Act-Checkin: binutils-gdb X-Git-Author: Tom de Vries X-Git-Refname: refs/heads/master X-Git-Oldrev: cd02db09d26959ea58771c946b44e56fe8c0d36e X-Git-Newrev: 5463a15c18bf01ba33bfbdc6739649fe1d00058b Message-Id: <20220509100146.B491B38485BC@sourceware.org> Date: Mon, 9 May 2022 10:01:46 +0000 (GMT) X-BeenThere: gdb-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 May 2022 10:01:46 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D5463a15c18bf= 01ba33bfbdc6739649fe1d00058b commit 5463a15c18bf01ba33bfbdc6739649fe1d00058b Author: Tom de Vries Date: Mon May 9 12:01:42 2022 +0200 [gdb/testsuite] Handle pipe2 syscall in gdb.base/catch-syscall.exp =20 When running test-case gdb.reverse/pipe-reverse.exp on openSUSE Tumblew= eed, I run into: ... (gdb) continue^M Continuing.^M ^M Catchpoint 2 (returned from syscall pipe2), in pipe () from /lib64/libc= .so.6^M (gdb) FAIL: gdb.base/catch-syscall.exp: without arguments: \ syscall pipe has returned ... =20 The current glibc on Tumbleweed is 2.35, which contains commit "linux: Implement pipe in terms of __NR_pipe2", and consequently syscal= l pipe2 is used instead of syscall pipe. =20 Fix this by detecting whether syscall pipe or pipe2 is used before runn= ing the tests. =20 Tested on x86_64-linux, specifically on: - openSUSE Tumbleweed (with glibc 2.35), and - openSUSE Leap 15.3 (with glibc 2.31). =20 On openSUSE Tumbleweed + target board unix/-m32, this exposes: ... (gdb) catch syscall pipe2^M Unknown syscall name 'pipe2'.^M ... which will be fixed in a folllow-up patch. =20 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=3D29056 Diff: --- gdb/testsuite/gdb.base/catch-syscall.c | 3 +- gdb/testsuite/gdb.base/catch-syscall.exp | 69 ++++++++++++++++++++++++++++= ---- 2 files changed, 64 insertions(+), 8 deletions(-) diff --git a/gdb/testsuite/gdb.base/catch-syscall.c b/gdb/testsuite/gdb.bas= e/catch-syscall.c index 0ab96318d3e..8c252a06b20 100644 --- a/gdb/testsuite/gdb.base/catch-syscall.c +++ b/gdb/testsuite/gdb.base/catch-syscall.c @@ -24,7 +24,8 @@ int chroot_syscall =3D SYS_chroot; int read_syscall =3D SYS_read; #ifdef SYS_pipe int pipe_syscall =3D SYS_pipe; -#else +#endif +#ifdef SYS_pipe2 int pipe2_syscall =3D SYS_pipe2; #endif int write_syscall =3D SYS_write; diff --git a/gdb/testsuite/gdb.base/catch-syscall.exp b/gdb/testsuite/gdb.b= ase/catch-syscall.exp index a5dfd02411b..1427dfece6d 100644 --- a/gdb/testsuite/gdb.base/catch-syscall.exp +++ b/gdb/testsuite/gdb.base/catch-syscall.exp @@ -669,35 +669,90 @@ proc fill_all_syscalls_numbers {} { set unknown_syscall_number [get_integer_valueof "unknown_syscall" -1] } =20 -# Set up the vector all_syscalls. +# Set up the vector all_syscalls. Returns 1 upon success, 0 upon failure. =20 proc setup_all_syscalls {} { global all_syscalls global gdb_prompt + global decimal =20 # They are ordered according to the file, so do not change this. lappend all_syscalls "close" lappend all_syscalls "chroot" =20 + if { ![runto_main] } { + return 0 + } + # SYS_pipe doesn't exist on aarch64 kernel. set test "check SYS_pipe" + set have_SYS_pipe 0 gdb_test_multiple "p pipe_syscall" $test { - -re " =3D .*$gdb_prompt $" { + -re -wrap " =3D $decimal" { pass $test - lappend all_syscalls "pipe" + set have_SYS_pipe 1 } - -re "No symbol .*$gdb_prompt $" { + -re -wrap "No symbol .*" { pass $test - # SYS_pipe isn't defined, use SYS_pipe2 instead. - lappend all_syscalls "pipe2" + } + } + + set test "check SYS_pipe2" + set have_SYS_pipe2 0 + gdb_test_multiple "p pipe2_syscall" $test { + -re -wrap " =3D $decimal" { + pass $test + set have_SYS_pipe2 1 + } + -re -wrap "No symbol .*" { + pass $test + } + } + + if { $have_SYS_pipe =3D=3D 0 && $have_SYS_pipe2 =3D=3D 0 } { + return 0 + } + + with_test_prefix "determine pipe syscall" { + set line [gdb_get_line_number "pipe (fd)"] + gdb_test "break $line" + gdb_continue_to_breakpoint "before pipe call" + if { $have_SYS_pipe } { + gdb_test "catch syscall pipe" + } + if { $have_SYS_pipe2 } { + gdb_test "catch syscall pipe2" + } + set ok 0 + gdb_test_multiple "continue" "" { + -re -wrap "Catchpoint $decimal \\(call to syscall pipe\\).*" { + lappend all_syscalls pipe + pass $gdb_test_name + set ok 1 + } + -re -wrap "Catchpoint $decimal \\(call to syscall pipe2\\).*" { + lappend all_syscalls pipe2 + pass $gdb_test_name + set ok 1 + } + -re -wrap "" { + fail $gdb_test_name + } + } + if { ! $ok } { + return 0 } } =20 lappend all_syscalls "write" lappend all_syscalls "read" + + return 1 } =20 -setup_all_syscalls +if { ![setup_all_syscalls] } { + return -1 +} =20 # Fill all the syscalls numbers before starting anything. fill_all_syscalls_numbers