aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/debug/kdb
diff options
context:
space:
mode:
authorJason Wessel <jason.wessel@windriver.com>2011-05-23 14:17:41 -0400
committerJason Wessel <jason.wessel@windriver.com>2011-08-01 14:23:59 -0400
commitf679c4985bb2e7de9d39a5d40b6031361c4ad861 (patch)
tree9750abdc0f876f38642c06c188b152324c512fdb /kernel/debug/kdb
parent3bdb65ec95e6cccffc40102d7c003047c45da90c (diff)
kdb,kgdb: Implement switch and pass buffer from kdb -> gdb
When switching from kdb mode to kgdb mode packets were getting lost depending on the size of the fifo queue of the serial chip. When gdb initially connects if it is in kdb mode it should entirely send any character buffer over to the gdbstub when switching connections. Previously kdb was zero'ing out the character buffer and this could lead to gdb failing to connect at all, or a lengthy pause could occur on the initial connect. Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
Diffstat (limited to 'kernel/debug/kdb')
-rw-r--r--kernel/debug/kdb/kdb_debugger.c17
-rw-r--r--kernel/debug/kdb/kdb_io.c10
-rw-r--r--kernel/debug/kdb/kdb_private.h1
3 files changed, 14 insertions, 14 deletions
diff --git a/kernel/debug/kdb/kdb_debugger.c b/kernel/debug/kdb/kdb_debugger.c
index dd0b1b7dd02c..fe422d275782 100644
--- a/kernel/debug/kdb/kdb_debugger.c
+++ b/kernel/debug/kdb/kdb_debugger.c
@@ -30,6 +30,8 @@ EXPORT_SYMBOL_GPL(kdb_poll_funcs);
30int kdb_poll_idx = 1; 30int kdb_poll_idx = 1;
31EXPORT_SYMBOL_GPL(kdb_poll_idx); 31EXPORT_SYMBOL_GPL(kdb_poll_idx);
32 32
33static struct kgdb_state *kdb_ks;
34
33int kdb_stub(struct kgdb_state *ks) 35int kdb_stub(struct kgdb_state *ks)
34{ 36{
35 int error = 0; 37 int error = 0;
@@ -39,6 +41,7 @@ int kdb_stub(struct kgdb_state *ks)
39 kdb_dbtrap_t db_result = KDB_DB_NOBPT; 41 kdb_dbtrap_t db_result = KDB_DB_NOBPT;
40 int i; 42 int i;
41 43
44 kdb_ks = ks;
42 if (KDB_STATE(REENTRY)) { 45 if (KDB_STATE(REENTRY)) {
43 reason = KDB_REASON_SWITCH; 46 reason = KDB_REASON_SWITCH;
44 KDB_STATE_CLEAR(REENTRY); 47 KDB_STATE_CLEAR(REENTRY);
@@ -124,16 +127,6 @@ int kdb_stub(struct kgdb_state *ks)
124 kdbnearsym_cleanup(); 127 kdbnearsym_cleanup();
125 if (error == KDB_CMD_KGDB) { 128 if (error == KDB_CMD_KGDB) {
126 if (KDB_STATE(DOING_KGDB) || KDB_STATE(DOING_KGDB2)) { 129 if (KDB_STATE(DOING_KGDB) || KDB_STATE(DOING_KGDB2)) {
127 /*
128 * This inteface glue which allows kdb to transition in into
129 * the gdb stub. In order to do this the '?' or '' gdb serial
130 * packet response is processed here. And then control is
131 * passed to the gdbstub.
132 */
133 if (KDB_STATE(DOING_KGDB))
134 gdbstub_state(ks, "?");
135 else
136 gdbstub_state(ks, "");
137 KDB_STATE_CLEAR(DOING_KGDB); 130 KDB_STATE_CLEAR(DOING_KGDB);
138 KDB_STATE_CLEAR(DOING_KGDB2); 131 KDB_STATE_CLEAR(DOING_KGDB2);
139 } 132 }
@@ -166,3 +159,7 @@ int kdb_stub(struct kgdb_state *ks)
166 return kgdb_info[ks->cpu].ret_state; 159 return kgdb_info[ks->cpu].ret_state;
167} 160}
168 161
162void kdb_gdb_state_pass(char *buf)
163{
164 gdbstub_state(kdb_ks, buf);
165}
diff --git a/kernel/debug/kdb/kdb_io.c b/kernel/debug/kdb/kdb_io.c
index 96fdaac46a80..bd233264b29f 100644
--- a/kernel/debug/kdb/kdb_io.c
+++ b/kernel/debug/kdb/kdb_io.c
@@ -35,8 +35,8 @@ static void kgdb_transition_check(char *buffer)
35{ 35{
36 int slen = strlen(buffer); 36 int slen = strlen(buffer);
37 if (strncmp(buffer, "$?#3f", slen) != 0 && 37 if (strncmp(buffer, "$?#3f", slen) != 0 &&
38 strncmp(buffer, "$qSupported#37", slen) != 0 && 38 strncmp(buffer, "$qSupported", slen) != 0 &&
39 strncmp(buffer, "+$qSupported#37", slen) != 0) { 39 strncmp(buffer, "+$qSupported", slen) != 0) {
40 KDB_STATE_SET(KGDB_TRANS); 40 KDB_STATE_SET(KGDB_TRANS);
41 kdb_printf("%s", buffer); 41 kdb_printf("%s", buffer);
42 } 42 }
@@ -390,12 +390,14 @@ poll_again:
390 /* Special escape to kgdb */ 390 /* Special escape to kgdb */
391 if (lastchar - buffer >= 5 && 391 if (lastchar - buffer >= 5 &&
392 strcmp(lastchar - 5, "$?#3f") == 0) { 392 strcmp(lastchar - 5, "$?#3f") == 0) {
393 kdb_gdb_state_pass(lastchar - 5);
393 strcpy(buffer, "kgdb"); 394 strcpy(buffer, "kgdb");
394 KDB_STATE_SET(DOING_KGDB); 395 KDB_STATE_SET(DOING_KGDB);
395 return buffer; 396 return buffer;
396 } 397 }
397 if (lastchar - buffer >= 14 && 398 if (lastchar - buffer >= 11 &&
398 strcmp(lastchar - 14, "$qSupported#37") == 0) { 399 strcmp(lastchar - 11, "$qSupported") == 0) {
400 kdb_gdb_state_pass(lastchar - 11);
399 strcpy(buffer, "kgdb"); 401 strcpy(buffer, "kgdb");
400 KDB_STATE_SET(DOING_KGDB2); 402 KDB_STATE_SET(DOING_KGDB2);
401 return buffer; 403 return buffer;
diff --git a/kernel/debug/kdb/kdb_private.h b/kernel/debug/kdb/kdb_private.h
index 35d69ed1dfb5..03d332e63442 100644
--- a/kernel/debug/kdb/kdb_private.h
+++ b/kernel/debug/kdb/kdb_private.h
@@ -218,6 +218,7 @@ extern void kdb_print_nameval(const char *name, unsigned long val);
218extern void kdb_send_sig_info(struct task_struct *p, struct siginfo *info); 218extern void kdb_send_sig_info(struct task_struct *p, struct siginfo *info);
219extern void kdb_meminfo_proc_show(void); 219extern void kdb_meminfo_proc_show(void);
220extern char *kdb_getstr(char *, size_t, char *); 220extern char *kdb_getstr(char *, size_t, char *);
221extern void kdb_gdb_state_pass(char *buf);
221 222
222/* Defines for kdb_symbol_print */ 223/* Defines for kdb_symbol_print */
223#define KDB_SP_SPACEB 0x0001 /* Space before string */ 224#define KDB_SP_SPACEB 0x0001 /* Space before string */