1 #ifndef _KDBPRIVATE_H
2 #define _KDBPRIVATE_H
3
4
5
6
7
8
9
10
11
12
13
14
15 #include <linux/kgdb.h>
16 #include "../debug_core.h"
17
18
19 #define KDB_CMD_GO (-1001)
20 #define KDB_CMD_CPU (-1002)
21 #define KDB_CMD_SS (-1003)
22 #define KDB_CMD_KGDB (-1005)
23
24
25 #define KDB_DEBUG_FLAG_BP 0x0002
26 #define KDB_DEBUG_FLAG_BB_SUMM 0x0004
27 #define KDB_DEBUG_FLAG_AR 0x0008
28 #define KDB_DEBUG_FLAG_ARA 0x0010
29 #define KDB_DEBUG_FLAG_BB 0x0020
30 #define KDB_DEBUG_FLAG_STATE 0x0040
31 #define KDB_DEBUG_FLAG_MASK 0xffff
32 #define KDB_DEBUG_FLAG_SHIFT 16
33
34 #define KDB_DEBUG(flag) (kdb_flags & \
35 (KDB_DEBUG_FLAG_##flag << KDB_DEBUG_FLAG_SHIFT))
36 #define KDB_DEBUG_STATE(text, value) if (KDB_DEBUG(STATE)) \
37 kdb_print_state(text, value)
38
39 #if BITS_PER_LONG == 32
40
41 #define KDB_PLATFORM_ENV "BYTESPERWORD=4"
42
43 #define kdb_machreg_fmt "0x%lx"
44 #define kdb_machreg_fmt0 "0x%08lx"
45 #define kdb_bfd_vma_fmt "0x%lx"
46 #define kdb_bfd_vma_fmt0 "0x%08lx"
47 #define kdb_elfw_addr_fmt "0x%x"
48 #define kdb_elfw_addr_fmt0 "0x%08x"
49 #define kdb_f_count_fmt "%d"
50
51 #elif BITS_PER_LONG == 64
52
53 #define KDB_PLATFORM_ENV "BYTESPERWORD=8"
54
55 #define kdb_machreg_fmt "0x%lx"
56 #define kdb_machreg_fmt0 "0x%016lx"
57 #define kdb_bfd_vma_fmt "0x%lx"
58 #define kdb_bfd_vma_fmt0 "0x%016lx"
59 #define kdb_elfw_addr_fmt "0x%x"
60 #define kdb_elfw_addr_fmt0 "0x%016x"
61 #define kdb_f_count_fmt "%ld"
62
63 #endif
64
65
66
67
68
69 #define KDB_MAXBPT 16
70
71
72 typedef struct __ksymtab {
73 unsigned long value;
74 const char *mod_name;
75
76 unsigned long mod_start;
77 unsigned long mod_end;
78 const char *sec_name;
79 unsigned long sec_start;
80 unsigned long sec_end;
81 const char *sym_name;
82
83 unsigned long sym_start;
84 unsigned long sym_end;
85 } kdb_symtab_t;
86 extern int kallsyms_symbol_next(char *prefix_name, int flag, int buf_size);
87 extern int kallsyms_symbol_complete(char *prefix_name, int max_len);
88
89
90 extern int kdb_getarea_size(void *, unsigned long, size_t);
91 extern int kdb_putarea_size(unsigned long, void *, size_t);
92
93
94
95
96
97 #define kdb_getarea(x, addr) kdb_getarea_size(&(x), addr, sizeof((x)))
98 #define kdb_putarea(addr, x) kdb_putarea_size(addr, &(x), sizeof((x)))
99
100 extern int kdb_getphysword(unsigned long *word,
101 unsigned long addr, size_t size);
102 extern int kdb_getword(unsigned long *, unsigned long, size_t);
103 extern int kdb_putword(unsigned long, unsigned long, size_t);
104
105 extern int kdbgetularg(const char *, unsigned long *);
106 extern int kdbgetu64arg(const char *, u64 *);
107 extern char *kdbgetenv(const char *);
108 extern int kdbgetaddrarg(int, const char **, int*, unsigned long *,
109 long *, char **);
110 extern int kdbgetsymval(const char *, kdb_symtab_t *);
111 extern int kdbnearsym(unsigned long, kdb_symtab_t *);
112 extern void kdbnearsym_cleanup(void);
113 extern char *kdb_strdup(const char *str, gfp_t type);
114 extern void kdb_symbol_print(unsigned long, const kdb_symtab_t *, unsigned int);
115
116
117 extern void kdb_print_state(const char *, int);
118
119 extern int kdb_state;
120 #define KDB_STATE_KDB 0x00000001
121 #define KDB_STATE_LEAVING 0x00000002
122 #define KDB_STATE_CMD 0x00000004
123 #define KDB_STATE_KDB_CONTROL 0x00000008
124
125 #define KDB_STATE_HOLD_CPU 0x00000010
126 #define KDB_STATE_DOING_SS 0x00000020
127 #define KDB_STATE_SSBPT 0x00000080
128
129
130 #define KDB_STATE_REENTRY 0x00000100
131 #define KDB_STATE_SUPPRESS 0x00000200
132 #define KDB_STATE_PAGER 0x00000400
133 #define KDB_STATE_GO_SWITCH 0x00000800
134
135 #define KDB_STATE_WAIT_IPI 0x00002000
136 #define KDB_STATE_RECURSE 0x00004000
137 #define KDB_STATE_IP_ADJUSTED 0x00008000
138
139 #define KDB_STATE_GO1 0x00010000
140 #define KDB_STATE_KEYBOARD 0x00020000
141
142 #define KDB_STATE_KEXEC 0x00040000
143 #define KDB_STATE_DOING_KGDB 0x00080000
144 #define KDB_STATE_KGDB_TRANS 0x00200000
145 #define KDB_STATE_ARCH 0xff000000
146
147
148 #define KDB_STATE(flag) (kdb_state & KDB_STATE_##flag)
149 #define KDB_STATE_SET(flag) ((void)(kdb_state |= KDB_STATE_##flag))
150 #define KDB_STATE_CLEAR(flag) ((void)(kdb_state &= ~KDB_STATE_##flag))
151
152 extern int kdb_nextline;
153
154 typedef struct _kdb_bp {
155 unsigned long bp_addr;
156 unsigned int bp_free:1;
157 unsigned int bp_enabled:1;
158 unsigned int bp_type:4;
159 unsigned int bp_installed:1;
160 unsigned int bp_delay:1;
161 unsigned int bp_delayed:1;
162 unsigned int bph_length;
163 } kdb_bp_t;
164
165 #ifdef CONFIG_KGDB_KDB
166 extern kdb_bp_t kdb_breakpoints[];
167
168
169 typedef struct _kdbtab {
170 char *cmd_name;
171 kdb_func_t cmd_func;
172 char *cmd_usage;
173 char *cmd_help;
174 short cmd_minlen;
175
176 kdb_cmdflags_t cmd_flags;
177 } kdbtab_t;
178
179 extern int kdb_bt(int, const char **);
180
181
182 extern void kdb_initbptab(void);
183 extern void kdb_bp_install(struct pt_regs *);
184 extern void kdb_bp_remove(void);
185
186 typedef enum {
187 KDB_DB_BPT,
188 KDB_DB_SS,
189 KDB_DB_SSBPT,
190 KDB_DB_NOBPT
191 } kdb_dbtrap_t;
192
193 extern int kdb_main_loop(kdb_reason_t, kdb_reason_t,
194 int, kdb_dbtrap_t, struct pt_regs *);
195
196
197 extern int kdb_grepping_flag;
198 #define KDB_GREPPING_FLAG_SEARCH 0x8000
199 extern char kdb_grep_string[];
200 #define KDB_GREP_STRLEN 256
201 extern int kdb_grep_leading;
202 extern int kdb_grep_trailing;
203 extern char *kdb_cmds[];
204 extern unsigned long kdb_task_state_string(const char *);
205 extern char kdb_task_state_char (const struct task_struct *);
206 extern unsigned long kdb_task_state(const struct task_struct *p,
207 unsigned long mask);
208 extern void kdb_ps_suppressed(void);
209 extern void kdb_ps1(const struct task_struct *p);
210 extern void kdb_print_nameval(const char *name, unsigned long val);
211 extern void kdb_send_sig(struct task_struct *p, int sig);
212 extern void kdb_meminfo_proc_show(void);
213 extern char *kdb_getstr(char *, size_t, const char *);
214 extern void kdb_gdb_state_pass(char *buf);
215
216
217 #define KDB_SP_SPACEB 0x0001
218 #define KDB_SP_SPACEA 0x0002
219 #define KDB_SP_PAREN 0x0004
220 #define KDB_SP_VALUE 0x0008
221 #define KDB_SP_SYMSIZE 0x0010
222 #define KDB_SP_NEWLINE 0x0020
223 #define KDB_SP_DEFAULT (KDB_SP_VALUE|KDB_SP_PAREN)
224
225 #define KDB_TSK(cpu) kgdb_info[cpu].task
226 #define KDB_TSKREGS(cpu) kgdb_info[cpu].debuggerinfo
227
228 extern struct task_struct *kdb_curr_task(int);
229
230 #define kdb_task_has_cpu(p) (task_curr(p))
231
232
233 #define kdb_do_each_thread(g, p) do_each_thread(g, p)
234 #define kdb_while_each_thread(g, p) while_each_thread(g, p)
235
236 #define GFP_KDB (in_interrupt() ? GFP_ATOMIC : GFP_KERNEL)
237
238 extern void *debug_kmalloc(size_t size, gfp_t flags);
239 extern void debug_kfree(void *);
240 extern void debug_kusage(void);
241
242 extern void kdb_set_current_task(struct task_struct *);
243 extern struct task_struct *kdb_current_task;
244
245 #ifdef CONFIG_KDB_KEYBOARD
246 extern void kdb_kbd_cleanup_state(void);
247 #else
248 #define kdb_kbd_cleanup_state()
249 #endif
250
251 #ifdef CONFIG_MODULES
252 extern struct list_head *kdb_modules;
253 #endif
254
255 extern char kdb_prompt_str[];
256
257 #define KDB_WORD_SIZE ((int)sizeof(unsigned long))
258
259 #endif
260 #endif