H. Peter Anvin | 1965aae | 2008-10-22 22:26:29 -0700 | [diff] [blame] | 1 | #ifndef _ASM_X86_KGDB_H |
| 2 | #define _ASM_X86_KGDB_H |
Ingo Molnar | 82da3ff | 2008-04-17 20:05:37 +0200 | [diff] [blame] | 3 | |
| 4 | /* |
| 5 | * Copyright (C) 2001-2004 Amit S. Kale |
| 6 | * Copyright (C) 2008 Wind River Systems, Inc. |
| 7 | */ |
| 8 | |
Andy Lutomirski | 35de5b0 | 2016-04-26 12:23:24 -0700 | [diff] [blame] | 9 | #include <asm/ptrace.h> |
| 10 | |
Ingo Molnar | 82da3ff | 2008-04-17 20:05:37 +0200 | [diff] [blame] | 11 | /* |
| 12 | * BUFMAX defines the maximum number of characters in inbound/outbound |
| 13 | * buffers at least NUMREGBYTES*2 are needed for register packets |
| 14 | * Longer buffer is needed to list all threads |
| 15 | */ |
| 16 | #define BUFMAX 1024 |
| 17 | |
| 18 | /* |
| 19 | * Note that this register image is in a different order than |
| 20 | * the register image that Linux produces at interrupt time. |
| 21 | * |
| 22 | * Linux's register image is defined by struct pt_regs in ptrace.h. |
| 23 | * Just why GDB uses a different order is a historical mystery. |
| 24 | */ |
| 25 | #ifdef CONFIG_X86_32 |
| 26 | enum regnames { |
| 27 | GDB_AX, /* 0 */ |
| 28 | GDB_CX, /* 1 */ |
| 29 | GDB_DX, /* 2 */ |
| 30 | GDB_BX, /* 3 */ |
| 31 | GDB_SP, /* 4 */ |
| 32 | GDB_BP, /* 5 */ |
| 33 | GDB_SI, /* 6 */ |
| 34 | GDB_DI, /* 7 */ |
| 35 | GDB_PC, /* 8 also known as eip */ |
| 36 | GDB_PS, /* 9 also known as eflags */ |
| 37 | GDB_CS, /* 10 */ |
| 38 | GDB_SS, /* 11 */ |
| 39 | GDB_DS, /* 12 */ |
| 40 | GDB_ES, /* 13 */ |
| 41 | GDB_FS, /* 14 */ |
| 42 | GDB_GS, /* 15 */ |
| 43 | }; |
Jason Wessel | 12bfa3d | 2010-08-05 09:22:20 -0500 | [diff] [blame] | 44 | #define GDB_ORIG_AX 41 |
| 45 | #define DBG_MAX_REG_NUM 16 |
Jason Wessel | 703a1ed | 2008-09-26 10:36:42 -0500 | [diff] [blame] | 46 | #define NUMREGBYTES ((GDB_GS+1)*4) |
Ingo Molnar | 82da3ff | 2008-04-17 20:05:37 +0200 | [diff] [blame] | 47 | #else /* ! CONFIG_X86_32 */ |
Jason Wessel | 12bfa3d | 2010-08-05 09:22:20 -0500 | [diff] [blame] | 48 | enum regnames { |
Ingo Molnar | 82da3ff | 2008-04-17 20:05:37 +0200 | [diff] [blame] | 49 | GDB_AX, /* 0 */ |
Jason Wessel | 95dbf1d | 2008-09-26 10:36:42 -0500 | [diff] [blame] | 50 | GDB_BX, /* 1 */ |
Ingo Molnar | 82da3ff | 2008-04-17 20:05:37 +0200 | [diff] [blame] | 51 | GDB_CX, /* 2 */ |
Jason Wessel | 95dbf1d | 2008-09-26 10:36:42 -0500 | [diff] [blame] | 52 | GDB_DX, /* 3 */ |
Ingo Molnar | 82da3ff | 2008-04-17 20:05:37 +0200 | [diff] [blame] | 53 | GDB_SI, /* 4 */ |
| 54 | GDB_DI, /* 5 */ |
| 55 | GDB_BP, /* 6 */ |
| 56 | GDB_SP, /* 7 */ |
| 57 | GDB_R8, /* 8 */ |
| 58 | GDB_R9, /* 9 */ |
| 59 | GDB_R10, /* 10 */ |
| 60 | GDB_R11, /* 11 */ |
| 61 | GDB_R12, /* 12 */ |
| 62 | GDB_R13, /* 13 */ |
| 63 | GDB_R14, /* 14 */ |
| 64 | GDB_R15, /* 15 */ |
| 65 | GDB_PC, /* 16 */ |
Jason Wessel | 12bfa3d | 2010-08-05 09:22:20 -0500 | [diff] [blame] | 66 | GDB_PS, /* 17 */ |
| 67 | GDB_CS, /* 18 */ |
| 68 | GDB_SS, /* 19 */ |
Jan Kiszka | 639077f | 2012-03-19 15:16:48 -0500 | [diff] [blame] | 69 | GDB_DS, /* 20 */ |
| 70 | GDB_ES, /* 21 */ |
| 71 | GDB_FS, /* 22 */ |
| 72 | GDB_GS, /* 23 */ |
Ingo Molnar | 82da3ff | 2008-04-17 20:05:37 +0200 | [diff] [blame] | 73 | }; |
Jason Wessel | 12bfa3d | 2010-08-05 09:22:20 -0500 | [diff] [blame] | 74 | #define GDB_ORIG_AX 57 |
Jan Kiszka | 639077f | 2012-03-19 15:16:48 -0500 | [diff] [blame] | 75 | #define DBG_MAX_REG_NUM 24 |
| 76 | /* 17 64 bit regs and 5 32 bit regs */ |
| 77 | #define NUMREGBYTES ((17 * 8) + (5 * 4)) |
Jason Wessel | 12bfa3d | 2010-08-05 09:22:20 -0500 | [diff] [blame] | 78 | #endif /* ! CONFIG_X86_32 */ |
Ingo Molnar | 82da3ff | 2008-04-17 20:05:37 +0200 | [diff] [blame] | 79 | |
| 80 | static inline void arch_kgdb_breakpoint(void) |
| 81 | { |
| 82 | asm(" int $3"); |
| 83 | } |
| 84 | #define BREAK_INSTR_SIZE 1 |
| 85 | #define CACHE_FLUSH_IS_SAFE 1 |
Mike Frysinger | 63ab25e | 2011-05-26 16:25:45 -0700 | [diff] [blame] | 86 | #define GDB_ADJUSTS_BREAK_OFFSET |
Ingo Molnar | 82da3ff | 2008-04-17 20:05:37 +0200 | [diff] [blame] | 87 | |
Jason Wessel | f503b5a | 2010-05-20 21:04:25 -0500 | [diff] [blame] | 88 | extern int kgdb_ll_trap(int cmd, const char *str, |
| 89 | struct pt_regs *regs, long err, int trap, int sig); |
| 90 | |
H. Peter Anvin | 1965aae | 2008-10-22 22:26:29 -0700 | [diff] [blame] | 91 | #endif /* _ASM_X86_KGDB_H */ |