Using a more portable API for ptrace() in the first place (from BSD)

This commit is contained in:
Pierre Pronchery 2012-11-04 00:47:03 +01:00
parent a3c645215a
commit c8ee0357e8
3 changed files with 5 additions and 15 deletions

View File

@ -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__)

View File

@ -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]

View File

@ -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;