1 /* -*- mode: C; c-basic-offset: 3; -*- */
10 #include <sys/ptrace.h>
11 #include <sys/types.h>
17 err_out(const char *msg
)
24 non_empty(const char *buf
, size_t len
)
28 volatile const char *p
= buf
;
30 for (i
= 0; i
!= len
; i
++)
38 if (ptrace(PTRACE_TRACEME
, 0, NULL
, NULL
) == -1)
39 return err_out("ptrace traceme");
54 return err_out("fork");
60 return err_out("wait");
62 /* Intentionally provide an uninitialized buffer to ptrace. */
63 iov
.iov_len
= sizeof(buf
);
65 if (ptrace(0x4204, cpid
, NT_PRSTATUS
, &iov
) == -1)
66 return err_out("ptrace getregset");
68 assert(iov
.iov_base
== buf
);
69 assert(iov
.iov_len
> 0 && iov
.iov_len
< sizeof(buf
));
71 /* We're assuming here that NT_PRSTATUS never contains
73 assert(non_empty(buf
, iov
.iov_len
));