| 1 |
|
| 2 | #ifndef _KDBPRIVATE_H
|
| 3 | #define _KDBPRIVATE_H
|
| 4 |
|
| 5 | |
| 6 | * Kernel Debugger Architecture Independent Private Headers
|
| 7 | *
|
| 8 | * This file is subject to the terms and conditions of the GNU General Public
|
| 9 | * License. See the file "COPYING" in the main directory of this archive
|
| 10 | * for more details.
|
| 11 | *
|
| 12 | * Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved.
|
| 13 | * Copyright (c) 2009 Wind River Systems, Inc. All Rights Reserved.
|
| 14 |
|
| 15 |
|
| 16 | #include <linux/kgdb.h>
|
| 17 | #include "../debug_core.h"
|
| 18 |
|
| 19 |
|
| 20 | #define KDB_CMD_GO (-1001)
|
| 21 | #define KDB_CMD_CPU (-1002)
|
| 22 | #define KDB_CMD_SS (-1003)
|
| 23 | #define KDB_CMD_KGDB (-1005)
|
| 24 |
|
| 25 |
|
| 26 | #define KDB_DEBUG_FLAG_BP 0x0002
|
| 27 | #define KDB_DEBUG_FLAG_BB_SUMM 0x0004
|
| 28 | #define KDB_DEBUG_FLAG_AR 0x0008
|
| 29 | #define KDB_DEBUG_FLAG_ARA 0x0010
|
| 30 | #define KDB_DEBUG_FLAG_BB 0x0020
|
| 31 | #define KDB_DEBUG_FLAG_STATE 0x0040
|
| 32 | #define KDB_DEBUG_FLAG_MASK 0xffff
|
| 33 | #define KDB_DEBUG_FLAG_SHIFT 16
|
| 34 |
|
| 35 | #define KDB_DEBUG(flag) (kdb_flags & \
|
| 36 | (KDB_DEBUG_FLAG_##flag << KDB_DEBUG_FLAG_SHIFT))
|
| 37 | #define KDB_DEBUG_STATE(text, value) if (KDB_DEBUG(STATE)) \
|
| 38 | kdb_print_state(text, value)
|
| 39 |
|
| 40 | #if BITS_PER_LONG == 32
|
| 41 |
|
| 42 | #define KDB_PLATFORM_ENV "BYTESPERWORD=4"
|
| 43 |
|
| 44 | #define kdb_machreg_fmt "0x%lx"
|
| 45 | #define kdb_machreg_fmt0 "0x%08lx"
|
| 46 | #define kdb_bfd_vma_fmt "0x%lx"
|
| 47 | #define kdb_bfd_vma_fmt0 "0x%08lx"
|
| 48 | #define kdb_elfw_addr_fmt "0x%x"
|
| 49 | #define kdb_elfw_addr_fmt0 "0x%08x"
|
| 50 | #define kdb_f_count_fmt "%d"
|
| 51 |
|
| 52 | #elif BITS_PER_LONG == 64
|
| 53 |
|
| 54 | #define KDB_PLATFORM_ENV "BYTESPERWORD=8"
|
| 55 |
|
| 56 | #define kdb_machreg_fmt "0x%lx"
|
| 57 | #define kdb_machreg_fmt0 "0x%016lx"
|
| 58 | #define kdb_bfd_vma_fmt "0x%lx"
|
| 59 | #define kdb_bfd_vma_fmt0 "0x%016lx"
|
| 60 | #define kdb_elfw_addr_fmt "0x%x"
|
| 61 | #define kdb_elfw_addr_fmt0 "0x%016x"
|
| 62 | #define kdb_f_count_fmt "%ld"
|
| 63 |
|
| 64 | #endif
|
| 65 |
|
| 66 | |
| 67 | * KDB_MAXBPT describes the total number of breakpoints
|
| 68 | * supported by this architecture.
|
| 69 |
|
| 70 | #define KDB_MAXBPT 16
|
| 71 |
|
| 72 |
|
| 73 | typedef struct __ksymtab {
|
| 74 | unsigned long value;
|
| 75 | const char *mod_name; |
| 76 | * "kernel"
|
| 77 | unsigned long mod_start;
|
| 78 | unsigned long mod_end;
|
| 79 | const char *sec_name;
|
| 80 | unsigned long sec_start;
|
| 81 | unsigned long sec_end;
|
| 82 | const char *sym_name; |
| 83 | * any version
|
| 84 | unsigned long sym_start;
|
| 85 | unsigned long sym_end;
|
| 86 | } kdb_symtab_t;
|
| 87 | extern int kallsyms_symbol_next(char *prefix_name, int flag, int buf_size);
|
| 88 | extern int kallsyms_symbol_complete(char *prefix_name, int max_len);
|
| 89 |
|
| 90 |
|
| 91 | extern int kdb_getarea_size(void *, unsigned long, size_t);
|
| 92 | extern int kdb_putarea_size(unsigned long, void *, size_t);
|
| 93 |
|
| 94 | |
| 95 | * Like get_user and put_user, kdb_getarea and kdb_putarea take variable
|
| 96 | * names, not pointers. The underlying *_size functions take pointers.
|
| 97 |
|
| 98 | #define kdb_getarea(x, addr) kdb_getarea_size(&(x), addr, sizeof((x)))
|
| 99 | #define kdb_putarea(addr, x) kdb_putarea_size(addr, &(x), sizeof((x)))
|
| 100 |
|
| 101 | extern int kdb_getphysword(unsigned long *word,
|
| 102 | unsigned long addr, size_t size);
|
| 103 | extern int kdb_getword(unsigned long *, unsigned long, size_t);
|
| 104 | extern int kdb_putword(unsigned long, unsigned long, size_t);
|
| 105 |
|
| 106 | extern int kdbgetularg(const char *, unsigned long *);
|
| 107 | extern int kdbgetu64arg(const char *, u64 *);
|
| 108 | extern char *kdbgetenv(const char *);
|
| 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 char *kdb_strdup(const char *str, gfp_t type);
|
| 114 | extern char *kdb_strdup_dequote(const char *str, gfp_t type);
|
| 115 | extern void kdb_symbol_print(unsigned long, const kdb_symtab_t *, unsigned int);
|
| 116 |
|
| 117 |
|
| 118 | extern void kdb_print_state(const char *, int);
|
| 119 |
|
| 120 | extern int kdb_state;
|
| 121 | #define KDB_STATE_KDB 0x00000001
|
| 122 | #define KDB_STATE_LEAVING 0x00000002
|
| 123 | #define KDB_STATE_CMD 0x00000004
|
| 124 | #define KDB_STATE_KDB_CONTROL 0x00000008 |
| 125 | * kdb control
|
| 126 | #define KDB_STATE_HOLD_CPU 0x00000010
|
| 127 | #define KDB_STATE_DOING_SS 0x00000020
|
| 128 | #define KDB_STATE_SSBPT 0x00000080 |
| 129 | * after one ss, independent of
|
| 130 | * DOING_SS
|
| 131 | #define KDB_STATE_REENTRY 0x00000100
|
| 132 | #define KDB_STATE_SUPPRESS 0x00000200
|
| 133 | #define KDB_STATE_PAGER 0x00000400
|
| 134 | #define KDB_STATE_GO_SWITCH 0x00000800 |
| 135 | * back to initial cpu
|
| 136 | #define KDB_STATE_WAIT_IPI 0x00002000
|
| 137 | #define KDB_STATE_RECURSE 0x00004000
|
| 138 | #define KDB_STATE_IP_ADJUSTED 0x00008000 |
| 139 | * adjusted
|
| 140 | #define KDB_STATE_GO1 0x00010000
|
| 141 | #define KDB_STATE_KEYBOARD 0x00020000 |
| 142 | * keyboard on this cpu
|
| 143 | #define KDB_STATE_KEXEC 0x00040000
|
| 144 | #define KDB_STATE_DOING_KGDB 0x00080000
|
| 145 | #define KDB_STATE_KGDB_TRANS 0x00200000
|
| 146 | #define KDB_STATE_ARCH 0xff000000 |
| 147 | * specific use
|
| 148 |
|
| 149 | #define KDB_STATE(flag) (kdb_state & KDB_STATE_##flag)
|
| 150 | #define KDB_STATE_SET(flag) ((void)(kdb_state |= KDB_STATE_##flag))
|
| 151 | #define KDB_STATE_CLEAR(flag) ((void)(kdb_state &= ~KDB_STATE_##flag))
|
| 152 |
|
| 153 | extern int kdb_nextline;
|
| 154 |
|
| 155 | typedef struct _kdb_bp {
|
| 156 | unsigned long bp_addr;
|
| 157 | unsigned int bp_free:1;
|
| 158 | unsigned int bp_enabled:1;
|
| 159 | unsigned int bp_type:4;
|
| 160 | unsigned int bp_installed:1;
|
| 161 | unsigned int bp_delay:1;
|
| 162 | unsigned int bp_delayed:1;
|
| 163 | unsigned int bph_length;
|
| 164 | } kdb_bp_t;
|
| 165 |
|
| 166 | #ifdef CONFIG_KGDB_KDB
|
| 167 | extern kdb_bp_t kdb_breakpoints[];
|
| 168 |
|
| 169 | extern void kdb_register_table(kdbtab_t *kp, size_t len);
|
| 170 | extern int kdb_bt(int, const char **);
|
| 171 |
|
| 172 |
|
| 173 | extern void kdb_initbptab(void);
|
| 174 | extern void kdb_bp_install(struct pt_regs *);
|
| 175 | extern void kdb_bp_remove(void);
|
| 176 |
|
| 177 | typedef enum {
|
| 178 | KDB_DB_BPT,
|
| 179 | KDB_DB_SS,
|
| 180 | KDB_DB_SSBPT,
|
| 181 | KDB_DB_NOBPT
|
| 182 | } kdb_dbtrap_t;
|
| 183 |
|
| 184 | extern int kdb_main_loop(kdb_reason_t, kdb_reason_t,
|
| 185 | int, kdb_dbtrap_t, struct pt_regs *);
|
| 186 |
|
| 187 |
|
| 188 | extern int kdb_grepping_flag;
|
| 189 | #define KDB_GREPPING_FLAG_SEARCH 0x8000
|
| 190 | extern char kdb_grep_string[];
|
| 191 | #define KDB_GREP_STRLEN 256
|
| 192 | extern int kdb_grep_leading;
|
| 193 | extern int kdb_grep_trailing;
|
| 194 | extern char *kdb_cmds[];
|
| 195 | extern char kdb_task_state_char (const struct task_struct *);
|
| 196 | extern bool kdb_task_state(const struct task_struct *p, const char *mask);
|
| 197 | extern void kdb_ps_suppressed(void);
|
| 198 | extern void kdb_ps1(const struct task_struct *p);
|
| 199 | extern char kdb_getchar(void);
|
| 200 | extern char *kdb_getstr(char *, size_t, const char *);
|
| 201 | extern void kdb_gdb_state_pass(char *buf);
|
| 202 |
|
| 203 |
|
| 204 | #define KDB_SP_SPACEB 0x0001
|
| 205 | #define KDB_SP_SPACEA 0x0002
|
| 206 | #define KDB_SP_PAREN 0x0004
|
| 207 | #define KDB_SP_VALUE 0x0008
|
| 208 | #define KDB_SP_SYMSIZE 0x0010
|
| 209 | #define KDB_SP_NEWLINE 0x0020
|
| 210 | #define KDB_SP_DEFAULT (KDB_SP_VALUE|KDB_SP_PAREN)
|
| 211 |
|
| 212 | #define KDB_TSK(cpu) kgdb_info[cpu].task
|
| 213 | #define KDB_TSKREGS(cpu) kgdb_info[cpu].debuggerinfo
|
| 214 |
|
| 215 | #define kdb_task_has_cpu(p) (task_curr(p))
|
| 216 |
|
| 217 | #define GFP_KDB (in_dbg_master() ? GFP_ATOMIC : GFP_KERNEL)
|
| 218 |
|
| 219 | extern struct task_struct *kdb_current_task;
|
| 220 | extern struct pt_regs *kdb_current_regs;
|
| 221 |
|
| 222 | #ifdef CONFIG_KDB_KEYBOARD
|
| 223 | extern void kdb_kbd_cleanup_state(void);
|
| 224 | #else
|
| 225 | #define kdb_kbd_cleanup_state()
|
| 226 | #endif
|
| 227 |
|
| 228 | extern char kdb_prompt_str[];
|
| 229 |
|
| 230 | #define KDB_WORD_SIZE ((int)sizeof(unsigned long))
|
| 231 |
|
| 232 | #endif
|
| 233 |
|
| 234 | #define kdb_func_printf(format, args...) \
|
| 235 | kdb_printf("%s: " format, __func__, ## args)
|
| 236 |
|
| 237 | #define kdb_dbg_printf(mask, format, args...) \
|
| 238 | do { \
|
| 239 | if (KDB_DEBUG(mask)) \
|
| 240 | kdb_func_printf(format, ## args); \
|
| 241 | } while (0)
|
| 242 |
|
| 243 | #endif
|