H. Peter Anvin | 1965aae | 2008-10-22 22:26:29 -0700 | [diff] [blame] | 1 | #ifndef _ASM_X86_PTRACE_ABI_H |
| 2 | #define _ASM_X86_PTRACE_ABI_H |
Thomas Gleixner | 686d8c6 | 2007-10-17 18:04:40 +0200 | [diff] [blame] | 3 | |
| 4 | #ifdef __i386__ |
| 5 | |
| 6 | #define EBX 0 |
| 7 | #define ECX 1 |
| 8 | #define EDX 2 |
| 9 | #define ESI 3 |
| 10 | #define EDI 4 |
| 11 | #define EBP 5 |
| 12 | #define EAX 6 |
| 13 | #define DS 7 |
| 14 | #define ES 8 |
| 15 | #define FS 9 |
| 16 | #define GS 10 |
| 17 | #define ORIG_EAX 11 |
| 18 | #define EIP 12 |
| 19 | #define CS 13 |
| 20 | #define EFL 14 |
| 21 | #define UESP 15 |
| 22 | #define SS 16 |
| 23 | #define FRAME_SIZE 17 |
| 24 | |
| 25 | #else /* __i386__ */ |
| 26 | |
| 27 | #if defined(__ASSEMBLY__) || defined(__FRAME_OFFSETS) |
| 28 | #define R15 0 |
| 29 | #define R14 8 |
| 30 | #define R13 16 |
| 31 | #define R12 24 |
| 32 | #define RBP 32 |
| 33 | #define RBX 40 |
| 34 | /* arguments: interrupts/non tracing syscalls only save upto here*/ |
| 35 | #define R11 48 |
| 36 | #define R10 56 |
| 37 | #define R9 64 |
| 38 | #define R8 72 |
| 39 | #define RAX 80 |
| 40 | #define RCX 88 |
| 41 | #define RDX 96 |
| 42 | #define RSI 104 |
| 43 | #define RDI 112 |
| 44 | #define ORIG_RAX 120 /* = ERROR */ |
| 45 | /* end of arguments */ |
| 46 | /* cpu exception frame or undefined in case of fast syscall. */ |
| 47 | #define RIP 128 |
| 48 | #define CS 136 |
| 49 | #define EFLAGS 144 |
| 50 | #define RSP 152 |
| 51 | #define SS 160 |
| 52 | #define ARGOFFSET R11 |
| 53 | #endif /* __ASSEMBLY__ */ |
| 54 | |
| 55 | /* top of stack page */ |
| 56 | #define FRAME_SIZE 168 |
| 57 | |
| 58 | #endif /* !__i386__ */ |
| 59 | |
| 60 | /* Arbitrarily choose the same ptrace numbers as used by the Sparc code. */ |
| 61 | #define PTRACE_GETREGS 12 |
| 62 | #define PTRACE_SETREGS 13 |
| 63 | #define PTRACE_GETFPREGS 14 |
| 64 | #define PTRACE_SETFPREGS 15 |
| 65 | #define PTRACE_GETFPXREGS 18 |
| 66 | #define PTRACE_SETFPXREGS 19 |
| 67 | |
| 68 | #define PTRACE_OLDSETOPTIONS 21 |
| 69 | |
| 70 | /* only useful for access 32bit programs / kernels */ |
| 71 | #define PTRACE_GET_THREAD_AREA 25 |
| 72 | #define PTRACE_SET_THREAD_AREA 26 |
| 73 | |
| 74 | #ifdef __x86_64__ |
| 75 | # define PTRACE_ARCH_PRCTL 30 |
Thomas Gleixner | 686d8c6 | 2007-10-17 18:04:40 +0200 | [diff] [blame] | 76 | #endif |
| 77 | |
Roland McGrath | d4d6715 | 2008-07-09 02:38:07 -0700 | [diff] [blame] | 78 | #define PTRACE_SYSEMU 31 |
| 79 | #define PTRACE_SYSEMU_SINGLESTEP 32 |
| 80 | |
Roland McGrath | 0fa376e | 2008-01-30 13:30:55 +0100 | [diff] [blame] | 81 | #define PTRACE_SINGLEBLOCK 33 /* resume execution until next branch */ |
| 82 | |
Markus Metzger | 93fa763 | 2008-04-08 11:01:58 +0200 | [diff] [blame] | 83 | #ifdef CONFIG_X86_PTRACE_BTS |
Markus Metzger | 87e8407 | 2008-01-30 13:32:54 +0100 | [diff] [blame] | 84 | |
Markus Metzger | 93fa763 | 2008-04-08 11:01:58 +0200 | [diff] [blame] | 85 | #ifndef __ASSEMBLY__ |
Jaswinder Singh Rajput | 420ab35 | 2009-01-30 22:52:16 +0530 | [diff] [blame] | 86 | #include <linux/types.h> |
Markus Metzger | 87e8407 | 2008-01-30 13:32:54 +0100 | [diff] [blame] | 87 | |
Markus Metzger | a95d67f | 2008-01-30 13:31:20 +0100 | [diff] [blame] | 88 | /* configuration/status structure used in PTRACE_BTS_CONFIG and |
| 89 | PTRACE_BTS_STATUS commands. |
| 90 | */ |
| 91 | struct ptrace_bts_config { |
| 92 | /* requested or actual size of BTS buffer in bytes */ |
Dave Anderson | 53c5858 | 2008-02-21 11:45:38 -0500 | [diff] [blame] | 93 | __u32 size; |
Markus Metzger | a95d67f | 2008-01-30 13:31:20 +0100 | [diff] [blame] | 94 | /* bitmask of below flags */ |
Dave Anderson | 53c5858 | 2008-02-21 11:45:38 -0500 | [diff] [blame] | 95 | __u32 flags; |
Markus Metzger | c633459 | 2008-01-30 13:32:04 +0100 | [diff] [blame] | 96 | /* buffer overflow signal */ |
Dave Anderson | 53c5858 | 2008-02-21 11:45:38 -0500 | [diff] [blame] | 97 | __u32 signal; |
Markus Metzger | 87e8407 | 2008-01-30 13:32:54 +0100 | [diff] [blame] | 98 | /* actual size of bts_struct in bytes */ |
Dave Anderson | 53c5858 | 2008-02-21 11:45:38 -0500 | [diff] [blame] | 99 | __u32 bts_size; |
Markus Metzger | a95d67f | 2008-01-30 13:31:20 +0100 | [diff] [blame] | 100 | }; |
Markus Metzger | 93fa763 | 2008-04-08 11:01:58 +0200 | [diff] [blame] | 101 | #endif /* __ASSEMBLY__ */ |
Markus Metzger | eee3af4 | 2008-01-30 13:31:09 +0100 | [diff] [blame] | 102 | |
Markus Metzger | a95d67f | 2008-01-30 13:31:20 +0100 | [diff] [blame] | 103 | #define PTRACE_BTS_O_TRACE 0x1 /* branch trace */ |
| 104 | #define PTRACE_BTS_O_SCHED 0x2 /* scheduling events w/ jiffies */ |
Markus Metzger | c633459 | 2008-01-30 13:32:04 +0100 | [diff] [blame] | 105 | #define PTRACE_BTS_O_SIGNAL 0x4 /* send SIG<signal> on buffer overflow |
Markus Metzger | a95d67f | 2008-01-30 13:31:20 +0100 | [diff] [blame] | 106 | instead of wrapping around */ |
Markus Metzger | 93fa763 | 2008-04-08 11:01:58 +0200 | [diff] [blame] | 107 | #define PTRACE_BTS_O_ALLOC 0x8 /* (re)allocate buffer */ |
Markus Metzger | eee3af4 | 2008-01-30 13:31:09 +0100 | [diff] [blame] | 108 | |
Markus Metzger | a95d67f | 2008-01-30 13:31:20 +0100 | [diff] [blame] | 109 | #define PTRACE_BTS_CONFIG 40 |
| 110 | /* Configure branch trace recording. |
Markus Metzger | cba4b65 | 2008-01-30 13:32:03 +0100 | [diff] [blame] | 111 | ADDR points to a struct ptrace_bts_config. |
| 112 | DATA gives the size of that buffer. |
Markus Metzger | 93fa763 | 2008-04-08 11:01:58 +0200 | [diff] [blame] | 113 | A new buffer is allocated, if requested in the flags. |
| 114 | An overflow signal may only be requested for new buffers. |
Markus Metzger | cba4b65 | 2008-01-30 13:32:03 +0100 | [diff] [blame] | 115 | Returns the number of bytes read. |
Markus Metzger | a95d67f | 2008-01-30 13:31:20 +0100 | [diff] [blame] | 116 | */ |
| 117 | #define PTRACE_BTS_STATUS 41 |
Markus Metzger | cba4b65 | 2008-01-30 13:32:03 +0100 | [diff] [blame] | 118 | /* Return the current configuration in a struct ptrace_bts_config |
| 119 | pointed to by ADDR; DATA gives the size of that buffer. |
| 120 | Returns the number of bytes written. |
Markus Metzger | a95d67f | 2008-01-30 13:31:20 +0100 | [diff] [blame] | 121 | */ |
| 122 | #define PTRACE_BTS_SIZE 42 |
Markus Metzger | 93fa763 | 2008-04-08 11:01:58 +0200 | [diff] [blame] | 123 | /* Return the number of available BTS records for draining. |
Markus Metzger | a95d67f | 2008-01-30 13:31:20 +0100 | [diff] [blame] | 124 | DATA and ADDR are ignored. |
| 125 | */ |
| 126 | #define PTRACE_BTS_GET 43 |
| 127 | /* Get a single BTS record. |
| 128 | DATA defines the index into the BTS array, where 0 is the newest |
| 129 | entry, and higher indices refer to older entries. |
| 130 | ADDR is pointing to struct bts_struct (see asm/ds.h). |
| 131 | */ |
| 132 | #define PTRACE_BTS_CLEAR 44 |
| 133 | /* Clear the BTS buffer. |
| 134 | DATA and ADDR are ignored. |
| 135 | */ |
| 136 | #define PTRACE_BTS_DRAIN 45 |
| 137 | /* Read all available BTS records and clear the buffer. |
Markus Metzger | cba4b65 | 2008-01-30 13:32:03 +0100 | [diff] [blame] | 138 | ADDR points to an array of struct bts_struct. |
| 139 | DATA gives the size of that buffer. |
Markus Metzger | a95d67f | 2008-01-30 13:31:20 +0100 | [diff] [blame] | 140 | BTS records are read from oldest to newest. |
| 141 | Returns number of BTS records drained. |
| 142 | */ |
Markus Metzger | 93fa763 | 2008-04-08 11:01:58 +0200 | [diff] [blame] | 143 | #endif /* CONFIG_X86_PTRACE_BTS */ |
Markus Metzger | eee3af4 | 2008-01-30 13:31:09 +0100 | [diff] [blame] | 144 | |
H. Peter Anvin | 1965aae | 2008-10-22 22:26:29 -0700 | [diff] [blame] | 145 | #endif /* _ASM_X86_PTRACE_ABI_H */ |