aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Wessel <jason.wessel@windriver.com>2010-10-11 11:20:14 -0400
committerJason Wessel <jason.wessel@windriver.com>2010-10-22 16:34:11 -0400
commitf7030bbc446430ecd12c9ad02cf0ea94934e5f91 (patch)
tree1a281ffa0c2686fa898081781a0c7b9bbc2d5b00
parentfb70b5888b70b0b50f738fbfc019445493112eb1 (diff)
kdb: Allow kernel loadable modules to add kdb shell functions
In order to allow kernel modules to dynamically add a command to the kdb shell the kdb_register, kdb_register_repeat, kdb_unregister, and kdb_printf need to be exported as GPL symbols. Any kernel module that adds a dynamic kdb shell function should only need to include linux/kdb.h. Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
-rw-r--r--include/linux/kdb.h43
-rw-r--r--kernel/debug/kdb/kdb_io.c2
-rw-r--r--kernel/debug/kdb/kdb_main.c4
-rw-r--r--kernel/debug/kdb/kdb_private.h39
4 files changed, 48 insertions, 40 deletions
diff --git a/include/linux/kdb.h b/include/linux/kdb.h
index ea6e5244ed3f..deda197ced62 100644
--- a/include/linux/kdb.h
+++ b/include/linux/kdb.h
@@ -28,6 +28,41 @@ extern int kdb_poll_idx;
28extern int kdb_initial_cpu; 28extern int kdb_initial_cpu;
29extern atomic_t kdb_event; 29extern atomic_t kdb_event;
30 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
31/* 66/*
32 * kdb_diemsg 67 * kdb_diemsg
33 * 68 *
@@ -105,9 +140,17 @@ int kdb_process_cpu(const struct task_struct *p)
105/* kdb access to register set for stack dumping */ 140/* kdb access to register set for stack dumping */
106extern struct pt_regs *kdb_current_regs; 141extern struct pt_regs *kdb_current_regs;
107 142
143/* Dynamic kdb shell command registration */
144extern int kdb_register(char *, kdb_func_t, char *, char *, short);
145extern int kdb_register_repeat(char *, kdb_func_t, char *, char *,
146 short, kdb_repeat_t);
147extern int kdb_unregister(char *);
108#else /* ! CONFIG_KGDB_KDB */ 148#else /* ! CONFIG_KGDB_KDB */
109#define kdb_printf(...) 149#define kdb_printf(...)
110#define kdb_init(x) 150#define kdb_init(x)
151#define kdb_register(...)
152#define kdb_register_repeat(...)
153#define kdb_uregister(x)
111#endif /* CONFIG_KGDB_KDB */ 154#endif /* CONFIG_KGDB_KDB */
112enum { 155enum {
113 KDB_NOT_INITIALIZED, 156 KDB_NOT_INITIALIZED,
diff --git a/kernel/debug/kdb/kdb_io.c b/kernel/debug/kdb/kdb_io.c
index c9b7f4f90bba..96fdaac46a80 100644
--- a/kernel/debug/kdb/kdb_io.c
+++ b/kernel/debug/kdb/kdb_io.c
@@ -823,4 +823,4 @@ int kdb_printf(const char *fmt, ...)
823 823
824 return r; 824 return r;
825} 825}
826 826EXPORT_SYMBOL_GPL(kdb_printf);
diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
index caf057a3de0e..5448990a299e 100644
--- a/kernel/debug/kdb/kdb_main.c
+++ b/kernel/debug/kdb/kdb_main.c
@@ -2783,6 +2783,8 @@ int kdb_register_repeat(char *cmd,
2783 2783
2784 return 0; 2784 return 0;
2785} 2785}
2786EXPORT_SYMBOL_GPL(kdb_register_repeat);
2787
2786 2788
2787/* 2789/*
2788 * kdb_register - Compatibility register function for commands that do 2790 * kdb_register - Compatibility register function for commands that do
@@ -2805,6 +2807,7 @@ int kdb_register(char *cmd,
2805 return kdb_register_repeat(cmd, func, usage, help, minlen, 2807 return kdb_register_repeat(cmd, func, usage, help, minlen,
2806 KDB_REPEAT_NONE); 2808 KDB_REPEAT_NONE);
2807} 2809}
2810EXPORT_SYMBOL_GPL(kdb_register);
2808 2811
2809/* 2812/*
2810 * kdb_unregister - This function is used to unregister a kernel 2813 * kdb_unregister - This function is used to unregister a kernel
@@ -2833,6 +2836,7 @@ int kdb_unregister(char *cmd)
2833 /* Couldn't find it. */ 2836 /* Couldn't find it. */
2834 return 1; 2837 return 1;
2835} 2838}
2839EXPORT_SYMBOL_GPL(kdb_unregister);
2836 2840
2837/* Initialize the kdb command table. */ 2841/* Initialize the kdb command table. */
2838static void __init kdb_inittab(void) 2842static void __init kdb_inittab(void)
diff --git a/kernel/debug/kdb/kdb_private.h b/kernel/debug/kdb/kdb_private.h
index be775f7e81e0..1921e6e4c0bc 100644
--- a/kernel/debug/kdb/kdb_private.h
+++ b/kernel/debug/kdb/kdb_private.h
@@ -15,29 +15,6 @@
15#include <linux/kgdb.h> 15#include <linux/kgdb.h>
16#include "../debug_core.h" 16#include "../debug_core.h"
17 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. */ 18/* Kernel Debugger Command codes. Must not overlap with error codes. */
42#define KDB_CMD_GO (-1001) 19#define KDB_CMD_GO (-1001)
43#define KDB_CMD_CPU (-1002) 20#define KDB_CMD_CPU (-1002)
@@ -93,17 +70,6 @@
93 */ 70 */
94#define KDB_MAXBPT 16 71#define KDB_MAXBPT 16
95 72
96/* Maximum number of arguments to a function */
97#define KDB_MAXARGS 16
98
99typedef 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
105typedef int (*kdb_func_t)(int, const char **);
106
107/* Symbol table format returned by kallsyms. */ 73/* Symbol table format returned by kallsyms. */
108typedef struct __ksymtab { 74typedef struct __ksymtab {
109 unsigned long value; /* Address of symbol */ 75 unsigned long value; /* Address of symbol */
@@ -123,11 +89,6 @@ extern int kallsyms_symbol_next(char *prefix_name, int flag);
123extern int kallsyms_symbol_complete(char *prefix_name, int max_len); 89extern int kallsyms_symbol_complete(char *prefix_name, int max_len);
124 90
125/* Exported Symbols for kernel loadable modules to use. */ 91/* Exported Symbols for kernel loadable modules to use. */
126extern int kdb_register(char *, kdb_func_t, char *, char *, short);
127extern int kdb_register_repeat(char *, kdb_func_t, char *, char *,
128 short, kdb_repeat_t);
129extern int kdb_unregister(char *);
130
131extern int kdb_getarea_size(void *, unsigned long, size_t); 92extern int kdb_getarea_size(void *, unsigned long, size_t);
132extern int kdb_putarea_size(unsigned long, void *, size_t); 93extern int kdb_putarea_size(unsigned long, void *, size_t);
133 94