* tests/ptrace.c: New file.
* tests/ptrace.test: New test.
* tests/.gitignore: Add ptrace.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add ptrace.test.
---
 tests/.gitignore  |  1 +
 tests/Makefile.am |  2 ++
 tests/ptrace.c    | 46 ++++++++++++++++++++++++++++++++++++++++++++++
 tests/ptrace.test |  6 ++++++
 4 files changed, 55 insertions(+)
 create mode 100644 tests/ptrace.c
 create mode 100755 tests/ptrace.test

diff --git a/tests/.gitignore b/tests/.gitignore
index 745b7a1..96533fb 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -152,6 +152,7 @@ pread64-pwrite64
 preadv
 preadv-pwritev
 pselect6
+ptrace
 pwritev
 read-write
 readdir
diff --git a/tests/Makefile.am b/tests/Makefile.am
index c836e49..ce26306 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -205,6 +205,7 @@ check_PROGRAMS = \
        preadv \
        preadv-pwritev \
        pselect6 \
+       ptrace \
        pwritev \
        read-write \
        readdir \
@@ -484,6 +485,7 @@ DECODER_TESTS = \
        preadv-pwritev.test \
        preadv.test \
        pselect6.test \
+       ptrace.test \
        pwritev.test \
        read-write.test \
        readdir.test \
diff --git a/tests/ptrace.c b/tests/ptrace.c
new file mode 100644
index 0000000..df7ae0e
--- /dev/null
+++ b/tests/ptrace.c
@@ -0,0 +1,46 @@
+#include "tests.h"
+#include <sys/syscall.h>
+
+#ifdef __NR_ptrace
+
+# include <stdio.h>
+# include <unistd.h>
+# include <sys/ptrace.h>
+# include <signal.h>
+
+# define PTRACE_INVALID 99
+# define PTRACE_O_INVALID (1 << 18)
+# define NT_INVALID 0x111
+
+int
+main(void)
+{
+       long rc = syscall(__NR_ptrace, PTRACE_INVALID, -1, NULL, NULL);
+       printf("ptrace(%#x /* PTRACE_??? */, -1, NULL, NULL) = %ld %s (%m)\n",
+              PTRACE_INVALID, rc, errno2name());
+
+       rc = syscall(__NR_ptrace, PTRACE_ATTACH, -1, NULL, NULL);
+       printf("ptrace(PTRACE_ATTACH, -1, NULL, NULL) = %ld %s (%m)\n",
+              rc, errno2name());
+
+       rc = syscall(__NR_ptrace, PTRACE_SETOPTIONS, -1, NULL, 
PTRACE_O_INVALID);
+       printf("ptrace(PTRACE_SETOPTIONS, -1, NULL, %#x /* PTRACE_O_??? */) = 
%ld %s (%m)\n",
+              PTRACE_O_INVALID, rc, errno2name());
+
+       rc = syscall(__NR_ptrace, PTRACE_GETREGSET, -1, NT_INVALID, NULL);
+       printf("ptrace(PTRACE_GETREGSET, -1, %#x /* NT_??? */, NULL) = %ld %s 
(%m)\n",
+              NT_INVALID, rc, errno2name());
+
+       rc = syscall(__NR_ptrace, PTRACE_CONT, -1, NULL, 0);
+       printf("ptrace(PTRACE_CONT, -1, NULL, SIG_0) = %ld %s (%m)\n",
+              rc, errno2name());
+
+       puts("+++ exited with 0 +++");
+       return 0;
+}
+
+#else
+
+SKIP_MAIN_UNDEFINED("__NR_ptrace")
+
+#endif
diff --git a/tests/ptrace.test b/tests/ptrace.test
new file mode 100755
index 0000000..15e4d5d
--- /dev/null
+++ b/tests/ptrace.test
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+# Check ptrace syscall decoding.
+
+. "${srcdir=.}/init.sh"
+run_strace_match_diff -a37
-- 
1.8.3.1




------------------------------------------------------------------------------
Mobile security can be enabling, not merely restricting. Employees who
bring their own devices (BYOD) to work are irked by the imposition of MDM
restrictions. Mobile Device Manager Plus allows you to control only the
apps on BYO-devices by containerizing them, leaving personal data untouched!
https://ad.doubleclick.net/ddm/clk/304595813;131938128;j
_______________________________________________
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel

Reply via email to