Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jwessel/linux-2.6-kgdb

* 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jwessel/linux-2.6-kgdb:
kdb,kgdb: Allow arbitrary kgdb magic knock sequences
kdb: Remove all references to DOING_KGDB2
kdb,kgdb: Implement switch and pass buffer from kdb -> gdb
kdb: cleanup unused variables missed in the original kdb merge

+53 -42
+15 -7
kernel/debug/gdbstub.c
··· 42 42 /* Our I/O buffers. */ 43 43 static char remcom_in_buffer[BUFMAX]; 44 44 static char remcom_out_buffer[BUFMAX]; 45 + static int gdbstub_use_prev_in_buf; 46 + static int gdbstub_prev_in_buf_pos; 45 47 46 48 /* Storage for the registers, in GDB format. */ 47 49 static unsigned long gdb_regs[(NUMREGBYTES + ··· 59 57 { 60 58 int ret = -1; 61 59 int i; 60 + 61 + if (unlikely(gdbstub_use_prev_in_buf)) { 62 + if (gdbstub_prev_in_buf_pos < gdbstub_use_prev_in_buf) 63 + return remcom_in_buffer[gdbstub_prev_in_buf_pos++]; 64 + else 65 + gdbstub_use_prev_in_buf = 0; 66 + } 62 67 63 68 /* poll any additional I/O interfaces that are defined */ 64 69 while (ret < 0) ··· 118 109 buffer[count] = ch; 119 110 count = count + 1; 120 111 } 121 - buffer[count] = 0; 122 112 123 113 if (ch == '#') { 124 114 xmitcsum = hex_to_bin(gdbstub_read_wait()) << 4; ··· 132 124 if (dbg_io_ops->flush) 133 125 dbg_io_ops->flush(); 134 126 } 127 + buffer[count] = 0; 135 128 } while (checksum != xmitcsum); 136 129 } 137 130 ··· 1091 1082 case 'c': 1092 1083 strcpy(remcom_in_buffer, cmd); 1093 1084 return 0; 1094 - case '?': 1095 - gdb_cmd_status(ks); 1096 - break; 1097 - case '\0': 1098 - strcpy(remcom_out_buffer, ""); 1099 - break; 1085 + case '$': 1086 + strcpy(remcom_in_buffer, cmd); 1087 + gdbstub_use_prev_in_buf = strlen(remcom_in_buffer); 1088 + gdbstub_prev_in_buf_pos = 0; 1089 + return 0; 1100 1090 } 1101 1091 dbg_io_ops->write_char('+'); 1102 1092 put_packet(remcom_out_buffer);
+2 -3
kernel/debug/kdb/kdb_bt.c
··· 112 112 unsigned long addr; 113 113 long offset; 114 114 115 - kdbgetintenv("BTARGS", &argcount); /* Arguments to print */ 116 - kdbgetintenv("BTAPROMPT", &btaprompt); /* Prompt after each 117 - * proc in bta */ 115 + /* Prompt after each proc in bta */ 116 + kdbgetintenv("BTAPROMPT", &btaprompt); 118 117 119 118 if (strcmp(argv[0], "bta") == 0) { 120 119 struct task_struct *g, *p;
-4
kernel/debug/kdb/kdb_cmds
··· 18 18 endefcmd 19 19 20 20 defcmd dumpall "" "First line debugging" 21 - set BTSYMARG 1 22 - set BTARGS 9 23 21 pid R 24 22 -dumpcommon 25 23 -bta 26 24 endefcmd 27 25 28 26 defcmd dumpcpu "" "Same as dumpall but only tasks on cpus" 29 - set BTSYMARG 1 30 - set BTARGS 9 31 27 pid R 32 28 -dumpcommon 33 29 -btc
+8 -13
kernel/debug/kdb/kdb_debugger.c
··· 30 30 int kdb_poll_idx = 1; 31 31 EXPORT_SYMBOL_GPL(kdb_poll_idx); 32 32 33 + static struct kgdb_state *kdb_ks; 34 + 33 35 int kdb_stub(struct kgdb_state *ks) 34 36 { 35 37 int error = 0; ··· 41 39 kdb_dbtrap_t db_result = KDB_DB_NOBPT; 42 40 int i; 43 41 42 + kdb_ks = ks; 44 43 if (KDB_STATE(REENTRY)) { 45 44 reason = KDB_REASON_SWITCH; 46 45 KDB_STATE_CLEAR(REENTRY); ··· 126 123 KDB_STATE_CLEAR(PAGER); 127 124 kdbnearsym_cleanup(); 128 125 if (error == KDB_CMD_KGDB) { 129 - if (KDB_STATE(DOING_KGDB) || KDB_STATE(DOING_KGDB2)) { 130 - /* 131 - * This inteface glue which allows kdb to transition in into 132 - * the gdb stub. In order to do this the '?' or '' gdb serial 133 - * packet response is processed here. And then control is 134 - * passed to the gdbstub. 135 - */ 136 - if (KDB_STATE(DOING_KGDB)) 137 - gdbstub_state(ks, "?"); 138 - else 139 - gdbstub_state(ks, ""); 126 + if (KDB_STATE(DOING_KGDB)) 140 127 KDB_STATE_CLEAR(DOING_KGDB); 141 - KDB_STATE_CLEAR(DOING_KGDB2); 142 - } 143 128 return DBG_PASS_EVENT; 144 129 } 145 130 kdb_bp_install(ks->linux_regs); ··· 157 166 return kgdb_info[ks->cpu].ret_state; 158 167 } 159 168 169 + void kdb_gdb_state_pass(char *buf) 170 + { 171 + gdbstub_state(kdb_ks, buf); 172 + }
+25 -11
kernel/debug/kdb/kdb_io.c
··· 31 31 32 32 int kdb_trap_printk; 33 33 34 - static void kgdb_transition_check(char *buffer) 34 + static int kgdb_transition_check(char *buffer) 35 35 { 36 - int slen = strlen(buffer); 37 - if (strncmp(buffer, "$?#3f", slen) != 0 && 38 - strncmp(buffer, "$qSupported#37", slen) != 0 && 39 - strncmp(buffer, "+$qSupported#37", slen) != 0) { 36 + if (buffer[0] != '+' && buffer[0] != '$') { 40 37 KDB_STATE_SET(KGDB_TRANS); 41 38 kdb_printf("%s", buffer); 39 + } else { 40 + int slen = strlen(buffer); 41 + if (slen > 3 && buffer[slen - 3] == '#') { 42 + kdb_gdb_state_pass(buffer); 43 + strcpy(buffer, "kgdb"); 44 + KDB_STATE_SET(DOING_KGDB); 45 + return 1; 46 + } 42 47 } 48 + return 0; 43 49 } 44 50 45 51 static int kdb_read_get_key(char *buffer, size_t bufsize) ··· 257 251 case 13: /* enter */ 258 252 *lastchar++ = '\n'; 259 253 *lastchar++ = '\0'; 254 + if (!KDB_STATE(KGDB_TRANS)) { 255 + KDB_STATE_SET(KGDB_TRANS); 256 + kdb_printf("%s", buffer); 257 + } 260 258 kdb_printf("\n"); 261 259 return buffer; 262 260 case 4: /* Del */ ··· 392 382 * printed characters if we think that 393 383 * kgdb is connecting, until the check 394 384 * fails */ 395 - if (!KDB_STATE(KGDB_TRANS)) 396 - kgdb_transition_check(buffer); 397 - else 385 + if (!KDB_STATE(KGDB_TRANS)) { 386 + if (kgdb_transition_check(buffer)) 387 + return buffer; 388 + } else { 398 389 kdb_printf("%c", key); 390 + } 399 391 } 400 392 /* Special escape to kgdb */ 401 393 if (lastchar - buffer >= 5 && 402 394 strcmp(lastchar - 5, "$?#3f") == 0) { 395 + kdb_gdb_state_pass(lastchar - 5); 403 396 strcpy(buffer, "kgdb"); 404 397 KDB_STATE_SET(DOING_KGDB); 405 398 return buffer; 406 399 } 407 - if (lastchar - buffer >= 14 && 408 - strcmp(lastchar - 14, "$qSupported#37") == 0) { 400 + if (lastchar - buffer >= 11 && 401 + strcmp(lastchar - 11, "$qSupported") == 0) { 402 + kdb_gdb_state_pass(lastchar - 11); 409 403 strcpy(buffer, "kgdb"); 410 - KDB_STATE_SET(DOING_KGDB2); 404 + KDB_STATE_SET(DOING_KGDB); 411 405 return buffer; 412 406 } 413 407 }
+2 -2
kernel/debug/kdb/kdb_main.c
··· 145 145 #endif 146 146 "RADIX=16", 147 147 "MDCOUNT=8", /* lines of md output */ 148 - "BTARGS=9", /* 9 possible args in bt */ 149 148 KDB_PLATFORM_ENV, 150 149 "DTABCOUNT=30", 151 150 "NOSECT=1", 151 + (char *)0, 152 152 (char *)0, 153 153 (char *)0, 154 154 (char *)0, ··· 1386 1386 } 1387 1387 1388 1388 if (result == KDB_CMD_KGDB) { 1389 - if (!(KDB_STATE(DOING_KGDB) || KDB_STATE(DOING_KGDB2))) 1389 + if (!KDB_STATE(DOING_KGDB)) 1390 1390 kdb_printf("Entering please attach debugger " 1391 1391 "or use $D#44+ or $3#33\n"); 1392 1392 break;
+1 -2
kernel/debug/kdb/kdb_private.h
··· 21 21 #define KDB_CMD_SS (-1003) 22 22 #define KDB_CMD_SSB (-1004) 23 23 #define KDB_CMD_KGDB (-1005) 24 - #define KDB_CMD_KGDB2 (-1006) 25 24 26 25 /* Internal debug flags */ 27 26 #define KDB_DEBUG_FLAG_BP 0x0002 /* Breakpoint subsystem debug */ ··· 145 146 * keyboard on this cpu */ 146 147 #define KDB_STATE_KEXEC 0x00040000 /* kexec issued */ 147 148 #define KDB_STATE_DOING_KGDB 0x00080000 /* kgdb enter now issued */ 148 - #define KDB_STATE_DOING_KGDB2 0x00100000 /* kgdb enter now issued */ 149 149 #define KDB_STATE_KGDB_TRANS 0x00200000 /* Transition to kgdb */ 150 150 #define KDB_STATE_ARCH 0xff000000 /* Reserved for arch 151 151 * specific use */ ··· 216 218 extern void kdb_send_sig_info(struct task_struct *p, struct siginfo *info); 217 219 extern void kdb_meminfo_proc_show(void); 218 220 extern char *kdb_getstr(char *, size_t, char *); 221 + extern void kdb_gdb_state_pass(char *buf); 219 222 220 223 /* Defines for kdb_symbol_print */ 221 224 #define KDB_SP_SPACEB 0x0001 /* Space before string */