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

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>

authored by

David Howells and committed by
Linus Torvalds
7ca8b9c0 c6f6b596

+70 -2
+7
arch/frv/include/asm/gdb-stub.h
··· 12 12 #ifndef __ASM_GDB_STUB_H 13 13 #define __ASM_GDB_STUB_H 14 14 15 + #undef GDBSTUB_DEBUG_IO 15 16 #undef GDBSTUB_DEBUG_PROTOCOL 16 17 17 18 #include <asm/ptrace.h> ··· 108 107 extern void gdbstub_printk(const char *fmt, ...); 109 108 extern void debug_to_serial(const char *p, int n); 110 109 extern void console_set_baud(unsigned baud); 110 + 111 + #ifdef GDBSTUB_DEBUG_IO 112 + #define gdbstub_io(FMT,...) gdbstub_printk(FMT, ##__VA_ARGS__) 113 + #else 114 + #define gdbstub_io(FMT,...) ({ 0; }) 115 + #endif 111 116 112 117 #ifdef GDBSTUB_DEBUG_PROTOCOL 113 118 #define gdbstub_proto(FMT,...) gdbstub_printk(FMT,##__VA_ARGS__)
+2 -2
arch/frv/kernel/gdb-io.c
··· 171 171 return -EINTR; 172 172 } 173 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 175 return -EIO; 176 176 } 177 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 179 *_ch = ch & 0x7f; 180 180 return 0; 181 181 }
+61
arch/frv/kernel/gdb-stub.c
··· 1344 1344 1345 1345 } /* end gdbstub_get_mmu_state() */ 1346 1346 1347 + /* 1348 + * handle general query commands of the form 'qXXXXX' 1349 + */ 1350 + static 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 1387 * handle event interception and GDB remote protocol processing ··· 1878 1840 case 'k' : 1879 1841 goto done; /* just continue */ 1880 1842 1843 + /* detach */ 1844 + case 'D': 1845 + gdbstub_strcpy(output_buffer, "OK"); 1846 + break; 1881 1847 1882 1848 /* reset the whole machine (FIXME: system dependent) */ 1883 1849 case 'r': ··· 1893 1851 __debug_regs->dcr |= DCR_SE; 1894 1852 __debug_status.dcr |= DCR_SE; 1895 1853 goto done; 1854 + 1855 + /* extended command */ 1856 + case 'v': 1857 + if (strcmp(input_buffer, "vCont?") == 0) { 1858 + output_buffer[0] = 0; 1859 + break; 1860 + } 1861 + goto unsupported_cmd; 1896 1862 1897 1863 /* set baud rate (bBB) */ 1898 1864 case 'b': ··· 1973 1923 gdbstub_strcpy(output_buffer,"OK"); 1974 1924 break; 1975 1925 1926 + /* Thread-setting packet */ 1927 + case 'H': 1928 + gdbstub_strcpy(output_buffer, "OK"); 1929 + break; 1930 + 1931 + case 'q': 1932 + gdbstub_handle_query(); 1933 + break; 1934 + 1976 1935 default: 1936 + unsupported_cmd: 1977 1937 gdbstub_proto("### GDB Unsupported Cmd '%s'\n",input_buffer); 1938 + gdbstub_strcpy(output_buffer,"E01"); 1978 1939 break; 1979 1940 } 1980 1941