aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/kdb.h
diff options
context:
space:
mode:
authorJason Wessel <jason.wessel@windriver.com>2010-05-20 22:04:20 -0400
committerJason Wessel <jason.wessel@windriver.com>2010-05-20 22:04:20 -0400
commit5d5314d6795f3c1c0f415348ff8c51f7de042b77 (patch)
tree2f433649d29be98ebc975f352b7d7046a2a2beec /include/linux/kdb.h
parente8861129d3c1a64e3c62f459aeb1cd54a55ab045 (diff)
kdb: core for kgdb back end (1 of 2)
This patch contains only the kdb core. Because the change set was large, it was split. The next patch in the series includes the instrumentation into the core kernel which are mainly helper functions for kdb. This work is directly derived from kdb v4.4 found at: ftp://oss.sgi.com/projects/kdb/download/v4.4/ The kdb internals have been re-organized to make them mostly platform independent and to connect everything to the debug core which is used by gdbstub (which has long been known as kgdb). The original version of kdb was 58,000 lines worth of changes to support x86. From that implementation only the kdb shell, and basic commands for memory access, runcontrol, lsmod, and dmesg where carried forward. This is a generic implementation which aims to cover all the current architectures using the kgdb core: ppc, arm, x86, mips, sparc, sh and blackfin. More archictectures can be added by implementing the architecture specific kgdb functions. [mort@sgi.com: Compile fix with hugepages enabled] [mort@sgi.com: Clean breakpoint code renaming kdba_ -> kdb_] [mort@sgi.com: fix new line after printing registers] [mort@sgi.com: Remove the concept of global vs. local breakpoints] [mort@sgi.com: Rework kdb_si_swapinfo to use more generic name] [mort@sgi.com: fix the information dump macros, remove 'arch' from the names] [sfr@canb.auug.org.au: include fixup to include linux/slab.h] CC: linux-arch@vger.kernel.org Signed-off-by: Jason Wessel <jason.wessel@windriver.com> Signed-off-by: Martin Hicks <mort@sgi.com>
Diffstat (limited to 'include/linux/kdb.h')
-rw-r--r--include/linux/kdb.h113
1 files changed, 113 insertions, 0 deletions
diff --git a/include/linux/kdb.h b/include/linux/kdb.h
new file mode 100644
index 000000000000..4d93790faec3
--- /dev/null
+++ b/include/linux/kdb.h
@@ -0,0 +1,113 @@
1#ifndef _KDB_H
2#define _KDB_H
3
4/*
5 * Kernel Debugger Architecture Independent Global 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-2007 Silicon Graphics, Inc. All Rights Reserved.
12 * Copyright (C) 2000 Stephane Eranian <eranian@hpl.hp.com>
13 * Copyright (C) 2009 Jason Wessel <jason.wessel@windriver.com>
14 */
15
16#ifdef CONFIG_KGDB_KDB
17#include <linux/init.h>
18#include <linux/sched.h>
19#include <asm/atomic.h>
20
21#define KDB_POLL_FUNC_MAX 5
22
23/*
24 * kdb_initial_cpu is initialized to -1, and is set to the cpu
25 * number whenever the kernel debugger is entered.
26 */
27extern int kdb_initial_cpu;
28extern atomic_t kdb_event;
29
30/*
31 * kdb_diemsg
32 *
33 * Contains a pointer to the last string supplied to the
34 * kernel 'die' panic function.
35 */
36extern const char *kdb_diemsg;
37
38#define KDB_FLAG_EARLYKDB (1 << 0) /* set from boot parameter kdb=early */
39#define KDB_FLAG_CATASTROPHIC (1 << 1) /* A catastrophic event has occurred */
40#define KDB_FLAG_CMD_INTERRUPT (1 << 2) /* Previous command was interrupted */
41#define KDB_FLAG_NOIPI (1 << 3) /* Do not send IPIs */
42#define KDB_FLAG_ONLY_DO_DUMP (1 << 4) /* Only do a dump, used when
43 * kdb is off */
44#define KDB_FLAG_NO_CONSOLE (1 << 5) /* No console is available,
45 * kdb is disabled */
46#define KDB_FLAG_NO_VT_CONSOLE (1 << 6) /* No VT console is available, do
47 * not use keyboard */
48#define KDB_FLAG_NO_I8042 (1 << 7) /* No i8042 chip is available, do
49 * not use keyboard */
50
51extern int kdb_flags; /* Global flags, see kdb_state for per cpu state */
52
53extern void kdb_save_flags(void);
54extern void kdb_restore_flags(void);
55
56#define KDB_FLAG(flag) (kdb_flags & KDB_FLAG_##flag)
57#define KDB_FLAG_SET(flag) ((void)(kdb_flags |= KDB_FLAG_##flag))
58#define KDB_FLAG_CLEAR(flag) ((void)(kdb_flags &= ~KDB_FLAG_##flag))
59
60/*
61 * External entry point for the kernel debugger. The pt_regs
62 * at the time of entry are supplied along with the reason for
63 * entry to the kernel debugger.
64 */
65
66typedef enum {
67 KDB_REASON_ENTER = 1, /* KDB_ENTER() trap/fault - regs valid */
68 KDB_REASON_ENTER_SLAVE, /* KDB_ENTER_SLAVE() trap/fault - regs valid */
69 KDB_REASON_BREAK, /* Breakpoint inst. - regs valid */
70 KDB_REASON_DEBUG, /* Debug Fault - regs valid */
71 KDB_REASON_OOPS, /* Kernel Oops - regs valid */
72 KDB_REASON_SWITCH, /* CPU switch - regs valid*/
73 KDB_REASON_KEYBOARD, /* Keyboard entry - regs valid */
74 KDB_REASON_NMI, /* Non-maskable interrupt; regs valid */
75 KDB_REASON_RECURSE, /* Recursive entry to kdb;
76 * regs probably valid */
77 KDB_REASON_SSTEP, /* Single Step trap. - regs valid */
78} kdb_reason_t;
79
80extern int kdb_printf(const char *, ...)
81 __attribute__ ((format (printf, 1, 2)));
82typedef int (*kdb_printf_t)(const char *, ...)
83 __attribute__ ((format (printf, 1, 2)));
84
85extern void kdb_init(int level);
86
87/* Access to kdb specific polling devices */
88typedef int (*get_char_func)(void);
89extern get_char_func kdb_poll_funcs[];
90extern int kdb_get_kbd_char(void);
91
92static inline
93int kdb_process_cpu(const struct task_struct *p)
94{
95 unsigned int cpu = task_thread_info(p)->cpu;
96 if (cpu > num_possible_cpus())
97 cpu = 0;
98 return cpu;
99}
100
101/* kdb access to register set for stack dumping */
102extern struct pt_regs *kdb_current_regs;
103
104#else /* ! CONFIG_KGDB_KDB */
105#define kdb_printf(...)
106#define kdb_init(x)
107#endif /* CONFIG_KGDB_KDB */
108enum {
109 KDB_NOT_INITIALIZED,
110 KDB_INIT_EARLY,
111 KDB_INIT_FULL,
112};
113#endif /* !_KDB_H */