public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] gdb: testsuite: use gdb_attach to fix attach-pie-noexec.exp
@ 2022-03-23  3:59 Tiezhu Yang
  0 siblings, 0 replies; only message in thread
From: Tiezhu Yang @ 2022-03-23  3:59 UTC (permalink / raw)
  To: gdb-cvs

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

commit 5b5442fbf0fab8bd3cb4d19e564b13501f547dac
Author: Tiezhu Yang <yangtiezhu@loongson.cn>
Date:   Thu Mar 17 10:25:09 2022 +0800

    gdb: testsuite: use gdb_attach to fix attach-pie-noexec.exp
    
    If /proc/sys/kernel/yama/ptrace_scope is 1, when execute the following
    command without superuser:
    
      make check-gdb TESTS="gdb.base/attach-pie-noexec.exp"
    
    we can see the following messages in gdb/testsuite/gdb.log:
    
      (gdb) attach 6500
      Attaching to process 6500
      ptrace: Operation not permitted.
      (gdb) PASS: gdb.base/attach-pie-noexec.exp: attach
    
    It is obviously wrong, the expected result should be UNSUPPORTED in such
    a case.
    
    With this patch, we can see "Operation not permitted" in the log info,
    and then we can do the following processes to test:
    (1) set ptrace_scope as 0
        $ echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope
        $ make check-gdb TESTS="gdb.base/attach-pie-noexec.exp"
    (2) use sudo
        $ sudo make check-gdb TESTS="gdb.base/attach-pie-noexec.exp"
    
    Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>

Diff:
---
 gdb/testsuite/gdb.base/attach-pie-noexec.exp | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/gdb/testsuite/gdb.base/attach-pie-noexec.exp b/gdb/testsuite/gdb.base/attach-pie-noexec.exp
index 471282466df..33238db834d 100644
--- a/gdb/testsuite/gdb.base/attach-pie-noexec.exp
+++ b/gdb/testsuite/gdb.base/attach-pie-noexec.exp
@@ -59,7 +59,10 @@ set testpid [spawn_id_get_pid $test_spawn_id]
 
 gdb_start
 file delete -- $binfile
-gdb_test "attach $testpid" "Attaching to process $testpid\r\n.*" "attach"
+if { ![gdb_attach $testpid] } {
+    kill_wait_spawned_process $test_spawn_id
+    return
+}
 gdb_test "set architecture $arch" "The target architecture is set to \"$arch\"\\."
 gdb_test "info shared" "From\[ \t\]+To\[ \t\]+Syms Read\[ \t\]+Shared Object Library\r\n0x.*"


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-03-23  3:59 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-23  3:59 [binutils-gdb] gdb: testsuite: use gdb_attach to fix attach-pie-noexec.exp Tiezhu Yang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).