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>
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.*"