2005-05-06 07:15:23 +08:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <signal.h>
|
|
|
|
#include <asm/ptrace.h>
|
|
|
|
#include <asm/user.h>
|
2006-12-07 12:34:52 +08:00
|
|
|
#include <stddef.h>
|
2006-03-27 17:14:30 +08:00
|
|
|
#include <sys/poll.h>
|
2005-05-06 07:15:23 +08:00
|
|
|
|
|
|
|
#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_IP, sigcontext, eip);
|
|
|
|
OFFSET(HOST_SC_SP, sigcontext, esp);
|
|
|
|
OFFSET(HOST_SC_FS, sigcontext, fs);
|
|
|
|
OFFSET(HOST_SC_GS, sigcontext, gs);
|
|
|
|
OFFSET(HOST_SC_DS, sigcontext, ds);
|
|
|
|
OFFSET(HOST_SC_ES, sigcontext, es);
|
|
|
|
OFFSET(HOST_SC_SS, sigcontext, ss);
|
|
|
|
OFFSET(HOST_SC_CS, sigcontext, cs);
|
|
|
|
OFFSET(HOST_SC_EFLAGS, sigcontext, eflags);
|
|
|
|
OFFSET(HOST_SC_EAX, sigcontext, eax);
|
|
|
|
OFFSET(HOST_SC_EBX, sigcontext, ebx);
|
|
|
|
OFFSET(HOST_SC_ECX, sigcontext, ecx);
|
|
|
|
OFFSET(HOST_SC_EDX, sigcontext, edx);
|
|
|
|
OFFSET(HOST_SC_EDI, sigcontext, edi);
|
|
|
|
OFFSET(HOST_SC_ESI, sigcontext, esi);
|
|
|
|
OFFSET(HOST_SC_EBP, sigcontext, ebp);
|
|
|
|
OFFSET(HOST_SC_TRAPNO, sigcontext, trapno);
|
|
|
|
OFFSET(HOST_SC_ERR, sigcontext, err);
|
|
|
|
OFFSET(HOST_SC_CR2, sigcontext, cr2);
|
|
|
|
OFFSET(HOST_SC_FPSTATE, sigcontext, fpstate);
|
|
|
|
OFFSET(HOST_SC_SIGMASK, sigcontext, oldmask);
|
|
|
|
OFFSET(HOST_SC_FP_CW, _fpstate, cw);
|
|
|
|
OFFSET(HOST_SC_FP_SW, _fpstate, sw);
|
|
|
|
OFFSET(HOST_SC_FP_TAG, _fpstate, tag);
|
|
|
|
OFFSET(HOST_SC_FP_IPOFF, _fpstate, ipoff);
|
|
|
|
OFFSET(HOST_SC_FP_CSSEL, _fpstate, cssel);
|
|
|
|
OFFSET(HOST_SC_FP_DATAOFF, _fpstate, dataoff);
|
|
|
|
OFFSET(HOST_SC_FP_DATASEL, _fpstate, datasel);
|
|
|
|
OFFSET(HOST_SC_FP_ST, _fpstate, _st);
|
|
|
|
OFFSET(HOST_SC_FXSR_ENV, _fpstate, _fxsr_env);
|
2005-05-06 07:15:23 +08:00
|
|
|
|
2005-10-05 02:53:49 +08:00
|
|
|
DEFINE(HOST_FRAME_SIZE, FRAME_SIZE);
|
2005-09-29 05:27:23 +08:00
|
|
|
DEFINE_LONGS(HOST_FP_SIZE, sizeof(struct user_i387_struct));
|
|
|
|
DEFINE_LONGS(HOST_XFP_SIZE, sizeof(struct user_fxsr_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);
|
2005-05-06 07:15:23 +08:00
|
|
|
}
|