Using a more portable API for ptrace() in the first place (from BSD)
This commit is contained in:
parent
a3c645215a
commit
c8ee0357e8
|
@ -31,11 +31,6 @@ struct user
|
||||||
|
|
||||||
|
|
||||||
/* constants */
|
/* 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__)
|
# if defined(__amd64__)
|
||||||
# define orig_eax r_rax
|
# define orig_eax r_rax
|
||||||
# elif defined(__i386__)
|
# elif defined(__i386__)
|
||||||
|
|
|
@ -34,11 +34,6 @@ struct user
|
||||||
|
|
||||||
|
|
||||||
/* constants */
|
/* 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__)
|
# if defined(__amd64__)
|
||||||
# define _REG32_EAX 11 /* XXX or #define _KERNEL */
|
# define _REG32_EAX 11 /* XXX or #define _KERNEL */
|
||||||
# define orig_eax regs[_REG32_EAX]
|
# define orig_eax regs[_REG32_EAX]
|
||||||
|
|
10
src/strace.c
10
src/strace.c
|
@ -38,7 +38,7 @@ static int _strace(char * argv[])
|
||||||
return _strace_error("fork", 1);
|
return _strace_error("fork", 1);
|
||||||
if(pid == 0)
|
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);
|
execvp(argv[0], argv);
|
||||||
return _strace_error(argv[0], 1);
|
return _strace_error(argv[0], 1);
|
||||||
}
|
}
|
||||||
|
@ -75,19 +75,19 @@ static int _handle(pid_t pid, int status)
|
||||||
switch(WSTOPSIG(status))
|
switch(WSTOPSIG(status))
|
||||||
{
|
{
|
||||||
case SIGTRAP:
|
case SIGTRAP:
|
||||||
ptrace(PTRACE_GETREGS, pid, NULL,
|
ptrace(PT_GETREGS, pid, NULL,
|
||||||
(ptrace_data_t)&context);
|
(ptrace_data_t)&context);
|
||||||
if(size >= context.regs.orig_eax)
|
if(size >= context.regs.orig_eax)
|
||||||
fprintf(stderr, "%s();\n", stracecall[
|
fprintf(stderr, "%s();\n", stracecall[
|
||||||
context.regs.orig_eax - 1]);
|
context.regs.orig_eax - 1]);
|
||||||
else
|
else
|
||||||
fprintf(stderr, "%ld\n", context.regs.orig_eax);
|
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);
|
wait(0);
|
||||||
ptrace(PTRACE_SYSCALL, pid, NULL, (ptrace_data_t)NULL);
|
ptrace(PT_SYSCALL, pid, NULL, (ptrace_data_t)NULL);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ptrace(PTRACE_CONT, pid, NULL, WSTOPSIG(status));
|
ptrace(PT_CONTINUE, pid, NULL, WSTOPSIG(status));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user