Debugging
This commit is contained in:
parent
17a285a2e0
commit
1ea24ab2ac
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
#ifdef __FreeBSD__
|
#ifdef __FreeBSD__
|
||||||
/* variables */
|
/* variables */
|
||||||
char const * stracecall[] =
|
char const * stracecall[SYS_getpid + 1] =
|
||||||
{
|
{
|
||||||
NULL,
|
NULL,
|
||||||
"exit",
|
"exit",
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
|
|
||||||
/* types */
|
/* types */
|
||||||
typedef long ptrace_data_t; /* XXX really is int */
|
typedef int ptrace_data_t;
|
||||||
struct user
|
struct user
|
||||||
{
|
{
|
||||||
struct reg regs;
|
struct reg regs;
|
||||||
|
@ -33,6 +33,9 @@ struct user
|
||||||
/* constants */
|
/* constants */
|
||||||
# if defined(__amd64__)
|
# if defined(__amd64__)
|
||||||
# define orig_eax r_rax
|
# define orig_eax r_rax
|
||||||
|
# define orig_ebx r_rbx
|
||||||
|
# define orig_ecx r_rcx
|
||||||
|
# define orig_edx r_rdx
|
||||||
# elif defined(__i386__)
|
# elif defined(__i386__)
|
||||||
# define orig_eax r_eax
|
# define orig_eax r_eax
|
||||||
# endif
|
# endif
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
#ifdef __NetBSD__
|
#ifdef __NetBSD__
|
||||||
/* variables */
|
/* variables */
|
||||||
char const * stracecall[] =
|
char const * stracecall[SYS_getpid + 1] =
|
||||||
{
|
{
|
||||||
"syscall",
|
"syscall",
|
||||||
"exit",
|
"exit",
|
||||||
|
@ -41,7 +41,7 @@ char const * stracecall[] =
|
||||||
"chmod",
|
"chmod",
|
||||||
"chown",
|
"chown",
|
||||||
"break",
|
"break",
|
||||||
NULL,
|
"oldgetfsstat",
|
||||||
"oldlseek",
|
"oldlseek",
|
||||||
"getpid"
|
"getpid"
|
||||||
};
|
};
|
||||||
|
|
|
@ -36,6 +36,9 @@ struct user
|
||||||
/* constants */
|
/* constants */
|
||||||
# if defined(__amd64__)
|
# if defined(__amd64__)
|
||||||
# define orig_rax regs[_REG_RAX]
|
# define orig_rax regs[_REG_RAX]
|
||||||
|
# define orig_rbx regs[_REG_RBX]
|
||||||
|
# define orig_rcx regs[_REG_RCX]
|
||||||
|
# define orig_rdx regs[_REG_RDX]
|
||||||
# elif defined(__i386__)
|
# elif defined(__i386__)
|
||||||
# define orig_eax r_eax
|
# define orig_eax r_eax
|
||||||
# endif
|
# endif
|
||||||
|
|
|
@ -119,7 +119,7 @@ static void _handle_trap_before(pid_t pid)
|
||||||
struct user context;
|
struct user context;
|
||||||
int size = sizeof(stracecall) / sizeof(*stracecall);
|
int size = sizeof(stracecall) / sizeof(*stracecall);
|
||||||
|
|
||||||
ptrace(PT_GETREGS, pid, &context, 0);
|
ptrace(PT_GETREGS, pid, &context.regs, 0);
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
_strace_regs_print(&context.regs);
|
_strace_regs_print(&context.regs);
|
||||||
#endif
|
#endif
|
||||||
|
@ -140,7 +140,7 @@ static void _handle_trap_after(pid_t pid)
|
||||||
{
|
{
|
||||||
struct user context;
|
struct user context;
|
||||||
|
|
||||||
ptrace(PT_GETREGS, pid, &context, 0);
|
ptrace(PT_GETREGS, pid, &context.regs, 0);
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
_strace_regs_print(&context.regs);
|
_strace_regs_print(&context.regs);
|
||||||
#endif
|
#endif
|
||||||
|
@ -158,6 +158,9 @@ static void _strace_regs_print(struct reg * regs)
|
||||||
{
|
{
|
||||||
#if defined(__amd64__)
|
#if defined(__amd64__)
|
||||||
fprintf(stderr, "rax: 0x%016lx\n", regs->orig_rax);
|
fprintf(stderr, "rax: 0x%016lx\n", regs->orig_rax);
|
||||||
|
fprintf(stderr, "rcx: 0x%016lx\n", regs->orig_rcx);
|
||||||
|
fprintf(stderr, "rdx: 0x%016lx\n", regs->orig_rdx);
|
||||||
|
fprintf(stderr, "rbx: 0x%016lx\n", regs->orig_rbx);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue
Block a user