4 * Maintainer: Jason Wessel <jason.wessel@windriver.com>
6 * Copyright (C) 2000-2001 VERITAS Software Corporation.
7 * Copyright (C) 2002-2004 Timesys Corporation
8 * Copyright (C) 2003-2004 Amit S. Kale <amitkale@linsyssoft.com>
9 * Copyright (C) 2004 Pavel Machek <pavel@suse.cz>
10 * Copyright (C) 2004-2006 Tom Rini <trini@kernel.crashing.org>
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.
14 * Copyright (C) 2008 Red Hat, Inc., Ingo Molnar <mingo@redhat.com>
16 * Contributors at various stages not listed above:
17 * Jason Wessel ( jason.wessel@windriver.com )
18 * George Anzinger <george@mvista.com>
19 * Anurekh Saxena (anurekh.saxena@timesys.com)
20 * Lake Stevens Instrument Division (Glenn Engel)
21 * Jim Kingdon, Cygnus Support.
23 * Original KGDB stub: David Grothe <dave@gcom.com>,
24 * Tigran Aivazian <tigran@sco.com>
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];
608 kgdb_hex2long(&ptr, ®num);
610 !(!kgdb_usethread || kgdb_usethread == current) ||
611 !dbg_get_reg(regnum, gdb_regs, ks->linux_regs)) {
612 error_packet(remcom_out_buffer, -EINVAL);
615 kgdb_hex2mem(ptr, (char *)gdb_regs, dbg_reg_def[regnum].size);
616 dbg_set_reg(regnum, gdb_regs, ks->linux_regs);
617 strcpy(remcom_out_buffer, "OK");
619 #endif /* DBG_MAX_REG_NUM > 0 */
621 /* Handle the 'X' memory binary write bytes */
622 static void gdb_cmd_binwrite(struct kgdb_state *ks)
624 int err = write_mem_msg(1);
627 error_packet(remcom_out_buffer, err);
629 strcpy(remcom_out_buffer, "OK");
632 /* Handle the 'D' or 'k', detach or kill packets */
633 static void gdb_cmd_detachkill(struct kgdb_state *ks)
637 /* The detach case */
638 if (remcom_in_buffer[0] == 'D') {
639 error = dbg_remove_all_break();
641 error_packet(remcom_out_buffer, error);
643 strcpy(remcom_out_buffer, "OK");
646 put_packet(remcom_out_buffer);
649 * Assume the kill case, with no exit code checking,
650 * trying to force detach the debugger:
652 dbg_remove_all_break();
657 /* Handle the 'R' reboot packets */
658 static int gdb_cmd_reboot(struct kgdb_state *ks)
660 /* For now, only honor R0 */
661 if (strcmp(remcom_in_buffer, "R0") == 0) {
662 printk(KERN_CRIT "Executing emergency reboot\n");
663 strcpy(remcom_out_buffer, "OK");
664 put_packet(remcom_out_buffer);
667 * Execution should not return from
668 * machine_emergency_restart()
670 machine_emergency_restart();
678 /* Handle the 'q' query packets */
679 static void gdb_cmd_query(struct kgdb_state *ks)
681 struct task_struct *g;
682 struct task_struct *p;
683 unsigned char thref[BUF_THREAD_ID_SIZE];
689 switch (remcom_in_buffer[1]) {
692 if (memcmp(remcom_in_buffer + 2, "ThreadInfo", 10))
696 remcom_out_buffer[0] = 'm';
697 ptr = remcom_out_buffer + 1;
698 if (remcom_in_buffer[1] == 'f') {
699 /* Each cpu is a shadow thread */
700 for_each_online_cpu(cpu) {
702 int_to_threadref(thref, -cpu - 2);
703 ptr = pack_threadid(ptr, thref);
709 do_each_thread(g, p) {
710 if (i >= ks->thr_query && !finished) {
711 int_to_threadref(thref, p->pid);
712 ptr = pack_threadid(ptr, thref);
715 if (ks->thr_query % KGDB_MAX_THREAD_QUERY == 0)
719 } while_each_thread(g, p);
725 /* Current thread id */
726 strcpy(remcom_out_buffer, "QC");
727 ks->threadid = shadow_pid(current->pid);
728 int_to_threadref(thref, ks->threadid);
729 pack_threadid(remcom_out_buffer + 2, thref);
732 if (memcmp(remcom_in_buffer + 1, "ThreadExtraInfo,", 16))
736 ptr = remcom_in_buffer + 17;
737 kgdb_hex2long(&ptr, &ks->threadid);
738 if (!getthread(ks->linux_regs, ks->threadid)) {
739 error_packet(remcom_out_buffer, -EINVAL);
742 if ((int)ks->threadid > 0) {
743 kgdb_mem2hex(getthread(ks->linux_regs,
745 remcom_out_buffer, 16);
747 static char tmpstr[23 + BUF_THREAD_ID_SIZE];
749 sprintf(tmpstr, "shadowCPU%d",
750 (int)(-ks->threadid - 2));
751 kgdb_mem2hex(tmpstr, remcom_out_buffer, strlen(tmpstr));
754 #ifdef CONFIG_KGDB_KDB
756 if (strncmp(remcom_in_buffer, "qRcmd,", 6) == 0) {
757 int len = strlen(remcom_in_buffer + 6);
759 if ((len % 2) != 0) {
760 strcpy(remcom_out_buffer, "E01");
763 kgdb_hex2mem(remcom_in_buffer + 6,
764 remcom_out_buffer, len);
766 remcom_out_buffer[len++] = 0;
768 kdb_parse(remcom_out_buffer);
769 strcpy(remcom_out_buffer, "OK");
776 /* Handle the 'H' task query packets */
777 static void gdb_cmd_task(struct kgdb_state *ks)
779 struct task_struct *thread;
782 switch (remcom_in_buffer[1]) {
784 ptr = &remcom_in_buffer[2];
785 kgdb_hex2long(&ptr, &ks->threadid);
786 thread = getthread(ks->linux_regs, ks->threadid);
787 if (!thread && ks->threadid > 0) {
788 error_packet(remcom_out_buffer, -EINVAL);
791 kgdb_usethread = thread;
792 ks->kgdb_usethreadid = ks->threadid;
793 strcpy(remcom_out_buffer, "OK");
796 ptr = &remcom_in_buffer[2];
797 kgdb_hex2long(&ptr, &ks->threadid);
799 kgdb_contthread = NULL;
801 thread = getthread(ks->linux_regs, ks->threadid);
802 if (!thread && ks->threadid > 0) {
803 error_packet(remcom_out_buffer, -EINVAL);
806 kgdb_contthread = thread;
808 strcpy(remcom_out_buffer, "OK");
813 /* Handle the 'T' thread query packets */
814 static void gdb_cmd_thread(struct kgdb_state *ks)
816 char *ptr = &remcom_in_buffer[1];
817 struct task_struct *thread;
819 kgdb_hex2long(&ptr, &ks->threadid);
820 thread = getthread(ks->linux_regs, ks->threadid);
822 strcpy(remcom_out_buffer, "OK");
824 error_packet(remcom_out_buffer, -EINVAL);
827 /* Handle the 'z' or 'Z' breakpoint remove or set packets */
828 static void gdb_cmd_break(struct kgdb_state *ks)
831 * Since GDB-5.3, it's been drafted that '0' is a software
832 * breakpoint, '1' is a hardware breakpoint, so let's do that.
834 char *bpt_type = &remcom_in_buffer[1];
835 char *ptr = &remcom_in_buffer[2];
837 unsigned long length;
840 if (arch_kgdb_ops.set_hw_breakpoint && *bpt_type >= '1') {
845 if (*bpt_type != '0' && *bpt_type != '1')
851 * Test if this is a hardware breakpoint, and
854 if (*bpt_type == '1' && !(arch_kgdb_ops.flags & KGDB_HW_BREAKPOINT))
858 if (*(ptr++) != ',') {
859 error_packet(remcom_out_buffer, -EINVAL);
862 if (!kgdb_hex2long(&ptr, &addr)) {
863 error_packet(remcom_out_buffer, -EINVAL);
866 if (*(ptr++) != ',' ||
867 !kgdb_hex2long(&ptr, &length)) {
868 error_packet(remcom_out_buffer, -EINVAL);
872 if (remcom_in_buffer[0] == 'Z' && *bpt_type == '0')
873 error = dbg_set_sw_break(addr);
874 else if (remcom_in_buffer[0] == 'z' && *bpt_type == '0')
875 error = dbg_remove_sw_break(addr);
876 else if (remcom_in_buffer[0] == 'Z')
877 error = arch_kgdb_ops.set_hw_breakpoint(addr,
878 (int)length, *bpt_type - '0');
879 else if (remcom_in_buffer[0] == 'z')
880 error = arch_kgdb_ops.remove_hw_breakpoint(addr,
881 (int) length, *bpt_type - '0');
884 strcpy(remcom_out_buffer, "OK");
886 error_packet(remcom_out_buffer, error);
889 /* Handle the 'C' signal / exception passing packets */
890 static int gdb_cmd_exception_pass(struct kgdb_state *ks)
892 /* C09 == pass exception
893 * C15 == detach kgdb, pass exception
895 if (remcom_in_buffer[1] == '0' && remcom_in_buffer[2] == '9') {
897 ks->pass_exception = 1;
898 remcom_in_buffer[0] = 'c';
900 } else if (remcom_in_buffer[1] == '1' && remcom_in_buffer[2] == '5') {
902 ks->pass_exception = 1;
903 remcom_in_buffer[0] = 'D';
904 dbg_remove_all_break();
909 gdbstub_msg_write("KGDB only knows signal 9 (pass)"
910 " and 15 (pass and disconnect)\n"
911 "Executing a continue without signal passing\n", 0);
912 remcom_in_buffer[0] = 'c';
915 /* Indicate fall through */
920 * This function performs all gdbserial command procesing
922 int gdb_serial_stub(struct kgdb_state *ks)
927 /* Initialize comm buffer and globals. */
928 memset(remcom_out_buffer, 0, sizeof(remcom_out_buffer));
929 kgdb_usethread = kgdb_info[ks->cpu].task;
930 ks->kgdb_usethreadid = shadow_pid(kgdb_info[ks->cpu].task->pid);
931 ks->pass_exception = 0;
933 if (kgdb_connected) {
934 unsigned char thref[BUF_THREAD_ID_SIZE];
937 /* Reply to host that an exception has occurred */
938 ptr = remcom_out_buffer;
940 ptr = pack_hex_byte(ptr, ks->signo);
941 ptr += strlen(strcpy(ptr, "thread:"));
942 int_to_threadref(thref, shadow_pid(current->pid));
943 ptr = pack_threadid(ptr, thref);
945 put_packet(remcom_out_buffer);
951 /* Clear the out buffer. */
952 memset(remcom_out_buffer, 0, sizeof(remcom_out_buffer));
954 get_packet(remcom_in_buffer);
956 switch (remcom_in_buffer[0]) {
957 case '?': /* gdbserial status */
960 case 'g': /* return the value of the CPU registers */
963 case 'G': /* set the value of the CPU registers - return OK */
966 case 'm': /* mAA..AA,LLLL Read LLLL bytes at address AA..AA */
969 case 'M': /* MAA..AA,LLLL: Write LLLL bytes at address AA..AA */
970 gdb_cmd_memwrite(ks);
972 #if DBG_MAX_REG_NUM > 0
973 case 'p': /* pXX Return gdb register XX (in hex) */
976 case 'P': /* PXX=aaaa Set gdb register XX to aaaa (in hex) */
979 #endif /* DBG_MAX_REG_NUM > 0 */
980 case 'X': /* XAA..AA,LLLL: Write LLLL bytes at address AA..AA */
981 gdb_cmd_binwrite(ks);
983 /* kill or detach. KGDB should treat this like a
986 case 'D': /* Debugger detach */
987 case 'k': /* Debugger detach via kill */
988 gdb_cmd_detachkill(ks);
990 case 'R': /* Reboot */
991 if (gdb_cmd_reboot(ks))
994 case 'q': /* query command */
997 case 'H': /* task related */
1000 case 'T': /* Query thread status */
1003 case 'z': /* Break point remove */
1004 case 'Z': /* Break point set */
1007 #ifdef CONFIG_KGDB_KDB
1008 case '3': /* Escape into back into kdb */
1009 if (remcom_in_buffer[1] == '\0') {
1010 gdb_cmd_detachkill(ks);
1011 return DBG_PASS_EVENT;
1014 case 'C': /* Exception passing */
1015 tmp = gdb_cmd_exception_pass(ks);
1017 goto default_handle;
1020 /* Fall through on tmp < 0 */
1021 case 'c': /* Continue packet */
1022 case 's': /* Single step packet */
1023 if (kgdb_contthread && kgdb_contthread != current) {
1024 /* Can't switch threads in kgdb */
1025 error_packet(remcom_out_buffer, -EINVAL);
1028 dbg_activate_sw_breakpoints();
1029 /* Fall through to default processing */
1032 error = kgdb_arch_handle_exception(ks->ex_vector,
1039 * Leave cmd processing on error, detach,
1040 * kill, continue, or single step.
1042 if (error >= 0 || remcom_in_buffer[0] == 'D' ||
1043 remcom_in_buffer[0] == 'k') {
1050 /* reply to the request */
1051 put_packet(remcom_out_buffer);
1055 if (ks->pass_exception)
1060 int gdbstub_state(struct kgdb_state *ks, char *cmd)
1066 error = kgdb_arch_handle_exception(ks->ex_vector,
1075 strcpy(remcom_in_buffer, cmd);
1081 strcpy(remcom_out_buffer, "");
1084 dbg_io_ops->write_char('+');
1085 put_packet(remcom_out_buffer);