blob: 0d5fd764c21fa13dd2c3d7eb323edaac387103e9 [file] [log] [blame]
Al Viro8d0b9dc2005-05-05 16:15:23 -07001#include <stdio.h>
2#include <stddef.h>
3#include <signal.h>
Jeff Dike63ae2a92006-03-27 01:14:30 -08004#include <sys/poll.h>
Jeff Dike16dd07b2007-05-06 14:51:48 -07005#include <sys/mman.h>
Al Viro8d0b9dc2005-05-05 16:15:23 -07006#define __FRAME_OFFSETS
7#include <asm/ptrace.h>
Jeff Dikeba9950c2005-05-20 13:59:07 -07008#include <asm/types.h>
9/* For some reason, x86_64 defines u64 and u32 only in <pci/types.h>, which I
10 * refuse to include here, even though they're used throughout the headers.
11 * These are used in asm/user.h, and that include can't be avoided because of
12 * the sizeof(struct user_regs_struct) below.
13 */
14typedef __u64 u64;
15typedef __u32 u32;
Al Viro8d0b9dc2005-05-05 16:15:23 -070016#include <asm/user.h>
17
18#define DEFINE(sym, val) \
19 asm volatile("\n->" #sym " %0 " #val : : "i" (val))
20
Al Viroecba97d2005-09-28 22:27:23 +010021#define DEFINE_LONGS(sym, val) \
22 asm volatile("\n->" #sym " %0 " #val : : "i" (val/sizeof(unsigned long)))
23
Al Viro8d0b9dc2005-05-05 16:15:23 -070024#define OFFSET(sym, str, mem) \
25 DEFINE(sym, offsetof(struct str, mem));
26
27void foo(void)
28{
Al Viroecba97d2005-09-28 22:27:23 +010029 OFFSET(HOST_SC_RBX, sigcontext, rbx);
30 OFFSET(HOST_SC_RCX, sigcontext, rcx);
31 OFFSET(HOST_SC_RDX, sigcontext, rdx);
32 OFFSET(HOST_SC_RSI, sigcontext, rsi);
33 OFFSET(HOST_SC_RDI, sigcontext, rdi);
34 OFFSET(HOST_SC_RBP, sigcontext, rbp);
35 OFFSET(HOST_SC_RAX, sigcontext, rax);
36 OFFSET(HOST_SC_R8, sigcontext, r8);
37 OFFSET(HOST_SC_R9, sigcontext, r9);
38 OFFSET(HOST_SC_R10, sigcontext, r10);
39 OFFSET(HOST_SC_R11, sigcontext, r11);
40 OFFSET(HOST_SC_R12, sigcontext, r12);
41 OFFSET(HOST_SC_R13, sigcontext, r13);
42 OFFSET(HOST_SC_R14, sigcontext, r14);
43 OFFSET(HOST_SC_R15, sigcontext, r15);
44 OFFSET(HOST_SC_IP, sigcontext, rip);
45 OFFSET(HOST_SC_SP, sigcontext, rsp);
46 OFFSET(HOST_SC_CR2, sigcontext, cr2);
47 OFFSET(HOST_SC_ERR, sigcontext, err);
48 OFFSET(HOST_SC_TRAPNO, sigcontext, trapno);
49 OFFSET(HOST_SC_CS, sigcontext, cs);
50 OFFSET(HOST_SC_FS, sigcontext, fs);
51 OFFSET(HOST_SC_GS, sigcontext, gs);
52 OFFSET(HOST_SC_EFLAGS, sigcontext, eflags);
53 OFFSET(HOST_SC_SIGMASK, sigcontext, oldmask);
Al Viro8d0b9dc2005-05-05 16:15:23 -070054#if 0
Al Viroecba97d2005-09-28 22:27:23 +010055 OFFSET(HOST_SC_ORIG_RAX, sigcontext, orig_rax);
56 OFFSET(HOST_SC_DS, sigcontext, ds);
57 OFFSET(HOST_SC_ES, sigcontext, es);
58 OFFSET(HOST_SC_SS, sigcontext, ss);
Al Viro8d0b9dc2005-05-05 16:15:23 -070059#endif
60
Jeff Dikee2216fe2006-02-07 12:58:43 -080061 DEFINE(HOST_FP_SIZE, sizeof(struct _fpstate) / sizeof(unsigned long));
Al Viroecba97d2005-09-28 22:27:23 +010062 DEFINE(HOST_XFP_SIZE, 0);
63 DEFINE_LONGS(HOST_RBX, RBX);
64 DEFINE_LONGS(HOST_RCX, RCX);
65 DEFINE_LONGS(HOST_RDI, RDI);
66 DEFINE_LONGS(HOST_RSI, RSI);
67 DEFINE_LONGS(HOST_RDX, RDX);
68 DEFINE_LONGS(HOST_RBP, RBP);
69 DEFINE_LONGS(HOST_RAX, RAX);
70 DEFINE_LONGS(HOST_R8, R8);
71 DEFINE_LONGS(HOST_R9, R9);
72 DEFINE_LONGS(HOST_R10, R10);
73 DEFINE_LONGS(HOST_R11, R11);
74 DEFINE_LONGS(HOST_R12, R12);
75 DEFINE_LONGS(HOST_R13, R13);
76 DEFINE_LONGS(HOST_R14, R14);
77 DEFINE_LONGS(HOST_R15, R15);
78 DEFINE_LONGS(HOST_ORIG_RAX, ORIG_RAX);
79 DEFINE_LONGS(HOST_CS, CS);
80 DEFINE_LONGS(HOST_SS, SS);
81 DEFINE_LONGS(HOST_EFLAGS, EFLAGS);
Al Viro8d0b9dc2005-05-05 16:15:23 -070082#if 0
Al Viroecba97d2005-09-28 22:27:23 +010083 DEFINE_LONGS(HOST_FS, FS);
84 DEFINE_LONGS(HOST_GS, GS);
85 DEFINE_LONGS(HOST_DS, DS);
86 DEFINE_LONGS(HOST_ES, ES);
Al Viro8d0b9dc2005-05-05 16:15:23 -070087#endif
88
Al Viroecba97d2005-09-28 22:27:23 +010089 DEFINE_LONGS(HOST_IP, RIP);
90 DEFINE_LONGS(HOST_SP, RSP);
91 DEFINE(UM_FRAME_SIZE, sizeof(struct user_regs_struct));
Jeff Dike63ae2a92006-03-27 01:14:30 -080092
93 /* XXX Duplicated between i386 and x86_64 */
94 DEFINE(UM_POLLIN, POLLIN);
95 DEFINE(UM_POLLPRI, POLLPRI);
96 DEFINE(UM_POLLOUT, POLLOUT);
Jeff Dike16dd07b2007-05-06 14:51:48 -070097
98 DEFINE(UM_PROT_READ, PROT_READ);
99 DEFINE(UM_PROT_WRITE, PROT_WRITE);
100 DEFINE(UM_PROT_EXEC, PROT_EXEC);
Al Viro8d0b9dc2005-05-05 16:15:23 -0700101}