aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2010-05-24 17:32:54 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2010-05-25 11:07:02 -0400
commit7ca8b9c0dafd1cb36289aa4c92c7beae7adcd34f (patch)
treea762d0b8bbb090b423eafae7f009839592e23290
parentc6f6b596a5a73e63e5e930c414375c0c389199ab (diff)
frv: extend gdbstub to support more features of gdb
Extend gdbstub to support more features of gdb remote protocol to keep gdb-7 and emacs gud mode happy: (*) The D command. Detach debugger. (*) The H command. Handle setting the target thread by ignoring it. (*) The qAttached command. Indicate we 'attached' to an existing process. (*) The qC command. Indicate that the current thread ID is 0. (*) The qOffsets command. Indicate that no relocation has been done. (*) The qSymbol:: command. Indicate that we're not interested in looking up any symbol addresses. (*) The qSupported command. Indicate the maximum packet size and the fact that reverse step and continue aren't supported. (*) The vCont? command. Indicate that we don't support any of its variants. Also make it possible to trace the commands and replies without tracing the individual character I/O. [akpm@linux-foundation.org: make gdbstub_handle_query() static] Signed-off-by: David Howells <dhowells@redhat.com> Cc: Jason Wessel <jason.wessel@windriver.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--arch/frv/include/asm/gdb-stub.h7
-rw-r--r--arch/frv/kernel/gdb-io.c4
-rw-r--r--arch/frv/kernel/gdb-stub.c61
3 files changed, 70 insertions, 2 deletions
diff --git a/arch/frv/include/asm/gdb-stub.h b/arch/frv/include/asm/gdb-stub.h
index 2da716407ff2..e6bedd0cd9a5 100644
--- a/arch/frv/include/asm/gdb-stub.h
+++ b/arch/frv/include/asm/gdb-stub.h
@@ -12,6 +12,7 @@
12#ifndef __ASM_GDB_STUB_H 12#ifndef __ASM_GDB_STUB_H
13#define __ASM_GDB_STUB_H 13#define __ASM_GDB_STUB_H
14 14
15#undef GDBSTUB_DEBUG_IO
15#undef GDBSTUB_DEBUG_PROTOCOL 16#undef GDBSTUB_DEBUG_PROTOCOL
16 17
17#include <asm/ptrace.h> 18#include <asm/ptrace.h>
@@ -108,6 +109,12 @@ extern void gdbstub_printk(const char *fmt, ...);
108extern void debug_to_serial(const char *p, int n); 109extern void debug_to_serial(const char *p, int n);
109extern void console_set_baud(unsigned baud); 110extern void console_set_baud(unsigned baud);
110 111
112#ifdef GDBSTUB_DEBUG_IO
113#define gdbstub_io(FMT,...) gdbstub_printk(FMT, ##__VA_ARGS__)
114#else
115#define gdbstub_io(FMT,...) ({ 0; })
116#endif
117
111#ifdef GDBSTUB_DEBUG_PROTOCOL 118#ifdef GDBSTUB_DEBUG_PROTOCOL
112#define gdbstub_proto(FMT,...) gdbstub_printk(FMT,##__VA_ARGS__) 119#define gdbstub_proto(FMT,...) gdbstub_printk(FMT,##__VA_ARGS__)
113#else 120#else
diff --git a/arch/frv/kernel/gdb-io.c b/arch/frv/kernel/gdb-io.c
index c997bccb9221..2ca641d199f8 100644
--- a/arch/frv/kernel/gdb-io.c
+++ b/arch/frv/kernel/gdb-io.c
@@ -171,11 +171,11 @@ int gdbstub_rx_char(unsigned char *_ch, int nonblock)
171 return -EINTR; 171 return -EINTR;
172 } 172 }
173 else if (st & (UART_LSR_FE|UART_LSR_OE|UART_LSR_PE)) { 173 else if (st & (UART_LSR_FE|UART_LSR_OE|UART_LSR_PE)) {
174 gdbstub_proto("### GDB Rx Error (st=%02x) ###\n",st); 174 gdbstub_io("### GDB Rx Error (st=%02x) ###\n",st);
175 return -EIO; 175 return -EIO;
176 } 176 }
177 else { 177 else {
178 gdbstub_proto("### GDB Rx %02x (st=%02x) ###\n",ch,st); 178 gdbstub_io("### GDB Rx %02x (st=%02x) ###\n",ch,st);
179 *_ch = ch & 0x7f; 179 *_ch = ch & 0x7f;
180 return 0; 180 return 0;
181 } 181 }
diff --git a/arch/frv/kernel/gdb-stub.c b/arch/frv/kernel/gdb-stub.c
index 7ca8a6b19ac9..84d103c33c9c 100644
--- a/arch/frv/kernel/gdb-stub.c
+++ b/arch/frv/kernel/gdb-stub.c
@@ -1344,6 +1344,44 @@ void gdbstub_get_mmu_state(void)
1344 1344
1345} /* end gdbstub_get_mmu_state() */ 1345} /* end gdbstub_get_mmu_state() */
1346 1346
1347/*
1348 * handle general query commands of the form 'qXXXXX'
1349 */
1350static void gdbstub_handle_query(void)
1351{
1352 if (strcmp(input_buffer, "qAttached") == 0) {
1353 /* return current thread ID */
1354 sprintf(output_buffer, "1");
1355 return;
1356 }
1357
1358 if (strcmp(input_buffer, "qC") == 0) {
1359 /* return current thread ID */
1360 sprintf(output_buffer, "QC 0");
1361 return;
1362 }
1363
1364 if (strcmp(input_buffer, "qOffsets") == 0) {
1365 /* return relocation offset of text and data segments */
1366 sprintf(output_buffer, "Text=0;Data=0;Bss=0");
1367 return;
1368 }
1369
1370 if (strcmp(input_buffer, "qSymbol::") == 0) {
1371 sprintf(output_buffer, "OK");
1372 return;
1373 }
1374
1375 if (strcmp(input_buffer, "qSupported") == 0) {
1376 /* query of supported features */
1377 sprintf(output_buffer, "PacketSize=%u;ReverseContinue-;ReverseStep-",
1378 sizeof(input_buffer));
1379 return;
1380 }
1381
1382 gdbstub_strcpy(output_buffer,"E01");
1383}
1384
1347/*****************************************************************************/ 1385/*****************************************************************************/
1348/* 1386/*
1349 * handle event interception and GDB remote protocol processing 1387 * handle event interception and GDB remote protocol processing
@@ -1840,6 +1878,10 @@ void gdbstub(int sigval)
1840 case 'k' : 1878 case 'k' :
1841 goto done; /* just continue */ 1879 goto done; /* just continue */
1842 1880
1881 /* detach */
1882 case 'D':
1883 gdbstub_strcpy(output_buffer, "OK");
1884 break;
1843 1885
1844 /* reset the whole machine (FIXME: system dependent) */ 1886 /* reset the whole machine (FIXME: system dependent) */
1845 case 'r': 1887 case 'r':
@@ -1852,6 +1894,14 @@ void gdbstub(int sigval)
1852 __debug_status.dcr |= DCR_SE; 1894 __debug_status.dcr |= DCR_SE;
1853 goto done; 1895 goto done;
1854 1896
1897 /* extended command */
1898 case 'v':
1899 if (strcmp(input_buffer, "vCont?") == 0) {
1900 output_buffer[0] = 0;
1901 break;
1902 }
1903 goto unsupported_cmd;
1904
1855 /* set baud rate (bBB) */ 1905 /* set baud rate (bBB) */
1856 case 'b': 1906 case 'b':
1857 ptr = &input_buffer[1]; 1907 ptr = &input_buffer[1];
@@ -1923,8 +1973,19 @@ void gdbstub(int sigval)
1923 gdbstub_strcpy(output_buffer,"OK"); 1973 gdbstub_strcpy(output_buffer,"OK");
1924 break; 1974 break;
1925 1975
1976 /* Thread-setting packet */
1977 case 'H':
1978 gdbstub_strcpy(output_buffer, "OK");
1979 break;
1980
1981 case 'q':
1982 gdbstub_handle_query();
1983 break;
1984
1926 default: 1985 default:
1986 unsupported_cmd:
1927 gdbstub_proto("### GDB Unsupported Cmd '%s'\n",input_buffer); 1987 gdbstub_proto("### GDB Unsupported Cmd '%s'\n",input_buffer);
1988 gdbstub_strcpy(output_buffer,"E01");
1928 break; 1989 break;
1929 } 1990 }
1930 1991