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