aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorMatt Klein <mklein@twitter.com>2013-01-02 16:20:49 -0500
committerJason Wessel <jason.wessel@windriver.com>2013-03-02 09:52:17 -0500
commit00370b8f8dd6e3171b8202f9c5187a5f73e99497 (patch)
tree5d15f25177a0e4f92e664b27658a48dfeadbbab7 /kernel
parent5f784f798c1a6367d314b3ea5d742a5dcc8dc7ca (diff)
kdb: Setup basic kdb state before invoking commands via kgdb
Although invasive kdb commands are not supported via kgdb, some useful non-invasive commands like bt* require basic kdb state to be setup before calling into the kdb code. Factor out some of this code and call it before and after executing kdb commands via kgdb. Signed-off-by: Matt Klein <mklein@twitter.com> Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/debug/debug_core.h2
-rw-r--r--kernel/debug/gdbstub.c3
-rw-r--r--kernel/debug/kdb/kdb_debugger.c24
3 files changed, 23 insertions, 6 deletions
diff --git a/kernel/debug/debug_core.h b/kernel/debug/debug_core.h
index 3494c28a7e7a..2235967e78b0 100644
--- a/kernel/debug/debug_core.h
+++ b/kernel/debug/debug_core.h
@@ -72,6 +72,8 @@ extern int dbg_kdb_mode;
72#ifdef CONFIG_KGDB_KDB 72#ifdef CONFIG_KGDB_KDB
73extern int kdb_stub(struct kgdb_state *ks); 73extern int kdb_stub(struct kgdb_state *ks);
74extern int kdb_parse(const char *cmdstr); 74extern int kdb_parse(const char *cmdstr);
75extern int kdb_common_init_state(struct kgdb_state *ks);
76extern int kdb_common_deinit_state(void);
75#else /* ! CONFIG_KGDB_KDB */ 77#else /* ! CONFIG_KGDB_KDB */
76static inline int kdb_stub(struct kgdb_state *ks) 78static inline int kdb_stub(struct kgdb_state *ks)
77{ 79{
diff --git a/kernel/debug/gdbstub.c b/kernel/debug/gdbstub.c
index ce615e064482..ea5e3edb6915 100644
--- a/kernel/debug/gdbstub.c
+++ b/kernel/debug/gdbstub.c
@@ -782,7 +782,10 @@ static void gdb_cmd_query(struct kgdb_state *ks)
782 len = len / 2; 782 len = len / 2;
783 remcom_out_buffer[len++] = 0; 783 remcom_out_buffer[len++] = 0;
784 784
785 kdb_common_init_state(ks);
785 kdb_parse(remcom_out_buffer); 786 kdb_parse(remcom_out_buffer);
787 kdb_common_deinit_state();
788
786 strcpy(remcom_out_buffer, "OK"); 789 strcpy(remcom_out_buffer, "OK");
787 } 790 }
788 break; 791 break;
diff --git a/kernel/debug/kdb/kdb_debugger.c b/kernel/debug/kdb/kdb_debugger.c
index be7b33b73d30..d04a6ce2d3b7 100644
--- a/kernel/debug/kdb/kdb_debugger.c
+++ b/kernel/debug/kdb/kdb_debugger.c
@@ -34,6 +34,22 @@ EXPORT_SYMBOL_GPL(kdb_poll_idx);
34 34
35static struct kgdb_state *kdb_ks; 35static struct kgdb_state *kdb_ks;
36 36
37int kdb_common_init_state(struct kgdb_state *ks)
38{
39 kdb_initial_cpu = atomic_read(&kgdb_active);
40 kdb_current_task = kgdb_info[ks->cpu].task;
41 kdb_current_regs = kgdb_info[ks->cpu].debuggerinfo;
42 return 0;
43}
44
45int kdb_common_deinit_state(void)
46{
47 kdb_initial_cpu = -1;
48 kdb_current_task = NULL;
49 kdb_current_regs = NULL;
50 return 0;
51}
52
37int kdb_stub(struct kgdb_state *ks) 53int kdb_stub(struct kgdb_state *ks)
38{ 54{
39 int error = 0; 55 int error = 0;
@@ -94,9 +110,7 @@ int kdb_stub(struct kgdb_state *ks)
94 } 110 }
95 /* Set initial kdb state variables */ 111 /* Set initial kdb state variables */
96 KDB_STATE_CLEAR(KGDB_TRANS); 112 KDB_STATE_CLEAR(KGDB_TRANS);
97 kdb_initial_cpu = atomic_read(&kgdb_active); 113 kdb_common_init_state(ks);
98 kdb_current_task = kgdb_info[ks->cpu].task;
99 kdb_current_regs = kgdb_info[ks->cpu].debuggerinfo;
100 /* Remove any breakpoints as needed by kdb and clear single step */ 114 /* Remove any breakpoints as needed by kdb and clear single step */
101 kdb_bp_remove(); 115 kdb_bp_remove();
102 KDB_STATE_CLEAR(DOING_SS); 116 KDB_STATE_CLEAR(DOING_SS);
@@ -125,9 +139,7 @@ int kdb_stub(struct kgdb_state *ks)
125 * Upon exit from the kdb main loop setup break points and restart 139 * Upon exit from the kdb main loop setup break points and restart
126 * the system based on the requested continue state 140 * the system based on the requested continue state
127 */ 141 */
128 kdb_initial_cpu = -1; 142 kdb_common_deinit_state();
129 kdb_current_task = NULL;
130 kdb_current_regs = NULL;
131 KDB_STATE_CLEAR(PAGER); 143 KDB_STATE_CLEAR(PAGER);
132 kdbnearsym_cleanup(); 144 kdbnearsym_cleanup();
133 if (error == KDB_CMD_KGDB) { 145 if (error == KDB_CMD_KGDB) {