blob: 332f98c9111f41d92def3e02f0771783c8dce100 [file] [log] [blame]
H. Peter Anvin1965aae2008-10-22 22:26:29 -07001#ifndef _ASM_X86_KGDB_H
2#define _ASM_X86_KGDB_H
Ingo Molnar82da3ff2008-04-17 20:05:37 +02003
4/*
5 * Copyright (C) 2001-2004 Amit S. Kale
6 * Copyright (C) 2008 Wind River Systems, Inc.
7 */
8
9/*
10 * BUFMAX defines the maximum number of characters in inbound/outbound
11 * buffers at least NUMREGBYTES*2 are needed for register packets
12 * Longer buffer is needed to list all threads
13 */
14#define BUFMAX 1024
15
16/*
17 * Note that this register image is in a different order than
18 * the register image that Linux produces at interrupt time.
19 *
20 * Linux's register image is defined by struct pt_regs in ptrace.h.
21 * Just why GDB uses a different order is a historical mystery.
22 */
23#ifdef CONFIG_X86_32
24enum regnames {
25 GDB_AX, /* 0 */
26 GDB_CX, /* 1 */
27 GDB_DX, /* 2 */
28 GDB_BX, /* 3 */
29 GDB_SP, /* 4 */
30 GDB_BP, /* 5 */
31 GDB_SI, /* 6 */
32 GDB_DI, /* 7 */
33 GDB_PC, /* 8 also known as eip */
34 GDB_PS, /* 9 also known as eflags */
35 GDB_CS, /* 10 */
36 GDB_SS, /* 11 */
37 GDB_DS, /* 12 */
38 GDB_ES, /* 13 */
39 GDB_FS, /* 14 */
40 GDB_GS, /* 15 */
41};
Jason Wessel12bfa3d2010-08-05 09:22:20 -050042#define GDB_ORIG_AX 41
43#define DBG_MAX_REG_NUM 16
Jason Wessel703a1ed2008-09-26 10:36:42 -050044#define NUMREGBYTES ((GDB_GS+1)*4)
Ingo Molnar82da3ff2008-04-17 20:05:37 +020045#else /* ! CONFIG_X86_32 */
Jason Wessel12bfa3d2010-08-05 09:22:20 -050046enum regnames {
Ingo Molnar82da3ff2008-04-17 20:05:37 +020047 GDB_AX, /* 0 */
Jason Wessel95dbf1d2008-09-26 10:36:42 -050048 GDB_BX, /* 1 */
Ingo Molnar82da3ff2008-04-17 20:05:37 +020049 GDB_CX, /* 2 */
Jason Wessel95dbf1d2008-09-26 10:36:42 -050050 GDB_DX, /* 3 */
Ingo Molnar82da3ff2008-04-17 20:05:37 +020051 GDB_SI, /* 4 */
52 GDB_DI, /* 5 */
53 GDB_BP, /* 6 */
54 GDB_SP, /* 7 */
55 GDB_R8, /* 8 */
56 GDB_R9, /* 9 */
57 GDB_R10, /* 10 */
58 GDB_R11, /* 11 */
59 GDB_R12, /* 12 */
60 GDB_R13, /* 13 */
61 GDB_R14, /* 14 */
62 GDB_R15, /* 15 */
63 GDB_PC, /* 16 */
Jason Wessel12bfa3d2010-08-05 09:22:20 -050064 GDB_PS, /* 17 */
65 GDB_CS, /* 18 */
66 GDB_SS, /* 19 */
Jan Kiszka639077f2012-03-19 15:16:48 -050067 GDB_DS, /* 20 */
68 GDB_ES, /* 21 */
69 GDB_FS, /* 22 */
70 GDB_GS, /* 23 */
Ingo Molnar82da3ff2008-04-17 20:05:37 +020071};
Jason Wessel12bfa3d2010-08-05 09:22:20 -050072#define GDB_ORIG_AX 57
Jan Kiszka639077f2012-03-19 15:16:48 -050073#define DBG_MAX_REG_NUM 24
74/* 17 64 bit regs and 5 32 bit regs */
75#define NUMREGBYTES ((17 * 8) + (5 * 4))
Jason Wessel12bfa3d2010-08-05 09:22:20 -050076#endif /* ! CONFIG_X86_32 */
Ingo Molnar82da3ff2008-04-17 20:05:37 +020077
78static inline void arch_kgdb_breakpoint(void)
79{
80 asm(" int $3");
81}
82#define BREAK_INSTR_SIZE 1
83#define CACHE_FLUSH_IS_SAFE 1
Mike Frysinger63ab25e2011-05-26 16:25:45 -070084#define GDB_ADJUSTS_BREAK_OFFSET
Ingo Molnar82da3ff2008-04-17 20:05:37 +020085
Jason Wesself503b5a2010-05-20 21:04:25 -050086extern int kgdb_ll_trap(int cmd, const char *str,
87 struct pt_regs *regs, long err, int trap, int sig);
88
H. Peter Anvin1965aae2008-10-22 22:26:29 -070089#endif /* _ASM_X86_KGDB_H */