2005-05-06 07:15:23 +08:00
|
|
|
#include <stdio.h>
|
2007-05-07 05:51:48 +08:00
|
|
|
#include <stddef.h>
|
2005-05-06 07:15:23 +08:00
|
|
|
#include <signal.h>
|
2007-05-07 05:51:48 +08:00
|
|
|
#include <sys/poll.h>
|
2007-10-16 16:27:14 +08:00
|
|
|
#include <sys/user.h>
|
2007-05-07 05:51:48 +08:00
|
|
|
#include <sys/mman.h>
|
2005-05-06 07:15:23 +08:00
|
|
|
#include <asm/ptrace.h>
|
|
|
|
|
|
|
|
#define DEFINE(sym, val) \
|
2006-03-27 17:14:30 +08:00
|
|
|
asm volatile("\n->" #sym " %0 " #val : : "i" (val))
|
2005-05-06 07:15:23 +08:00
|
|
|
|
2005-09-29 05:27:23 +08:00
|
|
|
#define DEFINE_LONGS(sym, val) \
|
2006-03-27 17:14:30 +08:00
|
|
|
asm volatile("\n->" #sym " %0 " #val : : "i" (val/sizeof(unsigned long)))
|
2005-09-29 05:27:23 +08:00
|
|
|
|
2005-05-06 07:15:23 +08:00
|
|
|
#define OFFSET(sym, str, mem) \
|
|
|
|
DEFINE(sym, offsetof(struct str, mem));
|
|
|
|
|
|
|
|
void foo(void)
|
|
|
|
{
|
2005-09-29 05:27:23 +08:00
|
|
|
OFFSET(HOST_SC_TRAPNO, sigcontext, trapno);
|
|
|
|
OFFSET(HOST_SC_ERR, sigcontext, err);
|
|
|
|
OFFSET(HOST_SC_CR2, sigcontext, cr2);
|
2005-05-06 07:15:23 +08:00
|
|
|
|
2007-10-16 16:27:14 +08:00
|
|
|
DEFINE_LONGS(HOST_FP_SIZE, sizeof(struct user_fpregs_struct));
|
|
|
|
DEFINE_LONGS(HOST_XFP_SIZE, sizeof(struct user_fpxregs_struct));
|
2005-05-06 07:15:23 +08:00
|
|
|
|
|
|
|
DEFINE(HOST_IP, EIP);
|
|
|
|
DEFINE(HOST_SP, UESP);
|
|
|
|
DEFINE(HOST_EFLAGS, EFL);
|
|
|
|
DEFINE(HOST_EAX, EAX);
|
|
|
|
DEFINE(HOST_EBX, EBX);
|
|
|
|
DEFINE(HOST_ECX, ECX);
|
|
|
|
DEFINE(HOST_EDX, EDX);
|
|
|
|
DEFINE(HOST_ESI, ESI);
|
|
|
|
DEFINE(HOST_EDI, EDI);
|
|
|
|
DEFINE(HOST_EBP, EBP);
|
|
|
|
DEFINE(HOST_CS, CS);
|
|
|
|
DEFINE(HOST_SS, SS);
|
|
|
|
DEFINE(HOST_DS, DS);
|
|
|
|
DEFINE(HOST_FS, FS);
|
|
|
|
DEFINE(HOST_ES, ES);
|
|
|
|
DEFINE(HOST_GS, GS);
|
2005-09-29 05:27:23 +08:00
|
|
|
DEFINE(UM_FRAME_SIZE, sizeof(struct user_regs_struct));
|
2006-03-27 17:14:30 +08:00
|
|
|
|
|
|
|
/* XXX Duplicated between i386 and x86_64 */
|
|
|
|
DEFINE(UM_POLLIN, POLLIN);
|
|
|
|
DEFINE(UM_POLLPRI, POLLPRI);
|
|
|
|
DEFINE(UM_POLLOUT, POLLOUT);
|
2007-05-07 05:51:48 +08:00
|
|
|
|
|
|
|
DEFINE(UM_PROT_READ, PROT_READ);
|
|
|
|
DEFINE(UM_PROT_WRITE, PROT_WRITE);
|
|
|
|
DEFINE(UM_PROT_EXEC, PROT_EXEC);
|
2005-05-06 07:15:23 +08:00
|
|
|
}
|