aboutsummaryrefslogtreecommitdiff
path: root/test/sanitizer_common/TestCases/Linux/ptrace.cc
diff options
context:
space:
mode:
Diffstat (limited to 'test/sanitizer_common/TestCases/Linux/ptrace.cc')
-rw-r--r--test/sanitizer_common/TestCases/Linux/ptrace.cc45
1 files changed, 41 insertions, 4 deletions
diff --git a/test/sanitizer_common/TestCases/Linux/ptrace.cc b/test/sanitizer_common/TestCases/Linux/ptrace.cc
index ba318169ee7d..67b64743043b 100644
--- a/test/sanitizer_common/TestCases/Linux/ptrace.cc
+++ b/test/sanitizer_common/TestCases/Linux/ptrace.cc
@@ -7,11 +7,17 @@
#include <sys/types.h>
#include <sys/user.h>
#include <sys/wait.h>
+#include <sys/uio.h>
#include <unistd.h>
-#if __mips64
+#include <elf.h>
+#if __mips64 || __arm__
#include <asm/ptrace.h>
#include <sys/procfs.h>
#endif
+#ifdef __aarch64__
+// GLIBC 2.20+ sys/user does not include asm/ptrace.h
+ #include <asm/ptrace.h>
+#endif
int main(void) {
pid_t pid;
@@ -37,23 +43,54 @@ int main(void) {
printf("%x\n", fpregs.mxcsr);
#endif // __x86_64__
-#if (__powerpc64__ || __mips64)
+#if (__powerpc64__ || __mips64 || __arm__)
struct pt_regs regs;
res = ptrace((enum __ptrace_request)PTRACE_GETREGS, pid, NULL, &regs);
assert(!res);
#if (__powerpc64__)
if (regs.nip)
printf("%lx\n", regs.nip);
-#else
+#elif (__mips64)
if (regs.cp0_epc)
printf("%lx\n", regs.cp0_epc);
+#elif (__arm__)
+ if (regs.ARM_pc)
+ printf("%lx\n", regs.ARM_pc);
#endif
+#if (__powerpc64 || __mips64)
elf_fpregset_t fpregs;
res = ptrace((enum __ptrace_request)PTRACE_GETFPREGS, pid, NULL, &fpregs);
assert(!res);
if ((elf_greg_t)fpregs[32]) // fpscr
printf("%lx\n", (elf_greg_t)fpregs[32]);
-#endif // (__powerpc64__ || __mips64)
+#elif (__arm__)
+ char regbuf[ARM_VFPREGS_SIZE];
+ res = ptrace((enum __ptrace_request)PTRACE_GETVFPREGS, pid, 0, regbuf);
+ assert(!res);
+ unsigned fpscr = *(unsigned*)(regbuf + (32 * 8));
+ printf ("%x\n", fpscr);
+#endif
+#endif // (__powerpc64__ || __mips64 || __arm__)
+
+#if (__aarch64__)
+ struct iovec regset_io;
+
+ struct user_pt_regs regs;
+ regset_io.iov_base = &regs;
+ regset_io.iov_len = sizeof(regs);
+ res = ptrace(PTRACE_GETREGSET, pid, (void*)NT_PRSTATUS, (void*)&regset_io);
+ assert(!res);
+ if (regs.pc)
+ printf("%llx\n", regs.pc);
+
+ struct user_fpsimd_state fpregs;
+ regset_io.iov_base = &fpregs;
+ regset_io.iov_len = sizeof(fpregs);
+ res = ptrace(PTRACE_GETREGSET, pid, (void*)NT_FPREGSET, (void*)&regset_io);
+ assert(!res);
+ if (fpregs.fpsr)
+ printf("%x\n", fpregs.fpsr);
+#endif // (__aarch64__)
siginfo_t siginfo;
res = ptrace(PTRACE_GETSIGINFO, pid, NULL, &siginfo);