Commit 00370b8f authored by Matt Klein's avatar Matt Klein Committed by Jason Wessel

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: default avatarMatt Klein <mklein@twitter.com>
Signed-off-by: default avatarJason Wessel <jason.wessel@windriver.com>
parent 5f784f79
...@@ -72,6 +72,8 @@ extern int dbg_kdb_mode; ...@@ -72,6 +72,8 @@ extern int dbg_kdb_mode;
#ifdef CONFIG_KGDB_KDB #ifdef CONFIG_KGDB_KDB
extern int kdb_stub(struct kgdb_state *ks); extern int kdb_stub(struct kgdb_state *ks);
extern int kdb_parse(const char *cmdstr); extern int kdb_parse(const char *cmdstr);
extern int kdb_common_init_state(struct kgdb_state *ks);
extern int kdb_common_deinit_state(void);
#else /* ! CONFIG_KGDB_KDB */ #else /* ! CONFIG_KGDB_KDB */
static inline int kdb_stub(struct kgdb_state *ks) static inline int kdb_stub(struct kgdb_state *ks)
{ {
......
...@@ -782,7 +782,10 @@ static void gdb_cmd_query(struct kgdb_state *ks) ...@@ -782,7 +782,10 @@ static void gdb_cmd_query(struct kgdb_state *ks)
len = len / 2; len = len / 2;
remcom_out_buffer[len++] = 0; remcom_out_buffer[len++] = 0;
kdb_common_init_state(ks);
kdb_parse(remcom_out_buffer); kdb_parse(remcom_out_buffer);
kdb_common_deinit_state();
strcpy(remcom_out_buffer, "OK"); strcpy(remcom_out_buffer, "OK");
} }
break; break;
......
...@@ -34,6 +34,22 @@ EXPORT_SYMBOL_GPL(kdb_poll_idx); ...@@ -34,6 +34,22 @@ EXPORT_SYMBOL_GPL(kdb_poll_idx);
static struct kgdb_state *kdb_ks; static struct kgdb_state *kdb_ks;
int kdb_common_init_state(struct kgdb_state *ks)
{
kdb_initial_cpu = atomic_read(&kgdb_active);
kdb_current_task = kgdb_info[ks->cpu].task;
kdb_current_regs = kgdb_info[ks->cpu].debuggerinfo;
return 0;
}
int kdb_common_deinit_state(void)
{
kdb_initial_cpu = -1;
kdb_current_task = NULL;
kdb_current_regs = NULL;
return 0;
}
int kdb_stub(struct kgdb_state *ks) int kdb_stub(struct kgdb_state *ks)
{ {
int error = 0; int error = 0;
...@@ -94,9 +110,7 @@ int kdb_stub(struct kgdb_state *ks) ...@@ -94,9 +110,7 @@ int kdb_stub(struct kgdb_state *ks)
} }
/* Set initial kdb state variables */ /* Set initial kdb state variables */
KDB_STATE_CLEAR(KGDB_TRANS); KDB_STATE_CLEAR(KGDB_TRANS);
kdb_initial_cpu = atomic_read(&kgdb_active); kdb_common_init_state(ks);
kdb_current_task = kgdb_info[ks->cpu].task;
kdb_current_regs = kgdb_info[ks->cpu].debuggerinfo;
/* Remove any breakpoints as needed by kdb and clear single step */ /* Remove any breakpoints as needed by kdb and clear single step */
kdb_bp_remove(); kdb_bp_remove();
KDB_STATE_CLEAR(DOING_SS); KDB_STATE_CLEAR(DOING_SS);
...@@ -125,9 +139,7 @@ int kdb_stub(struct kgdb_state *ks) ...@@ -125,9 +139,7 @@ int kdb_stub(struct kgdb_state *ks)
* Upon exit from the kdb main loop setup break points and restart * Upon exit from the kdb main loop setup break points and restart
* the system based on the requested continue state * the system based on the requested continue state
*/ */
kdb_initial_cpu = -1; kdb_common_deinit_state();
kdb_current_task = NULL;
kdb_current_regs = NULL;
KDB_STATE_CLEAR(PAGER); KDB_STATE_CLEAR(PAGER);
kdbnearsym_cleanup(); kdbnearsym_cleanup();
if (error == KDB_CMD_KGDB) { if (error == KDB_CMD_KGDB) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment