Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/tests/lib/libc/sys Merge PT_GET_PROCESS_STATE checks into tr...



details:   https://anonhg.NetBSD.org/src/rev/f54b1d025bb1
branches:  trunk
changeset: 1003822:f54b1d025bb1
user:      kamil <kamil%NetBSD.org@localhost>
date:      Tue Oct 01 22:26:38 2019 +0000

description:
Merge PT_GET_PROCESS_STATE checks into traceme_raise ATF ptrace tests

Assert that PT_GET_PROCESS_STATE for !child and !lwp events returns
non-error and zeroed struct ptrace_state.

These checks are not really special to traceme_raise, it's just an
opportunity to reuse them in an existing tests without writing a dedicated
one.

This behavior is needed to maintain in 3rd party software (GDB).

diffstat:

 tests/lib/libc/sys/t_ptrace_wait.c |  15 +++++++++++++--
 1 files changed, 13 insertions(+), 2 deletions(-)

diffs (51 lines):

diff -r 2b03a4940689 -r f54b1d025bb1 tests/lib/libc/sys/t_ptrace_wait.c
--- a/tests/lib/libc/sys/t_ptrace_wait.c        Tue Oct 01 21:49:50 2019 +0000
+++ b/tests/lib/libc/sys/t_ptrace_wait.c        Tue Oct 01 22:26:38 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: t_ptrace_wait.c,v 1.132 2019/10/01 21:13:30 kamil Exp $        */
+/*     $NetBSD: t_ptrace_wait.c,v 1.133 2019/10/01 22:26:38 kamil Exp $        */
 
 /*-
  * Copyright (c) 2016, 2017, 2018, 2019 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: t_ptrace_wait.c,v 1.132 2019/10/01 21:13:30 kamil Exp $");
+__RCSID("$NetBSD: t_ptrace_wait.c,v 1.133 2019/10/01 22:26:38 kamil Exp $");
 
 #include <sys/param.h>
 #include <sys/types.h>
@@ -140,7 +140,10 @@
        int status;
 #endif
 
+       ptrace_state_t state, zero_state;
+       const int slen = sizeof(state);
        struct ptrace_siginfo info;
+       memset(&zero_state, 0, sizeof(zero_state));
        memset(&info, 0, sizeof(info));
 
        DPRINTF("Before forking process PID=%d\n", getpid());
@@ -170,6 +173,9 @@
        switch (sigval) {
        case SIGKILL:
                validate_status_signaled(status, sigval, 0);
+               SYSCALL_REQUIRE(
+                   ptrace(PT_GET_PROCESS_STATE, child, &state, slen) == -1);
+
                break;
        default:
                validate_status_stopped(status, sigval);
@@ -188,6 +194,11 @@
                ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, sigval);
                ATF_REQUIRE_EQ(info.psi_siginfo.si_code, SI_LWP);
 
+               DPRINTF("Assert that PT_GET_PROCESS_STATE returns non-error");
+               SYSCALL_REQUIRE(
+                   ptrace(PT_GET_PROCESS_STATE, child, &state, slen) != -1);
+               ATF_REQUIRE(memcmp(&state, &zero_state, slen) == 0);
+
                DPRINTF("Before resuming the child process where it left off "
                    "and without signal to be sent\n");
                SYSCALL_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);



Home | Main Index | Thread Index | Old Index