Linux Audio

Check our new training course

Loading...
v5.9
  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/* Shifted versions of the command enable bits are be used if the command
 17 * has no arguments (see kdb_check_flags). This allows commands, such as
 18 * go, to have different permissions depending upon whether it is called
 19 * with an argument.
 20 */
 21#define KDB_ENABLE_NO_ARGS_SHIFT 10
 22
 23typedef enum {
 24	KDB_ENABLE_ALL = (1 << 0), /* Enable everything */
 25	KDB_ENABLE_MEM_READ = (1 << 1),
 26	KDB_ENABLE_MEM_WRITE = (1 << 2),
 27	KDB_ENABLE_REG_READ = (1 << 3),
 28	KDB_ENABLE_REG_WRITE = (1 << 4),
 29	KDB_ENABLE_INSPECT = (1 << 5),
 30	KDB_ENABLE_FLOW_CTRL = (1 << 6),
 31	KDB_ENABLE_SIGNAL = (1 << 7),
 32	KDB_ENABLE_REBOOT = (1 << 8),
 33	/* User exposed values stop here, all remaining flags are
 34	 * exclusively used to describe a commands behaviour.
 35	 */
 36
 37	KDB_ENABLE_ALWAYS_SAFE = (1 << 9),
 38	KDB_ENABLE_MASK = (1 << KDB_ENABLE_NO_ARGS_SHIFT) - 1,
 39
 40	KDB_ENABLE_ALL_NO_ARGS = KDB_ENABLE_ALL << KDB_ENABLE_NO_ARGS_SHIFT,
 41	KDB_ENABLE_MEM_READ_NO_ARGS = KDB_ENABLE_MEM_READ
 42				      << KDB_ENABLE_NO_ARGS_SHIFT,
 43	KDB_ENABLE_MEM_WRITE_NO_ARGS = KDB_ENABLE_MEM_WRITE
 44				       << KDB_ENABLE_NO_ARGS_SHIFT,
 45	KDB_ENABLE_REG_READ_NO_ARGS = KDB_ENABLE_REG_READ
 46				      << KDB_ENABLE_NO_ARGS_SHIFT,
 47	KDB_ENABLE_REG_WRITE_NO_ARGS = KDB_ENABLE_REG_WRITE
 48				       << KDB_ENABLE_NO_ARGS_SHIFT,
 49	KDB_ENABLE_INSPECT_NO_ARGS = KDB_ENABLE_INSPECT
 50				     << KDB_ENABLE_NO_ARGS_SHIFT,
 51	KDB_ENABLE_FLOW_CTRL_NO_ARGS = KDB_ENABLE_FLOW_CTRL
 52				       << KDB_ENABLE_NO_ARGS_SHIFT,
 53	KDB_ENABLE_SIGNAL_NO_ARGS = KDB_ENABLE_SIGNAL
 54				    << KDB_ENABLE_NO_ARGS_SHIFT,
 55	KDB_ENABLE_REBOOT_NO_ARGS = KDB_ENABLE_REBOOT
 56				    << KDB_ENABLE_NO_ARGS_SHIFT,
 57	KDB_ENABLE_ALWAYS_SAFE_NO_ARGS = KDB_ENABLE_ALWAYS_SAFE
 58					 << KDB_ENABLE_NO_ARGS_SHIFT,
 59	KDB_ENABLE_MASK_NO_ARGS = KDB_ENABLE_MASK << KDB_ENABLE_NO_ARGS_SHIFT,
 60
 61	KDB_REPEAT_NO_ARGS = 0x40000000, /* Repeat the command w/o arguments */
 62	KDB_REPEAT_WITH_ARGS = 0x80000000, /* Repeat the command with args */
 63} kdb_cmdflags_t;
 64
 65typedef int (*kdb_func_t)(int, const char **);
 66
 67#ifdef	CONFIG_KGDB_KDB
 68#include <linux/init.h>
 69#include <linux/sched.h>
 70#include <linux/atomic.h>
 71
 72#define KDB_POLL_FUNC_MAX	5
 73extern int kdb_poll_idx;
 74
 75/*
 76 * kdb_initial_cpu is initialized to -1, and is set to the cpu
 77 * number whenever the kernel debugger is entered.
 78 */
 79extern int kdb_initial_cpu;
 
 80
 81/* Types and messages used for dynamically added kdb shell commands */
 82
 83#define KDB_MAXARGS    16 /* Maximum number of arguments to a function  */
 84
 
 
 
 
 
 
 
 
 85/* KDB return codes from a command or internal kdb function */
 86#define KDB_NOTFOUND	(-1)
 87#define KDB_ARGCOUNT	(-2)
 88#define KDB_BADWIDTH	(-3)
 89#define KDB_BADRADIX	(-4)
 90#define KDB_NOTENV	(-5)
 91#define KDB_NOENVVALUE	(-6)
 92#define KDB_NOTIMP	(-7)
 93#define KDB_ENVFULL	(-8)
 94#define KDB_ENVBUFFULL	(-9)
 95#define KDB_TOOMANYBPT	(-10)
 96#define KDB_TOOMANYDBREGS (-11)
 97#define KDB_DUPBPT	(-12)
 98#define KDB_BPTNOTFOUND	(-13)
 99#define KDB_BADMODE	(-14)
100#define KDB_BADINT	(-15)
101#define KDB_INVADDRFMT  (-16)
102#define KDB_BADREG      (-17)
103#define KDB_BADCPUNUM   (-18)
104#define KDB_BADLENGTH	(-19)
105#define KDB_NOBP	(-20)
106#define KDB_BADADDR	(-21)
107#define KDB_NOPERM	(-22)
108
109/*
110 * kdb_diemsg
111 *
112 *	Contains a pointer to the last string supplied to the
113 *	kernel 'die' panic function.
114 */
115extern const char *kdb_diemsg;
116
117#define KDB_FLAG_EARLYKDB	(1 << 0) /* set from boot parameter kdb=early */
118#define KDB_FLAG_CATASTROPHIC	(1 << 1) /* A catastrophic event has occurred */
119#define KDB_FLAG_CMD_INTERRUPT	(1 << 2) /* Previous command was interrupted */
120#define KDB_FLAG_NOIPI		(1 << 3) /* Do not send IPIs */
 
 
121#define KDB_FLAG_NO_CONSOLE	(1 << 5) /* No console is available,
122					  * kdb is disabled */
123#define KDB_FLAG_NO_VT_CONSOLE	(1 << 6) /* No VT console is available, do
124					  * not use keyboard */
125#define KDB_FLAG_NO_I8042	(1 << 7) /* No i8042 chip is available, do
126					  * not use keyboard */
127
128extern unsigned int kdb_flags;	/* Global flags, see kdb_state for per cpu state */
129
130extern void kdb_save_flags(void);
131extern void kdb_restore_flags(void);
132
133#define KDB_FLAG(flag)		(kdb_flags & KDB_FLAG_##flag)
134#define KDB_FLAG_SET(flag)	((void)(kdb_flags |= KDB_FLAG_##flag))
135#define KDB_FLAG_CLEAR(flag)	((void)(kdb_flags &= ~KDB_FLAG_##flag))
136
137/*
138 * External entry point for the kernel debugger.  The pt_regs
139 * at the time of entry are supplied along with the reason for
140 * entry to the kernel debugger.
141 */
142
143typedef enum {
144	KDB_REASON_ENTER = 1,	/* KDB_ENTER() trap/fault - regs valid */
145	KDB_REASON_ENTER_SLAVE,	/* KDB_ENTER_SLAVE() trap/fault - regs valid */
146	KDB_REASON_BREAK,	/* Breakpoint inst. - regs valid */
147	KDB_REASON_DEBUG,	/* Debug Fault - regs valid */
148	KDB_REASON_OOPS,	/* Kernel Oops - regs valid */
149	KDB_REASON_SWITCH,	/* CPU switch - regs valid*/
150	KDB_REASON_KEYBOARD,	/* Keyboard entry - regs valid */
151	KDB_REASON_NMI,		/* Non-maskable interrupt; regs valid */
152	KDB_REASON_RECURSE,	/* Recursive entry to kdb;
153				 * regs probably valid */
154	KDB_REASON_SSTEP,	/* Single Step trap. - regs valid */
155	KDB_REASON_SYSTEM_NMI,	/* In NMI due to SYSTEM cmd; regs valid */
156} kdb_reason_t;
157
158enum kdb_msgsrc {
159	KDB_MSGSRC_INTERNAL, /* direct call to kdb_printf() */
160	KDB_MSGSRC_PRINTK, /* trapped from printk() */
161};
162
163extern int kdb_trap_printk;
164extern int kdb_printf_cpu;
165extern __printf(2, 0) int vkdb_printf(enum kdb_msgsrc src, const char *fmt,
166				      va_list args);
167extern __printf(1, 2) int kdb_printf(const char *, ...);
168typedef __printf(1, 2) int (*kdb_printf_t)(const char *, ...);
169
170extern void kdb_init(int level);
171
172/* Access to kdb specific polling devices */
173typedef int (*get_char_func)(void);
174extern get_char_func kdb_poll_funcs[];
175extern int kdb_get_kbd_char(void);
176
177static inline
178int kdb_process_cpu(const struct task_struct *p)
179{
180	unsigned int cpu = task_cpu(p);
181	if (cpu > num_possible_cpus())
182		cpu = 0;
183	return cpu;
184}
185
 
 
186#ifdef CONFIG_KALLSYMS
187extern const char *kdb_walk_kallsyms(loff_t *pos);
188#else /* ! CONFIG_KALLSYMS */
189static inline const char *kdb_walk_kallsyms(loff_t *pos)
190{
191	return NULL;
192}
193#endif /* ! CONFIG_KALLSYMS */
194
195/* Dynamic kdb shell command registration */
196extern int kdb_register(char *, kdb_func_t, char *, char *, short);
197extern int kdb_register_flags(char *, kdb_func_t, char *, char *,
198			      short, kdb_cmdflags_t);
199extern int kdb_unregister(char *);
200#else /* ! CONFIG_KGDB_KDB */
201static inline __printf(1, 2) int kdb_printf(const char *fmt, ...) { return 0; }
202static inline void kdb_init(int level) {}
203static inline int kdb_register(char *cmd, kdb_func_t func, char *usage,
204			       char *help, short minlen) { return 0; }
205static inline int kdb_register_flags(char *cmd, kdb_func_t func, char *usage,
206				     char *help, short minlen,
207				     kdb_cmdflags_t flags) { return 0; }
208static inline int kdb_unregister(char *cmd) { return 0; }
209#endif	/* CONFIG_KGDB_KDB */
210enum {
211	KDB_NOT_INITIALIZED,
212	KDB_INIT_EARLY,
213	KDB_INIT_FULL,
214};
215
216extern int kdbgetintenv(const char *, int *);
217extern int kdb_set(int, const char **);
218
219#endif	/* !_KDB_H */
v3.5.6
  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 <linux/atomic.h>
 20
 21#define KDB_POLL_FUNC_MAX	5
 22extern int kdb_poll_idx;
 23
 24/*
 25 * kdb_initial_cpu is initialized to -1, and is set to the cpu
 26 * number whenever the kernel debugger is entered.
 27 */
 28extern int kdb_initial_cpu;
 29extern atomic_t kdb_event;
 30
 31/* Types and messages used for dynamically added kdb shell commands */
 32
 33#define KDB_MAXARGS    16 /* Maximum number of arguments to a function  */
 34
 35typedef enum {
 36	KDB_REPEAT_NONE = 0,	/* Do not repeat this command */
 37	KDB_REPEAT_NO_ARGS,	/* Repeat the command without arguments */
 38	KDB_REPEAT_WITH_ARGS,	/* Repeat the command including its arguments */
 39} kdb_repeat_t;
 40
 41typedef int (*kdb_func_t)(int, const char **);
 42
 43/* KDB return codes from a command or internal kdb function */
 44#define KDB_NOTFOUND	(-1)
 45#define KDB_ARGCOUNT	(-2)
 46#define KDB_BADWIDTH	(-3)
 47#define KDB_BADRADIX	(-4)
 48#define KDB_NOTENV	(-5)
 49#define KDB_NOENVVALUE	(-6)
 50#define KDB_NOTIMP	(-7)
 51#define KDB_ENVFULL	(-8)
 52#define KDB_ENVBUFFULL	(-9)
 53#define KDB_TOOMANYBPT	(-10)
 54#define KDB_TOOMANYDBREGS (-11)
 55#define KDB_DUPBPT	(-12)
 56#define KDB_BPTNOTFOUND	(-13)
 57#define KDB_BADMODE	(-14)
 58#define KDB_BADINT	(-15)
 59#define KDB_INVADDRFMT  (-16)
 60#define KDB_BADREG      (-17)
 61#define KDB_BADCPUNUM   (-18)
 62#define KDB_BADLENGTH	(-19)
 63#define KDB_NOBP	(-20)
 64#define KDB_BADADDR	(-21)
 
 65
 66/*
 67 * kdb_diemsg
 68 *
 69 *	Contains a pointer to the last string supplied to the
 70 *	kernel 'die' panic function.
 71 */
 72extern const char *kdb_diemsg;
 73
 74#define KDB_FLAG_EARLYKDB	(1 << 0) /* set from boot parameter kdb=early */
 75#define KDB_FLAG_CATASTROPHIC	(1 << 1) /* A catastrophic event has occurred */
 76#define KDB_FLAG_CMD_INTERRUPT	(1 << 2) /* Previous command was interrupted */
 77#define KDB_FLAG_NOIPI		(1 << 3) /* Do not send IPIs */
 78#define KDB_FLAG_ONLY_DO_DUMP	(1 << 4) /* Only do a dump, used when
 79					  * kdb is off */
 80#define KDB_FLAG_NO_CONSOLE	(1 << 5) /* No console is available,
 81					  * kdb is disabled */
 82#define KDB_FLAG_NO_VT_CONSOLE	(1 << 6) /* No VT console is available, do
 83					  * not use keyboard */
 84#define KDB_FLAG_NO_I8042	(1 << 7) /* No i8042 chip is available, do
 85					  * not use keyboard */
 86
 87extern int kdb_flags;	/* Global flags, see kdb_state for per cpu state */
 88
 89extern void kdb_save_flags(void);
 90extern void kdb_restore_flags(void);
 91
 92#define KDB_FLAG(flag)		(kdb_flags & KDB_FLAG_##flag)
 93#define KDB_FLAG_SET(flag)	((void)(kdb_flags |= KDB_FLAG_##flag))
 94#define KDB_FLAG_CLEAR(flag)	((void)(kdb_flags &= ~KDB_FLAG_##flag))
 95
 96/*
 97 * External entry point for the kernel debugger.  The pt_regs
 98 * at the time of entry are supplied along with the reason for
 99 * entry to the kernel debugger.
100 */
101
102typedef enum {
103	KDB_REASON_ENTER = 1,	/* KDB_ENTER() trap/fault - regs valid */
104	KDB_REASON_ENTER_SLAVE,	/* KDB_ENTER_SLAVE() trap/fault - regs valid */
105	KDB_REASON_BREAK,	/* Breakpoint inst. - regs valid */
106	KDB_REASON_DEBUG,	/* Debug Fault - regs valid */
107	KDB_REASON_OOPS,	/* Kernel Oops - regs valid */
108	KDB_REASON_SWITCH,	/* CPU switch - regs valid*/
109	KDB_REASON_KEYBOARD,	/* Keyboard entry - regs valid */
110	KDB_REASON_NMI,		/* Non-maskable interrupt; regs valid */
111	KDB_REASON_RECURSE,	/* Recursive entry to kdb;
112				 * regs probably valid */
113	KDB_REASON_SSTEP,	/* Single Step trap. - regs valid */
 
114} kdb_reason_t;
115
 
 
 
 
 
116extern int kdb_trap_printk;
117extern __printf(1, 0) int vkdb_printf(const char *fmt, va_list args);
 
 
118extern __printf(1, 2) int kdb_printf(const char *, ...);
119typedef __printf(1, 2) int (*kdb_printf_t)(const char *, ...);
120
121extern void kdb_init(int level);
122
123/* Access to kdb specific polling devices */
124typedef int (*get_char_func)(void);
125extern get_char_func kdb_poll_funcs[];
126extern int kdb_get_kbd_char(void);
127
128static inline
129int kdb_process_cpu(const struct task_struct *p)
130{
131	unsigned int cpu = task_thread_info(p)->cpu;
132	if (cpu > num_possible_cpus())
133		cpu = 0;
134	return cpu;
135}
136
137/* kdb access to register set for stack dumping */
138extern struct pt_regs *kdb_current_regs;
139#ifdef CONFIG_KALLSYMS
140extern const char *kdb_walk_kallsyms(loff_t *pos);
141#else /* ! CONFIG_KALLSYMS */
142static inline const char *kdb_walk_kallsyms(loff_t *pos)
143{
144	return NULL;
145}
146#endif /* ! CONFIG_KALLSYMS */
147
148/* Dynamic kdb shell command registration */
149extern int kdb_register(char *, kdb_func_t, char *, char *, short);
150extern int kdb_register_repeat(char *, kdb_func_t, char *, char *,
151			       short, kdb_repeat_t);
152extern int kdb_unregister(char *);
153#else /* ! CONFIG_KGDB_KDB */
154#define kdb_printf(...)
155#define kdb_init(x)
156#define kdb_register(...)
157#define kdb_register_repeat(...)
158#define kdb_uregister(x)
 
 
 
159#endif	/* CONFIG_KGDB_KDB */
160enum {
161	KDB_NOT_INITIALIZED,
162	KDB_INIT_EARLY,
163	KDB_INIT_FULL,
164};
165
166extern int kdbgetintenv(const char *, int *);
167extern int kdb_set(int, const char **);
168
169#endif	/* !_KDB_H */