Al Viro | 8d0b9dc | 2005-05-05 16:15:23 -0700 | [diff] [blame] | 1 | #include <stdio.h> |
| 2 | #include <stddef.h> |
| 3 | #include <signal.h> |
Jeff Dike | 63ae2a9 | 2006-03-27 01:14:30 -0800 | [diff] [blame] | 4 | #include <sys/poll.h> |
Jeff Dike | 16dd07b | 2007-05-06 14:51:48 -0700 | [diff] [blame] | 5 | #include <sys/mman.h> |
Jeff Dike | 189872f | 2007-10-16 01:27:14 -0700 | [diff] [blame] | 6 | #include <sys/user.h> |
Al Viro | 8d0b9dc | 2005-05-05 16:15:23 -0700 | [diff] [blame] | 7 | #define __FRAME_OFFSETS |
| 8 | #include <asm/ptrace.h> |
Jeff Dike | ba9950c | 2005-05-20 13:59:07 -0700 | [diff] [blame] | 9 | #include <asm/types.h> |
Al Viro | 8d0b9dc | 2005-05-05 16:15:23 -0700 | [diff] [blame] | 10 | |
| 11 | #define DEFINE(sym, val) \ |
| 12 | asm volatile("\n->" #sym " %0 " #val : : "i" (val)) |
| 13 | |
Al Viro | ecba97d | 2005-09-28 22:27:23 +0100 | [diff] [blame] | 14 | #define DEFINE_LONGS(sym, val) \ |
| 15 | asm volatile("\n->" #sym " %0 " #val : : "i" (val/sizeof(unsigned long))) |
| 16 | |
Al Viro | 8d0b9dc | 2005-05-05 16:15:23 -0700 | [diff] [blame] | 17 | #define OFFSET(sym, str, mem) \ |
| 18 | DEFINE(sym, offsetof(struct str, mem)); |
| 19 | |
| 20 | void foo(void) |
| 21 | { |
Al Viro | ecba97d | 2005-09-28 22:27:23 +0100 | [diff] [blame] | 22 | OFFSET(HOST_SC_CR2, sigcontext, cr2); |
| 23 | OFFSET(HOST_SC_ERR, sigcontext, err); |
| 24 | OFFSET(HOST_SC_TRAPNO, sigcontext, trapno); |
Al Viro | 8d0b9dc | 2005-05-05 16:15:23 -0700 | [diff] [blame] | 25 | |
Jeff Dike | e2216fe | 2006-02-07 12:58:43 -0800 | [diff] [blame] | 26 | DEFINE(HOST_FP_SIZE, sizeof(struct _fpstate) / sizeof(unsigned long)); |
Al Viro | ecba97d | 2005-09-28 22:27:23 +0100 | [diff] [blame] | 27 | DEFINE(HOST_XFP_SIZE, 0); |
| 28 | DEFINE_LONGS(HOST_RBX, RBX); |
| 29 | DEFINE_LONGS(HOST_RCX, RCX); |
| 30 | DEFINE_LONGS(HOST_RDI, RDI); |
| 31 | DEFINE_LONGS(HOST_RSI, RSI); |
| 32 | DEFINE_LONGS(HOST_RDX, RDX); |
| 33 | DEFINE_LONGS(HOST_RBP, RBP); |
| 34 | DEFINE_LONGS(HOST_RAX, RAX); |
| 35 | DEFINE_LONGS(HOST_R8, R8); |
| 36 | DEFINE_LONGS(HOST_R9, R9); |
| 37 | DEFINE_LONGS(HOST_R10, R10); |
| 38 | DEFINE_LONGS(HOST_R11, R11); |
| 39 | DEFINE_LONGS(HOST_R12, R12); |
| 40 | DEFINE_LONGS(HOST_R13, R13); |
| 41 | DEFINE_LONGS(HOST_R14, R14); |
| 42 | DEFINE_LONGS(HOST_R15, R15); |
| 43 | DEFINE_LONGS(HOST_ORIG_RAX, ORIG_RAX); |
| 44 | DEFINE_LONGS(HOST_CS, CS); |
| 45 | DEFINE_LONGS(HOST_SS, SS); |
| 46 | DEFINE_LONGS(HOST_EFLAGS, EFLAGS); |
Al Viro | 8d0b9dc | 2005-05-05 16:15:23 -0700 | [diff] [blame] | 47 | #if 0 |
Al Viro | ecba97d | 2005-09-28 22:27:23 +0100 | [diff] [blame] | 48 | DEFINE_LONGS(HOST_FS, FS); |
| 49 | DEFINE_LONGS(HOST_GS, GS); |
| 50 | DEFINE_LONGS(HOST_DS, DS); |
| 51 | DEFINE_LONGS(HOST_ES, ES); |
Al Viro | 8d0b9dc | 2005-05-05 16:15:23 -0700 | [diff] [blame] | 52 | #endif |
| 53 | |
Al Viro | ecba97d | 2005-09-28 22:27:23 +0100 | [diff] [blame] | 54 | DEFINE_LONGS(HOST_IP, RIP); |
| 55 | DEFINE_LONGS(HOST_SP, RSP); |
| 56 | DEFINE(UM_FRAME_SIZE, sizeof(struct user_regs_struct)); |
Jeff Dike | 63ae2a9 | 2006-03-27 01:14:30 -0800 | [diff] [blame] | 57 | |
| 58 | /* XXX Duplicated between i386 and x86_64 */ |
| 59 | DEFINE(UM_POLLIN, POLLIN); |
| 60 | DEFINE(UM_POLLPRI, POLLPRI); |
| 61 | DEFINE(UM_POLLOUT, POLLOUT); |
Jeff Dike | 16dd07b | 2007-05-06 14:51:48 -0700 | [diff] [blame] | 62 | |
| 63 | DEFINE(UM_PROT_READ, PROT_READ); |
| 64 | DEFINE(UM_PROT_WRITE, PROT_WRITE); |
| 65 | DEFINE(UM_PROT_EXEC, PROT_EXEC); |
Al Viro | 8d0b9dc | 2005-05-05 16:15:23 -0700 | [diff] [blame] | 66 | } |