diff options
Diffstat (limited to 'kernel/debug/kdb/kdb_private.h')
-rw-r--r-- | kernel/debug/kdb/kdb_private.h | 300 |
1 files changed, 300 insertions, 0 deletions
diff --git a/kernel/debug/kdb/kdb_private.h b/kernel/debug/kdb/kdb_private.h new file mode 100644 index 000000000000..97d3ba69775d --- /dev/null +++ b/kernel/debug/kdb/kdb_private.h | |||
@@ -0,0 +1,300 @@ | |||
1 | #ifndef _KDBPRIVATE_H | ||
2 | #define _KDBPRIVATE_H | ||
3 | |||
4 | /* | ||
5 | * Kernel Debugger Architecture Independent Private Headers | ||
6 | * | ||
7 | * This file is subject to the terms and conditions of the GNU General Public | ||
8 | * License. See the file "COPYING" in the main directory of this archive | ||
9 | * for more details. | ||
10 | * | ||
11 | * Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved. | ||
12 | * Copyright (c) 2009 Wind River Systems, Inc. All Rights Reserved. | ||
13 | */ | ||
14 | |||
15 | #include <linux/kgdb.h> | ||
16 | #include "../debug_core.h" | ||
17 | |||
18 | /* Kernel Debugger Error codes. Must not overlap with command codes. */ | ||
19 | #define KDB_NOTFOUND (-1) | ||
20 | #define KDB_ARGCOUNT (-2) | ||
21 | #define KDB_BADWIDTH (-3) | ||
22 | #define KDB_BADRADIX (-4) | ||
23 | #define KDB_NOTENV (-5) | ||
24 | #define KDB_NOENVVALUE (-6) | ||
25 | #define KDB_NOTIMP (-7) | ||
26 | #define KDB_ENVFULL (-8) | ||
27 | #define KDB_ENVBUFFULL (-9) | ||
28 | #define KDB_TOOMANYBPT (-10) | ||
29 | #define KDB_TOOMANYDBREGS (-11) | ||
30 | #define KDB_DUPBPT (-12) | ||
31 | #define KDB_BPTNOTFOUND (-13) | ||
32 | #define KDB_BADMODE (-14) | ||
33 | #define KDB_BADINT (-15) | ||
34 | #define KDB_INVADDRFMT (-16) | ||
35 | #define KDB_BADREG (-17) | ||
36 | #define KDB_BADCPUNUM (-18) | ||
37 | #define KDB_BADLENGTH (-19) | ||
38 | #define KDB_NOBP (-20) | ||
39 | #define KDB_BADADDR (-21) | ||
40 | |||
41 | /* Kernel Debugger Command codes. Must not overlap with error codes. */ | ||
42 | #define KDB_CMD_GO (-1001) | ||
43 | #define KDB_CMD_CPU (-1002) | ||
44 | #define KDB_CMD_SS (-1003) | ||
45 | #define KDB_CMD_SSB (-1004) | ||
46 | #define KDB_CMD_KGDB (-1005) | ||
47 | #define KDB_CMD_KGDB2 (-1006) | ||
48 | |||
49 | /* Internal debug flags */ | ||
50 | #define KDB_DEBUG_FLAG_BP 0x0002 /* Breakpoint subsystem debug */ | ||
51 | #define KDB_DEBUG_FLAG_BB_SUMM 0x0004 /* Basic block analysis, summary only */ | ||
52 | #define KDB_DEBUG_FLAG_AR 0x0008 /* Activation record, generic */ | ||
53 | #define KDB_DEBUG_FLAG_ARA 0x0010 /* Activation record, arch specific */ | ||
54 | #define KDB_DEBUG_FLAG_BB 0x0020 /* All basic block analysis */ | ||
55 | #define KDB_DEBUG_FLAG_STATE 0x0040 /* State flags */ | ||
56 | #define KDB_DEBUG_FLAG_MASK 0xffff /* All debug flags */ | ||
57 | #define KDB_DEBUG_FLAG_SHIFT 16 /* Shift factor for dbflags */ | ||
58 | |||
59 | #define KDB_DEBUG(flag) (kdb_flags & \ | ||
60 | (KDB_DEBUG_FLAG_##flag << KDB_DEBUG_FLAG_SHIFT)) | ||
61 | #define KDB_DEBUG_STATE(text, value) if (KDB_DEBUG(STATE)) \ | ||
62 | kdb_print_state(text, value) | ||
63 | |||
64 | #if BITS_PER_LONG == 32 | ||
65 | |||
66 | #define KDB_PLATFORM_ENV "BYTESPERWORD=4" | ||
67 | |||
68 | #define kdb_machreg_fmt "0x%lx" | ||
69 | #define kdb_machreg_fmt0 "0x%08lx" | ||
70 | #define kdb_bfd_vma_fmt "0x%lx" | ||
71 | #define kdb_bfd_vma_fmt0 "0x%08lx" | ||
72 | #define kdb_elfw_addr_fmt "0x%x" | ||
73 | #define kdb_elfw_addr_fmt0 "0x%08x" | ||
74 | #define kdb_f_count_fmt "%d" | ||
75 | |||
76 | #elif BITS_PER_LONG == 64 | ||
77 | |||
78 | #define KDB_PLATFORM_ENV "BYTESPERWORD=8" | ||
79 | |||
80 | #define kdb_machreg_fmt "0x%lx" | ||
81 | #define kdb_machreg_fmt0 "0x%016lx" | ||
82 | #define kdb_bfd_vma_fmt "0x%lx" | ||
83 | #define kdb_bfd_vma_fmt0 "0x%016lx" | ||
84 | #define kdb_elfw_addr_fmt "0x%x" | ||
85 | #define kdb_elfw_addr_fmt0 "0x%016x" | ||
86 | #define kdb_f_count_fmt "%ld" | ||
87 | |||
88 | #endif | ||
89 | |||
90 | /* | ||
91 | * KDB_MAXBPT describes the total number of breakpoints | ||
92 | * supported by this architecure. | ||
93 | */ | ||
94 | #define KDB_MAXBPT 16 | ||
95 | |||
96 | /* Maximum number of arguments to a function */ | ||
97 | #define KDB_MAXARGS 16 | ||
98 | |||
99 | typedef enum { | ||
100 | KDB_REPEAT_NONE = 0, /* Do not repeat this command */ | ||
101 | KDB_REPEAT_NO_ARGS, /* Repeat the command without arguments */ | ||
102 | KDB_REPEAT_WITH_ARGS, /* Repeat the command including its arguments */ | ||
103 | } kdb_repeat_t; | ||
104 | |||
105 | typedef int (*kdb_func_t)(int, const char **); | ||
106 | |||
107 | /* Symbol table format returned by kallsyms. */ | ||
108 | typedef struct __ksymtab { | ||
109 | unsigned long value; /* Address of symbol */ | ||
110 | const char *mod_name; /* Module containing symbol or | ||
111 | * "kernel" */ | ||
112 | unsigned long mod_start; | ||
113 | unsigned long mod_end; | ||
114 | const char *sec_name; /* Section containing symbol */ | ||
115 | unsigned long sec_start; | ||
116 | unsigned long sec_end; | ||
117 | const char *sym_name; /* Full symbol name, including | ||
118 | * any version */ | ||
119 | unsigned long sym_start; | ||
120 | unsigned long sym_end; | ||
121 | } kdb_symtab_t; | ||
122 | extern int kallsyms_symbol_next(char *prefix_name, int flag); | ||
123 | extern int kallsyms_symbol_complete(char *prefix_name, int max_len); | ||
124 | |||
125 | /* Exported Symbols for kernel loadable modules to use. */ | ||
126 | extern int kdb_register(char *, kdb_func_t, char *, char *, short); | ||
127 | extern int kdb_register_repeat(char *, kdb_func_t, char *, char *, | ||
128 | short, kdb_repeat_t); | ||
129 | extern int kdb_unregister(char *); | ||
130 | |||
131 | extern int kdb_getarea_size(void *, unsigned long, size_t); | ||
132 | extern int kdb_putarea_size(unsigned long, void *, size_t); | ||
133 | |||
134 | /* | ||
135 | * Like get_user and put_user, kdb_getarea and kdb_putarea take variable | ||
136 | * names, not pointers. The underlying *_size functions take pointers. | ||
137 | */ | ||
138 | #define kdb_getarea(x, addr) kdb_getarea_size(&(x), addr, sizeof((x))) | ||
139 | #define kdb_putarea(addr, x) kdb_putarea_size(addr, &(x), sizeof((x))) | ||
140 | |||
141 | extern int kdb_getphysword(unsigned long *word, | ||
142 | unsigned long addr, size_t size); | ||
143 | extern int kdb_getword(unsigned long *, unsigned long, size_t); | ||
144 | extern int kdb_putword(unsigned long, unsigned long, size_t); | ||
145 | |||
146 | extern int kdbgetularg(const char *, unsigned long *); | ||
147 | extern int kdb_set(int, const char **); | ||
148 | extern char *kdbgetenv(const char *); | ||
149 | extern int kdbgetintenv(const char *, int *); | ||
150 | extern int kdbgetaddrarg(int, const char **, int*, unsigned long *, | ||
151 | long *, char **); | ||
152 | extern int kdbgetsymval(const char *, kdb_symtab_t *); | ||
153 | extern int kdbnearsym(unsigned long, kdb_symtab_t *); | ||
154 | extern void kdbnearsym_cleanup(void); | ||
155 | extern char *kdb_strdup(const char *str, gfp_t type); | ||
156 | extern void kdb_symbol_print(unsigned long, const kdb_symtab_t *, unsigned int); | ||
157 | |||
158 | /* Routine for debugging the debugger state. */ | ||
159 | extern void kdb_print_state(const char *, int); | ||
160 | |||
161 | extern int kdb_state; | ||
162 | #define KDB_STATE_KDB 0x00000001 /* Cpu is inside kdb */ | ||
163 | #define KDB_STATE_LEAVING 0x00000002 /* Cpu is leaving kdb */ | ||
164 | #define KDB_STATE_CMD 0x00000004 /* Running a kdb command */ | ||
165 | #define KDB_STATE_KDB_CONTROL 0x00000008 /* This cpu is under | ||
166 | * kdb control */ | ||
167 | #define KDB_STATE_HOLD_CPU 0x00000010 /* Hold this cpu inside kdb */ | ||
168 | #define KDB_STATE_DOING_SS 0x00000020 /* Doing ss command */ | ||
169 | #define KDB_STATE_DOING_SSB 0x00000040 /* Doing ssb command, | ||
170 | * DOING_SS is also set */ | ||
171 | #define KDB_STATE_SSBPT 0x00000080 /* Install breakpoint | ||
172 | * after one ss, independent of | ||
173 | * DOING_SS */ | ||
174 | #define KDB_STATE_REENTRY 0x00000100 /* Valid re-entry into kdb */ | ||
175 | #define KDB_STATE_SUPPRESS 0x00000200 /* Suppress error messages */ | ||
176 | #define KDB_STATE_PAGER 0x00000400 /* pager is available */ | ||
177 | #define KDB_STATE_GO_SWITCH 0x00000800 /* go is switching | ||
178 | * back to initial cpu */ | ||
179 | #define KDB_STATE_PRINTF_LOCK 0x00001000 /* Holds kdb_printf lock */ | ||
180 | #define KDB_STATE_WAIT_IPI 0x00002000 /* Waiting for kdb_ipi() NMI */ | ||
181 | #define KDB_STATE_RECURSE 0x00004000 /* Recursive entry to kdb */ | ||
182 | #define KDB_STATE_IP_ADJUSTED 0x00008000 /* Restart IP has been | ||
183 | * adjusted */ | ||
184 | #define KDB_STATE_GO1 0x00010000 /* go only releases one cpu */ | ||
185 | #define KDB_STATE_KEYBOARD 0x00020000 /* kdb entered via | ||
186 | * keyboard on this cpu */ | ||
187 | #define KDB_STATE_KEXEC 0x00040000 /* kexec issued */ | ||
188 | #define KDB_STATE_DOING_KGDB 0x00080000 /* kgdb enter now issued */ | ||
189 | #define KDB_STATE_DOING_KGDB2 0x00100000 /* kgdb enter now issued */ | ||
190 | #define KDB_STATE_KGDB_TRANS 0x00200000 /* Transition to kgdb */ | ||
191 | #define KDB_STATE_ARCH 0xff000000 /* Reserved for arch | ||
192 | * specific use */ | ||
193 | |||
194 | #define KDB_STATE(flag) (kdb_state & KDB_STATE_##flag) | ||
195 | #define KDB_STATE_SET(flag) ((void)(kdb_state |= KDB_STATE_##flag)) | ||
196 | #define KDB_STATE_CLEAR(flag) ((void)(kdb_state &= ~KDB_STATE_##flag)) | ||
197 | |||
198 | extern int kdb_nextline; /* Current number of lines displayed */ | ||
199 | |||
200 | typedef struct _kdb_bp { | ||
201 | unsigned long bp_addr; /* Address breakpoint is present at */ | ||
202 | unsigned int bp_free:1; /* This entry is available */ | ||
203 | unsigned int bp_enabled:1; /* Breakpoint is active in register */ | ||
204 | unsigned int bp_type:4; /* Uses hardware register */ | ||
205 | unsigned int bp_installed:1; /* Breakpoint is installed */ | ||
206 | unsigned int bp_delay:1; /* Do delayed bp handling */ | ||
207 | unsigned int bp_delayed:1; /* Delayed breakpoint */ | ||
208 | unsigned int bph_length; /* HW break length */ | ||
209 | } kdb_bp_t; | ||
210 | |||
211 | #ifdef CONFIG_KGDB_KDB | ||
212 | extern kdb_bp_t kdb_breakpoints[/* KDB_MAXBPT */]; | ||
213 | |||
214 | /* The KDB shell command table */ | ||
215 | typedef struct _kdbtab { | ||
216 | char *cmd_name; /* Command name */ | ||
217 | kdb_func_t cmd_func; /* Function to execute command */ | ||
218 | char *cmd_usage; /* Usage String for this command */ | ||
219 | char *cmd_help; /* Help message for this command */ | ||
220 | short cmd_flags; /* Parsing flags */ | ||
221 | short cmd_minlen; /* Minimum legal # command | ||
222 | * chars required */ | ||
223 | kdb_repeat_t cmd_repeat; /* Does command auto repeat on enter? */ | ||
224 | } kdbtab_t; | ||
225 | |||
226 | extern int kdb_bt(int, const char **); /* KDB display back trace */ | ||
227 | |||
228 | /* KDB breakpoint management functions */ | ||
229 | extern void kdb_initbptab(void); | ||
230 | extern void kdb_bp_install(struct pt_regs *); | ||
231 | extern void kdb_bp_remove(void); | ||
232 | |||
233 | typedef enum { | ||
234 | KDB_DB_BPT, /* Breakpoint */ | ||
235 | KDB_DB_SS, /* Single-step trap */ | ||
236 | KDB_DB_SSB, /* Single step to branch */ | ||
237 | KDB_DB_SSBPT, /* Single step over breakpoint */ | ||
238 | KDB_DB_NOBPT /* Spurious breakpoint */ | ||
239 | } kdb_dbtrap_t; | ||
240 | |||
241 | extern int kdb_main_loop(kdb_reason_t, kdb_reason_t, | ||
242 | int, kdb_dbtrap_t, struct pt_regs *); | ||
243 | |||
244 | /* Miscellaneous functions and data areas */ | ||
245 | extern int kdb_grepping_flag; | ||
246 | extern char kdb_grep_string[]; | ||
247 | extern int kdb_grep_leading; | ||
248 | extern int kdb_grep_trailing; | ||
249 | extern char *kdb_cmds[]; | ||
250 | extern void kdb_syslog_data(char *syslog_data[]); | ||
251 | extern unsigned long kdb_task_state_string(const char *); | ||
252 | extern char kdb_task_state_char (const struct task_struct *); | ||
253 | extern unsigned long kdb_task_state(const struct task_struct *p, | ||
254 | unsigned long mask); | ||
255 | extern void kdb_ps_suppressed(void); | ||
256 | extern void kdb_ps1(const struct task_struct *p); | ||
257 | extern void kdb_print_nameval(const char *name, unsigned long val); | ||
258 | extern void kdb_send_sig_info(struct task_struct *p, struct siginfo *info); | ||
259 | extern void kdb_meminfo_proc_show(void); | ||
260 | extern const char *kdb_walk_kallsyms(loff_t *pos); | ||
261 | extern char *kdb_getstr(char *, size_t, char *); | ||
262 | |||
263 | /* Defines for kdb_symbol_print */ | ||
264 | #define KDB_SP_SPACEB 0x0001 /* Space before string */ | ||
265 | #define KDB_SP_SPACEA 0x0002 /* Space after string */ | ||
266 | #define KDB_SP_PAREN 0x0004 /* Parenthesis around string */ | ||
267 | #define KDB_SP_VALUE 0x0008 /* Print the value of the address */ | ||
268 | #define KDB_SP_SYMSIZE 0x0010 /* Print the size of the symbol */ | ||
269 | #define KDB_SP_NEWLINE 0x0020 /* Newline after string */ | ||
270 | #define KDB_SP_DEFAULT (KDB_SP_VALUE|KDB_SP_PAREN) | ||
271 | |||
272 | #define KDB_TSK(cpu) kgdb_info[cpu].task | ||
273 | #define KDB_TSKREGS(cpu) kgdb_info[cpu].debuggerinfo | ||
274 | |||
275 | extern struct task_struct *kdb_curr_task(int); | ||
276 | |||
277 | #define kdb_task_has_cpu(p) (task_curr(p)) | ||
278 | |||
279 | /* Simplify coexistence with NPTL */ | ||
280 | #define kdb_do_each_thread(g, p) do_each_thread(g, p) | ||
281 | #define kdb_while_each_thread(g, p) while_each_thread(g, p) | ||
282 | |||
283 | #define GFP_KDB (in_interrupt() ? GFP_ATOMIC : GFP_KERNEL) | ||
284 | |||
285 | extern void *debug_kmalloc(size_t size, gfp_t flags); | ||
286 | extern void debug_kfree(void *); | ||
287 | extern void debug_kusage(void); | ||
288 | |||
289 | extern void kdb_set_current_task(struct task_struct *); | ||
290 | extern struct task_struct *kdb_current_task; | ||
291 | #ifdef CONFIG_MODULES | ||
292 | extern struct list_head *kdb_modules; | ||
293 | #endif /* CONFIG_MODULES */ | ||
294 | |||
295 | extern char kdb_prompt_str[]; | ||
296 | |||
297 | #define KDB_WORD_SIZE ((int)sizeof(unsigned long)) | ||
298 | |||
299 | #endif /* CONFIG_KGDB_KDB */ | ||
300 | #endif /* !_KDBPRIVATE_H */ | ||