6 * Copyright (C) 2000-2001 VERITAS Software Corporation.
7 * Copyright (C) 2002-2004 Timesys Corporation
11 * Copyright (C) 2004-2006 LinSysSoft Technologies Pvt. Ltd.
12 * Copyright (C) 2005-2009 Wind River Systems, Inc.
13 * Copyright (C) 2007 MontaVista Software, Inc.
16 * Contributors at various stages not listed above:
20 * Lake Stevens Instrument Division (Glenn Engel)
21 * Jim Kingdon, Cygnus Support.
26 * This file is licensed under the terms of the GNU General Public License
27 * version 2. This program is licensed "as is" without any warranty of any
28 * kind, whether express or implied.
31 #include <linux/kernel.h>
32 #include <linux/kgdb.h>
33 #include <linux/kdb.h>
34 #include <linux/reboot.h>
35 #include <linux/uaccess.h>
36 #include <asm/cacheflush.h>
37 #include <asm/unaligned.h>
38 #include "debug_core.h"
40 #define KGDB_MAX_THREAD_QUERY 17
42 /* Our I/O buffers. */
43 static char remcom_in_buffer[BUFMAX];
44 static char remcom_out_buffer[BUFMAX];
46 /* Storage for the registers, in GDB format. */
47 static unsigned long gdb_regs[(NUMREGBYTES +
48 sizeof(unsigned long) - 1) /
49 sizeof(unsigned long)];
52 * GDB remote protocol parser:
55 #ifdef CONFIG_KGDB_KDB
56 static int gdbstub_read_wait(void)
61 /* poll any additional I/O interfaces that are defined */
63 for (i = 0; kdb_poll_funcs[i] != NULL; i++) {
64 ret = kdb_poll_funcs[i]();
71 static int gdbstub_read_wait(void)
73 int ret = dbg_io_ops->read_char();
74 while (ret == NO_POLL_CHAR)
75 ret = dbg_io_ops->read_char();
79 /* scan for the sequence $<data>#<checksum> */
80 static void get_packet(char *buffer)
82 unsigned char checksum;
83 unsigned char xmitcsum;
89 * Spin and wait around for the start character, ignore all
92 while ((ch = (gdbstub_read_wait())) != '$')
102 * now, read until a # or end of buffer is found:
104 while (count < (BUFMAX - 1)) {
105 ch = gdbstub_read_wait();
108 checksum = checksum + ch;
115 xmitcsum = hex_to_bin(gdbstub_read_wait()) << 4;
116 xmitcsum += hex_to_bin(gdbstub_read_wait());
118 if (checksum != xmitcsum)
119 /* failed checksum */
120 dbg_io_ops->write_char('-');
122 /* successful transfer */
123 dbg_io_ops->write_char('+');
124 if (dbg_io_ops->flush)
127 } while (checksum != xmitcsum);
131 * Send the packet in buffer.
132 * Check for gdb connection if asked for.
134 static void put_packet(char *buffer)
136 unsigned char checksum;
141 * $<packet info>#<checksum>.
144 dbg_io_ops->write_char('$');
148 while ((ch = buffer[count])) {
149 dbg_io_ops->write_char(ch);
154 dbg_io_ops->write_char('#');
155 dbg_io_ops->write_char(hex_asc_hi(checksum));
156 dbg_io_ops->write_char(hex_asc_lo(checksum));
157 if (dbg_io_ops->flush)
160 /* Now see what we get in reply. */
161 ch = gdbstub_read_wait();
164 ch = gdbstub_read_wait();
166 /* If we get an ACK, we are done. */
171 * If we get the start of another packet, this means
172 * that GDB is attempting to reconnect. We will NAK
173 * the packet being sent, and stop trying to send this
177 dbg_io_ops->write_char('-');
178 if (dbg_io_ops->flush)
185 static char gdbmsgbuf[BUFMAX + 1];
187 void gdbstub_msg_write(const char *s, int len)
199 /* Fill and send buffers... */
201 bufptr = gdbmsgbuf + 1;
203 /* Calculate how many this time */
204 if ((len << 1) > (BUFMAX - 2))
205 wcount = (BUFMAX - 2) >> 1;
209 /* Pack in hex chars */
210 for (i = 0; i < wcount; i++)
211 bufptr = pack_hex_byte(bufptr, s[i]);
219 put_packet(gdbmsgbuf);
224 * Convert the memory pointed to by mem into hex, placing result in
225 * buf. Return a pointer to the last char put in buf (null). May
228 char *kgdb_mem2hex(char *mem, char *buf, int count)
234 * We use the upper half of buf as an intermediate buffer for the
235 * raw memory copy. Hex conversion will work against this one.
239 err = probe_kernel_read(tmp, mem, count);
243 buf = pack_hex_byte(buf, *tmp);
253 * Convert the hex array pointed to by buf into binary to be placed in
254 * mem. Return a pointer to the character AFTER the last byte
255 * written. May return an error.
257 int kgdb_hex2mem(char *buf, char *mem, int count)
263 * We use the upper half of buf as an intermediate buffer for the
264 * raw memory that is converted from hex.
266 tmp_raw = buf + count * 2;
268 tmp_hex = tmp_raw - 1;
269 while (tmp_hex >= buf) {
271 *tmp_raw = hex_to_bin(*tmp_hex--);
272 *tmp_raw |= hex_to_bin(*tmp_hex--) << 4;
275 return probe_kernel_write(mem, tmp_raw, count);
279 * While we find nice hex chars, build a long_val.
280 * Return number of chars processed.
282 int kgdb_hex2long(char **ptr, unsigned long *long_val)
295 hex_val = hex_to_bin(**ptr);
299 *long_val = (*long_val << 4) | hex_val;
305 *long_val = -*long_val;
311 * Copy the binary array pointed to by buf into mem. Fix $, #, and
312 * 0x7d escaped with 0x7d. Return -EFAULT on failure or 0 on success.
313 * The input buf is overwitten with the result to write to mem.
315 static int kgdb_ebin2mem(char *buf, char *mem, int count)
320 while (count-- > 0) {
323 c[size] = *buf++ ^ 0x20;
327 return probe_kernel_write(mem, c, size);
330 #if DBG_MAX_REG_NUM > 0
331 void pt_regs_to_gdb_regs(unsigned long *gdb_regs, struct pt_regs *regs)
335 char *ptr = (char *)gdb_regs;
337 for (i = 0; i < DBG_MAX_REG_NUM; i++) {
338 dbg_get_reg(i, ptr + idx, regs);
339 idx += dbg_reg_def[i].size;
343 void gdb_regs_to_pt_regs(unsigned long *gdb_regs, struct pt_regs *regs)
347 char *ptr = (char *)gdb_regs;
349 for (i = 0; i < DBG_MAX_REG_NUM; i++) {
350 dbg_set_reg(i, ptr + idx, regs);
351 idx += dbg_reg_def[i].size;
354 #endif /* DBG_MAX_REG_NUM > 0 */
356 /* Write memory due to an 'M' or 'X' packet. */
357 static int write_mem_msg(int binary)
359 char *ptr = &remcom_in_buffer[1];
361 unsigned long length;
364 if (kgdb_hex2long(&ptr, &addr) > 0 && *(ptr++) == ',' &&
365 kgdb_hex2long(&ptr, &length) > 0 && *(ptr++) == ':') {
367 err = kgdb_ebin2mem(ptr, (char *)addr, length);
369 err = kgdb_hex2mem(ptr, (char *)addr, length);
372 if (CACHE_FLUSH_IS_SAFE)
373 flush_icache_range(addr, addr + length);
380 static void error_packet(char *pkt, int error)
384 pkt[1] = hex_asc[(error / 10)];
385 pkt[2] = hex_asc[(error % 10)];
390 * Thread ID accessors. We represent a flat TID space to GDB, where
391 * the per CPU idle threads (which under Linux all have PID 0) are
392 * remapped to negative TIDs.
395 #define BUF_THREAD_ID_SIZE 8
397 static char *pack_threadid(char *pkt, unsigned char *id)
399 unsigned char *limit;
402 limit = id + (BUF_THREAD_ID_SIZE / 2);
404 if (!lzero || *id != 0) {
405 pkt = pack_hex_byte(pkt, *id);
412 pkt = pack_hex_byte(pkt, 0);
417 static void int_to_threadref(unsigned char *id, int value)
419 put_unaligned_be32(value, id);
422 static struct task_struct *getthread(struct pt_regs *regs, int tid)
425 * Non-positive TIDs are remapped to the cpu shadow information
427 if (tid == 0 || tid == -1)
428 tid = -atomic_read(&kgdb_active) - 2;
429 if (tid < -1 && tid > -NR_CPUS - 2) {
430 if (kgdb_info[-tid - 2].task)
431 return kgdb_info[-tid - 2].task;
433 return idle_task(-tid - 2);
436 printk(KERN_ERR "KGDB: Internal thread select error\n");
442 * find_task_by_pid_ns() does not take the tasklist lock anymore
443 * but is nicely RCU locked - hence is a pretty resilient
446 return find_task_by_pid_ns(tid, &init_pid_ns);
451 * Remap normal tasks to their real PID,
452 * CPU shadow threads are mapped to -CPU - 2
454 static inline int shadow_pid(int realpid)
459 return -raw_smp_processor_id() - 2;
463 * All the functions that start with gdb_cmd are the various
464 * operations to implement the handlers for the gdbserial protocol
465 * where KGDB is communicating with an external debugger
468 /* Handle the '?' status packets */
469 static void gdb_cmd_status(struct kgdb_state *ks)
472 * We know that this packet is only sent
473 * during initial connect. So to be safe,
474 * we clear out our breakpoints now in case
475 * GDB is reconnecting.
477 dbg_remove_all_break();
479 remcom_out_buffer[0] = 'S';
480 pack_hex_byte(&remcom_out_buffer[1], ks->signo);
483 static void gdb_get_regs_helper(struct kgdb_state *ks)
485 struct task_struct *thread;
486 void *local_debuggerinfo;
489 thread = kgdb_usethread;
491 thread = kgdb_info[ks->cpu].task;
492 local_debuggerinfo = kgdb_info[ks->cpu].debuggerinfo;
494 local_debuggerinfo = NULL;
495 for_each_online_cpu(i) {
497 * Try to find the task on some other
498 * or possibly this node if we do not
499 * find the matching task then we try
500 * to approximate the results.
502 if (thread == kgdb_info[i].task)
503 local_debuggerinfo = kgdb_info[i].debuggerinfo;
508 * All threads that don't have debuggerinfo should be
509 * in schedule() sleeping, since all other CPUs
510 * are in kgdb_wait, and thus have debuggerinfo.
512 if (local_debuggerinfo) {
513 pt_regs_to_gdb_regs(gdb_regs, local_debuggerinfo);
516 * Pull stuff saved during switch_to; nothing
517 * else is accessible (or even particularly
520 * This should be enough for a stack trace.
522 sleeping_thread_to_gdb_regs(gdb_regs, thread);
526 /* Handle the 'g' get registers request */
527 static void gdb_cmd_getregs(struct kgdb_state *ks)
529 gdb_get_regs_helper(ks);
530 kgdb_mem2hex((char *)gdb_regs, remcom_out_buffer, NUMREGBYTES);
533 /* Handle the 'G' set registers request */
534 static void gdb_cmd_setregs(struct kgdb_state *ks)
536 kgdb_hex2mem(&remcom_in_buffer[1], (char *)gdb_regs, NUMREGBYTES);
538 if (kgdb_usethread && kgdb_usethread != current) {
539 error_packet(remcom_out_buffer, -EINVAL);
541 gdb_regs_to_pt_regs(gdb_regs, ks->linux_regs);
542 strcpy(remcom_out_buffer, "OK");
546 /* Handle the 'm' memory read bytes */
547 static void gdb_cmd_memread(struct kgdb_state *ks)
549 char *ptr = &remcom_in_buffer[1];
550 unsigned long length;
554 if (kgdb_hex2long(&ptr, &addr) > 0 && *ptr++ == ',' &&
555 kgdb_hex2long(&ptr, &length) > 0) {
556 err = kgdb_mem2hex((char *)addr, remcom_out_buffer, length);
558 error_packet(remcom_out_buffer, -EINVAL);
560 error_packet(remcom_out_buffer, -EINVAL);
564 /* Handle the 'M' memory write bytes */
565 static void gdb_cmd_memwrite(struct kgdb_state *ks)
567 int err = write_mem_msg(0);
570 error_packet(remcom_out_buffer, err);
572 strcpy(remcom_out_buffer, "OK");
575 #if DBG_MAX_REG_NUM > 0
576 static char *gdb_hex_reg_helper(int regnum, char *out)
581 for (i = 0; i < regnum; i++)
582 offset += dbg_reg_def[i].size;
583 return kgdb_mem2hex((char *)gdb_regs + offset, out,
584 dbg_reg_def[i].size);
587 /* Handle the 'p' individual regster get */
588 static void gdb_cmd_reg_get(struct kgdb_state *ks)
590 unsigned long regnum;
591 char *ptr = &remcom_in_buffer[1];
593 kgdb_hex2long(&ptr, ®num);
594 if (regnum >= DBG_MAX_REG_NUM) {
595 error_packet(remcom_out_buffer, -EINVAL);
598 gdb_get_regs_helper(ks);
599 gdb_hex_reg_helper(regnum, remcom_out_buffer);
602 /* Handle the 'P' individual regster set */
603 static void gdb_cmd_reg_set(struct kgdb_state *ks)
605 unsigned long regnum;
606 char *ptr = &remcom_in_buffer[1];
609 kgdb_hex2long(&ptr, ®num);
611 !(!kgdb_usethread || kgdb_usethread == current) ||
612 !dbg_get_reg(regnum, gdb_regs, ks->linux_regs)) {
613 error_packet(remcom_out_buffer, -EINVAL);
616 memset(gdb_regs, 0, sizeof(gdb_regs));
617 while (i < sizeof(gdb_regs) * 2)
618 if (hex_to_bin(ptr[i]) >= 0)
623 kgdb_hex2mem(ptr, (char *)gdb_regs, i);
624 dbg_set_reg(regnum, gdb_regs, ks->linux_regs);
625 strcpy(remcom_out_buffer, "OK");
627 #endif /* DBG_MAX_REG_NUM > 0 */
629 /* Handle the 'X' memory binary write bytes */
630 static void gdb_cmd_binwrite(struct kgdb_state *ks)
632 int err = write_mem_msg(1);
635 error_packet(remcom_out_buffer, err);
637 strcpy(remcom_out_buffer, "OK");
640 /* Handle the 'D' or 'k', detach or kill packets */
641 static void gdb_cmd_detachkill(struct kgdb_state *ks)
645 /* The detach case */
646 if (remcom_in_buffer[0] == 'D') {
647 error = dbg_remove_all_break();
649 error_packet(remcom_out_buffer, error);
651 strcpy(remcom_out_buffer, "OK");
654 put_packet(remcom_out_buffer);
657 * Assume the kill case, with no exit code checking,
658 * trying to force detach the debugger:
660 dbg_remove_all_break();
665 /* Handle the 'R' reboot packets */
666 static int gdb_cmd_reboot(struct kgdb_state *ks)
668 /* For now, only honor R0 */
669 if (strcmp(remcom_in_buffer, "R0") == 0) {
670 printk(KERN_CRIT "Executing emergency reboot\n");
671 strcpy(remcom_out_buffer, "OK");
672 put_packet(remcom_out_buffer);
675 * Execution should not return from
676 * machine_emergency_restart()
678 machine_emergency_restart();
686 /* Handle the 'q' query packets */
687 static void gdb_cmd_query(struct kgdb_state *ks)
689 struct task_struct *g;
690 struct task_struct *p;
691 unsigned char thref[BUF_THREAD_ID_SIZE];
697 switch (remcom_in_buffer[1]) {
700 if (memcmp(remcom_in_buffer + 2, "ThreadInfo", 10))
704 remcom_out_buffer[0] = 'm';
705 ptr = remcom_out_buffer + 1;
706 if (remcom_in_buffer[1] == 'f') {
707 /* Each cpu is a shadow thread */
708 for_each_online_cpu(cpu) {
710 int_to_threadref(thref, -cpu - 2);
711 ptr = pack_threadid(ptr, thref);
717 do_each_thread(g, p) {
718 if (i >= ks->thr_query && !finished) {
719 int_to_threadref(thref, p->pid);
720 ptr = pack_threadid(ptr, thref);
723 if (ks->thr_query % KGDB_MAX_THREAD_QUERY == 0)
727 } while_each_thread(g, p);
733 /* Current thread id */
734 strcpy(remcom_out_buffer, "QC");
735 ks->threadid = shadow_pid(current->pid);
736 int_to_threadref(thref, ks->threadid);
737 pack_threadid(remcom_out_buffer + 2, thref);
740 if (memcmp(remcom_in_buffer + 1, "ThreadExtraInfo,", 16))
744 ptr = remcom_in_buffer + 17;
745 kgdb_hex2long(&ptr, &ks->threadid);
746 if (!getthread(ks->linux_regs, ks->threadid)) {
747 error_packet(remcom_out_buffer, -EINVAL);
750 if ((int)ks->threadid > 0) {
751 kgdb_mem2hex(getthread(ks->linux_regs,
753 remcom_out_buffer, 16);
755 static char tmpstr[23 + BUF_THREAD_ID_SIZE];
757 sprintf(tmpstr, "shadowCPU%d",
758 (int)(-ks->threadid - 2));
759 kgdb_mem2hex(tmpstr, remcom_out_buffer, strlen(tmpstr));
762 #ifdef CONFIG_KGDB_KDB
764 if (strncmp(remcom_in_buffer, "qRcmd,", 6) == 0) {
765 int len = strlen(remcom_in_buffer + 6);
767 if ((len % 2) != 0) {
768 strcpy(remcom_out_buffer, "E01");
771 kgdb_hex2mem(remcom_in_buffer + 6,
772 remcom_out_buffer, len);
774 remcom_out_buffer[len++] = 0;
776 kdb_parse(remcom_out_buffer);
777 strcpy(remcom_out_buffer, "OK");
784 /* Handle the 'H' task query packets */
785 static void gdb_cmd_task(struct kgdb_state *ks)
787 struct task_struct *thread;
790 switch (remcom_in_buffer[1]) {
792 ptr = &remcom_in_buffer[2];
793 kgdb_hex2long(&ptr, &ks->threadid);
794 thread = getthread(ks->linux_regs, ks->threadid);
795 if (!thread && ks->threadid > 0) {
796 error_packet(remcom_out_buffer, -EINVAL);
799 kgdb_usethread = thread;
800 ks->kgdb_usethreadid = ks->threadid;
801 strcpy(remcom_out_buffer, "OK");
804 ptr = &remcom_in_buffer[2];
805 kgdb_hex2long(&ptr, &ks->threadid);
807 kgdb_contthread = NULL;
809 thread = getthread(ks->linux_regs, ks->threadid);
810 if (!thread && ks->threadid > 0) {
811 error_packet(remcom_out_buffer, -EINVAL);
814 kgdb_contthread = thread;
816 strcpy(remcom_out_buffer, "OK");
821 /* Handle the 'T' thread query packets */
822 static void gdb_cmd_thread(struct kgdb_state *ks)
824 char *ptr = &remcom_in_buffer[1];
825 struct task_struct *thread;
827 kgdb_hex2long(&ptr, &ks->threadid);
828 thread = getthread(ks->linux_regs, ks->threadid);
830 strcpy(remcom_out_buffer, "OK");
832 error_packet(remcom_out_buffer, -EINVAL);
835 /* Handle the 'z' or 'Z' breakpoint remove or set packets */
836 static void gdb_cmd_break(struct kgdb_state *ks)
839 * Since GDB-5.3, it's been drafted that '0' is a software
840 * breakpoint, '1' is a hardware breakpoint, so let's do that.
842 char *bpt_type = &remcom_in_buffer[1];
843 char *ptr = &remcom_in_buffer[2];
845 unsigned long length;
848 if (arch_kgdb_ops.set_hw_breakpoint && *bpt_type >= '1') {
853 if (*bpt_type != '0' && *bpt_type != '1')
859 * Test if this is a hardware breakpoint, and
862 if (*bpt_type == '1' && !(arch_kgdb_ops.flags & KGDB_HW_BREAKPOINT))
866 if (*(ptr++) != ',') {
867 error_packet(remcom_out_buffer, -EINVAL);
870 if (!kgdb_hex2long(&ptr, &addr)) {
871 error_packet(remcom_out_buffer, -EINVAL);
874 if (*(ptr++) != ',' ||
875 !kgdb_hex2long(&ptr, &length)) {
876 error_packet(remcom_out_buffer, -EINVAL);
880 if (remcom_in_buffer[0] == 'Z' && *bpt_type == '0')
881 error = dbg_set_sw_break(addr);
882 else if (remcom_in_buffer[0] == 'z' && *bpt_type == '0')
883 error = dbg_remove_sw_break(addr);
884 else if (remcom_in_buffer[0] == 'Z')
885 error = arch_kgdb_ops.set_hw_breakpoint(addr,
886 (int)length, *bpt_type - '0');
887 else if (remcom_in_buffer[0] == 'z')
888 error = arch_kgdb_ops.remove_hw_breakpoint(addr,
889 (int) length, *bpt_type - '0');
892 strcpy(remcom_out_buffer, "OK");
894 error_packet(remcom_out_buffer, error);
897 /* Handle the 'C' signal / exception passing packets */
898 static int gdb_cmd_exception_pass(struct kgdb_state *ks)
900 /* C09 == pass exception
901 * C15 == detach kgdb, pass exception
903 if (remcom_in_buffer[1] == '0' && remcom_in_buffer[2] == '9') {
905 ks->pass_exception = 1;
906 remcom_in_buffer[0] = 'c';
908 } else if (remcom_in_buffer[1] == '1' && remcom_in_buffer[2] == '5') {
910 ks->pass_exception = 1;
911 remcom_in_buffer[0] = 'D';
912 dbg_remove_all_break();
917 gdbstub_msg_write("KGDB only knows signal 9 (pass)"
918 " and 15 (pass and disconnect)\n"
919 "Executing a continue without signal passing\n", 0);
920 remcom_in_buffer[0] = 'c';
923 /* Indicate fall through */
928 * This function performs all gdbserial command procesing
930 int gdb_serial_stub(struct kgdb_state *ks)
935 /* Initialize comm buffer and globals. */
936 memset(remcom_out_buffer, 0, sizeof(remcom_out_buffer));
937 kgdb_usethread = kgdb_info[ks->cpu].task;
938 ks->kgdb_usethreadid = shadow_pid(kgdb_info[ks->cpu].task->pid);
939 ks->pass_exception = 0;
941 if (kgdb_connected) {
942 unsigned char thref[BUF_THREAD_ID_SIZE];
945 /* Reply to host that an exception has occurred */
946 ptr = remcom_out_buffer;
948 ptr = pack_hex_byte(ptr, ks->signo);
949 ptr += strlen(strcpy(ptr, "thread:"));
950 int_to_threadref(thref, shadow_pid(current->pid));
951 ptr = pack_threadid(ptr, thref);
953 put_packet(remcom_out_buffer);
959 /* Clear the out buffer. */
960 memset(remcom_out_buffer, 0, sizeof(remcom_out_buffer));
962 get_packet(remcom_in_buffer);
964 switch (remcom_in_buffer[0]) {
965 case '?': /* gdbserial status */
968 case 'g': /* return the value of the CPU registers */
971 case 'G': /* set the value of the CPU registers - return OK */
974 case 'm': /* mAA..AA,LLLL Read LLLL bytes at address AA..AA */
977 case 'M': /* MAA..AA,LLLL: Write LLLL bytes at address AA..AA */
978 gdb_cmd_memwrite(ks);
980 #if DBG_MAX_REG_NUM > 0
981 case 'p': /* pXX Return gdb register XX (in hex) */
984 case 'P': /* PXX=aaaa Set gdb register XX to aaaa (in hex) */
987 #endif /* DBG_MAX_REG_NUM > 0 */
988 case 'X': /* XAA..AA,LLLL: Write LLLL bytes at address AA..AA */
989 gdb_cmd_binwrite(ks);
991 /* kill or detach. KGDB should treat this like a
994 case 'D': /* Debugger detach */
995 case 'k': /* Debugger detach via kill */
996 gdb_cmd_detachkill(ks);
998 case 'R': /* Reboot */
999 if (gdb_cmd_reboot(ks))
1000 goto default_handle;
1002 case 'q': /* query command */
1005 case 'H': /* task related */
1008 case 'T': /* Query thread status */
1011 case 'z': /* Break point remove */
1012 case 'Z': /* Break point set */
1015 #ifdef CONFIG_KGDB_KDB
1016 case '3': /* Escape into back into kdb */
1017 if (remcom_in_buffer[1] == '\0') {
1018 gdb_cmd_detachkill(ks);
1019 return DBG_PASS_EVENT;
1022 case 'C': /* Exception passing */
1023 tmp = gdb_cmd_exception_pass(ks);
1025 goto default_handle;
1028 /* Fall through on tmp < 0 */
1029 case 'c': /* Continue packet */
1030 case 's': /* Single step packet */
1031 if (kgdb_contthread && kgdb_contthread != current) {
1032 /* Can't switch threads in kgdb */
1033 error_packet(remcom_out_buffer, -EINVAL);
1036 dbg_activate_sw_breakpoints();
1037 /* Fall through to default processing */
1040 error = kgdb_arch_handle_exception(ks->ex_vector,
1047 * Leave cmd processing on error, detach,
1048 * kill, continue, or single step.
1050 if (error >= 0 || remcom_in_buffer[0] == 'D' ||
1051 remcom_in_buffer[0] == 'k') {
1058 /* reply to the request */
1059 put_packet(remcom_out_buffer);
1063 if (ks->pass_exception)
1068 int gdbstub_state(struct kgdb_state *ks, char *cmd)
1074 error = kgdb_arch_handle_exception(ks->ex_vector,
1083 strcpy(remcom_in_buffer, cmd);
1089 strcpy(remcom_out_buffer, "");
1092 dbg_io_ops->write_char('+');
1093 put_packet(remcom_out_buffer);