Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/tests/kernel/arch/amd64 Add regs1 in arch/amd64/t_ptrace_wait*
details: https://anonhg.NetBSD.org/src/rev/52ed53a8f8ac
branches: trunk
changeset: 349524:52ed53a8f8ac
user: kamil <kamil%NetBSD.org@localhost>
date: Tue Dec 13 13:04:18 2016 +0000
description:
Add regs1 in arch/amd64/t_ptrace_wait*
regs1:
Call PT_GETREGS and iterate over General Purpose registers
Sponsored by <The NetBSD Foundation>
diffstat:
tests/kernel/arch/amd64/t_ptrace_wait.c | 88 ++++++++++++++++++++++++++++++++-
1 files changed, 86 insertions(+), 2 deletions(-)
diffs (116 lines):
diff -r c95d03ecbfcb -r 52ed53a8f8ac tests/kernel/arch/amd64/t_ptrace_wait.c
--- a/tests/kernel/arch/amd64/t_ptrace_wait.c Tue Dec 13 12:59:46 2016 +0000
+++ b/tests/kernel/arch/amd64/t_ptrace_wait.c Tue Dec 13 13:04:18 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: t_ptrace_wait.c,v 1.5 2016/12/07 22:24:44 kamil Exp $ */
+/* $NetBSD: t_ptrace_wait.c,v 1.6 2016/12/13 13:04:18 kamil Exp $ */
/*-
* Copyright (c) 2016 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: t_ptrace_wait.c,v 1.5 2016/12/07 22:24:44 kamil Exp $");
+__RCSID("$NetBSD: t_ptrace_wait.c,v 1.6 2016/12/13 13:04:18 kamil Exp $");
#include <sys/param.h>
#include <sys/types.h>
@@ -84,6 +84,88 @@
} bits;
};
+#if defined(HAVE_GPREGS)
+ATF_TC(regs1);
+ATF_TC_HEAD(regs1, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Call PT_GETREGS and iterate over General Purpose registers");
+}
+
+ATF_TC_BODY(regs1, tc)
+{
+ const int exitval = 5;
+ const int sigval = SIGSTOP;
+ pid_t child, wpid;
+#if defined(TWAIT_HAVE_STATUS)
+ int status;
+#endif
+ struct reg r;
+
+ printf("Before forking process PID=%d\n", getpid());
+ ATF_REQUIRE((child = fork()) != -1);
+ if (child == 0) {
+ printf("Before calling PT_TRACE_ME from child %d\n", getpid());
+ FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
+
+ printf("Before raising %s from child\n", strsignal(sigval));
+ FORKEE_ASSERT(raise(sigval) == 0);
+
+ printf("Before exiting of the child process\n");
+ _exit(exitval);
+ }
+ printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_stopped(status, sigval);
+
+ printf("Call GETREGS for the child process\n");
+ ATF_REQUIRE(ptrace(PT_GETREGS, child, &r, 0) != -1);
+
+ printf("RAX=%#" PRIxREGISTER "\n", r.regs[_REG_RAX]);
+ printf("RBX=%#" PRIxREGISTER "\n", r.regs[_REG_RBX]);
+ printf("RCX=%#" PRIxREGISTER "\n", r.regs[_REG_RCX]);
+ printf("RDX=%#" PRIxREGISTER "\n", r.regs[_REG_RDX]);
+
+ printf("RDI=%#" PRIxREGISTER "\n", r.regs[_REG_RDI]);
+ printf("RSI=%#" PRIxREGISTER "\n", r.regs[_REG_RSI]);
+
+ printf("GS=%#" PRIxREGISTER "\n", r.regs[_REG_GS]);
+ printf("FS=%#" PRIxREGISTER "\n", r.regs[_REG_FS]);
+ printf("ES=%#" PRIxREGISTER "\n", r.regs[_REG_ES]);
+ printf("DS=%#" PRIxREGISTER "\n", r.regs[_REG_DS]);
+ printf("CS=%#" PRIxREGISTER "\n", r.regs[_REG_CS]);
+ printf("SS=%#" PRIxREGISTER "\n", r.regs[_REG_SS]);
+
+ printf("RSP=%#" PRIxREGISTER "\n", r.regs[_REG_RSP]);
+ printf("RIP=%#" PRIxREGISTER "\n", r.regs[_REG_RIP]);
+
+ printf("RFLAGS=%#" PRIxREGISTER "\n", r.regs[_REG_RFLAGS]);
+
+ printf("R8=%#" PRIxREGISTER "\n", r.regs[_REG_R8]);
+ printf("R9=%#" PRIxREGISTER "\n", r.regs[_REG_R9]);
+ printf("R10=%#" PRIxREGISTER "\n", r.regs[_REG_R10]);
+ printf("R11=%#" PRIxREGISTER "\n", r.regs[_REG_R11]);
+ printf("R12=%#" PRIxREGISTER "\n", r.regs[_REG_R12]);
+ printf("R13=%#" PRIxREGISTER "\n", r.regs[_REG_R13]);
+ printf("R14=%#" PRIxREGISTER "\n", r.regs[_REG_R14]);
+ printf("R15=%#" PRIxREGISTER "\n", r.regs[_REG_R15]);
+
+ printf("Before resuming the child process where it left off and "
+ "without signal to be sent\n");
+ ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_exited(status, exitval);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
+}
+#endif
#if defined(HAVE_DBREGS)
ATF_TC(dbregs_print);
@@ -1673,6 +1755,8 @@
setvbuf(stdout, NULL, _IONBF, 0);
setvbuf(stderr, NULL, _IONBF, 0);
+ ATF_TP_ADD_TC_HAVE_GPREGS(tp, regs1);
+
ATF_TP_ADD_TC_HAVE_DBREGS(tp, dbregs_print);
ATF_TP_ADD_TC_HAVE_DBREGS(tp, dbregs_preserve_dr0);
- Prev by Date:
[src/trunk]: src/tests/kernel Remove dbregs[12] from t_ptrace_wait{, 3, 4, 6, id, ...
- Next by Date:
[src/trunk]: src/tests/kernel/arch/amd64 Define in CPPFLAGS symbol _KERNTYPES...
- Previous by Thread:
[src/trunk]: src/tests/kernel Remove dbregs[12] from t_ptrace_wait{, 3, 4, 6, id, ...
- Next by Thread:
[src/trunk]: src/tests/kernel/arch/amd64 Define in CPPFLAGS symbol _KERNTYPES...
- Indexes:
Home |
Main Index |
Thread Index |
Old Index