From c8ee0357e8c75bcb32f26cc378ec63ed46d7e363 Mon Sep 17 00:00:00 2001 From: Pierre Pronchery Date: Sun, 4 Nov 2012 00:47:03 +0100 Subject: [PATCH] Using a more portable API for ptrace() in the first place (from BSD) --- src/freebsd.h | 5 ----- src/netbsd.h | 5 ----- src/strace.c | 10 +++++----- 3 files changed, 5 insertions(+), 15 deletions(-) diff --git a/src/freebsd.h b/src/freebsd.h index 011d4f6..b8a446d 100644 --- a/src/freebsd.h +++ b/src/freebsd.h @@ -31,11 +31,6 @@ struct user /* constants */ -# define PTRACE_CONT PT_CONTINUE -# define PTRACE_GETREGS PT_GETREGS -# define PTRACE_SYSCALL PT_SYSCALL -# define PTRACE_TRACEME PT_TRACE_ME - # if defined(__amd64__) # define orig_eax r_rax # elif defined(__i386__) diff --git a/src/netbsd.h b/src/netbsd.h index 340706b..6eb7791 100644 --- a/src/netbsd.h +++ b/src/netbsd.h @@ -34,11 +34,6 @@ struct user /* constants */ -# define PTRACE_CONT PT_CONTINUE -# define PTRACE_GETREGS PT_GETREGS -# define PTRACE_SYSCALL PT_SYSCALL -# define PTRACE_TRACEME PT_TRACE_ME - # if defined(__amd64__) # define _REG32_EAX 11 /* XXX or #define _KERNEL */ # define orig_eax regs[_REG32_EAX] diff --git a/src/strace.c b/src/strace.c index 5821e04..94647c3 100644 --- a/src/strace.c +++ b/src/strace.c @@ -38,7 +38,7 @@ static int _strace(char * argv[]) return _strace_error("fork", 1); if(pid == 0) { - ptrace(PTRACE_TRACEME, -1, NULL, (ptrace_data_t)NULL); + ptrace(PT_TRACE_ME, -1, NULL, (ptrace_data_t)NULL); execvp(argv[0], argv); return _strace_error(argv[0], 1); } @@ -75,19 +75,19 @@ static int _handle(pid_t pid, int status) switch(WSTOPSIG(status)) { case SIGTRAP: - ptrace(PTRACE_GETREGS, pid, NULL, + ptrace(PT_GETREGS, pid, NULL, (ptrace_data_t)&context); if(size >= context.regs.orig_eax) fprintf(stderr, "%s();\n", stracecall[ context.regs.orig_eax - 1]); else fprintf(stderr, "%ld\n", context.regs.orig_eax); - ptrace(PTRACE_SYSCALL, pid, NULL, (ptrace_data_t)NULL); + ptrace(PT_SYSCALL, pid, NULL, (ptrace_data_t)NULL); wait(0); - ptrace(PTRACE_SYSCALL, pid, NULL, (ptrace_data_t)NULL); + ptrace(PT_SYSCALL, pid, NULL, (ptrace_data_t)NULL); break; default: - ptrace(PTRACE_CONT, pid, NULL, WSTOPSIG(status)); + ptrace(PT_CONTINUE, pid, NULL, WSTOPSIG(status)); break; } return 0;