1 /* -*- tab-width:8 -*- */
4 Copyright (C) 2011 Peter Zotov <whitequark@whitequark.org>
5 Use of this source code is governed by a BSD-style
6 license that can be found in the LICENSE file.
14 #include <sys/types.h>
15 #include <sys/socket.h>
16 #include <netinet/in.h>
17 #include <arpa/inet.h>
20 #include <stlink-common.h>
22 #include "gdb-remote.h"
24 #define DEFAULT_LOGGING_LEVEL 50
25 #define DEFAULT_GDB_LISTEN_PORT 4242
27 #define STRINGIFY_inner(name) #name
28 #define STRINGIFY(name) STRINGIFY_inner(name)
30 #define FLASH_BASE 0x08000000
32 //Allways update the FLASH_PAGE before each use, by calling stlink_calculate_pagesize
33 #define FLASH_PAGE (sl->flash_pgsz)
35 static const char hex[] = "0123456789abcdef";
37 static const char* current_memory_map = NULL;
39 typedef struct _st_state_t {
40 // things from command line, bleh
42 // "/dev/serial/by-id/usb-FTDI_TTL232R-3V3_FTE531X6-if00-port0" is only 58 chars
49 int serve(stlink_t *sl, int port);
50 char* make_memory_map(stlink_t *sl);
53 int parse_options(int argc, char** argv, st_state_t *st) {
54 static struct option long_options[] = {
55 {"help", no_argument, NULL, 'h'},
56 {"verbose", optional_argument, NULL, 'v'},
57 {"device", required_argument, NULL, 'd'},
58 {"stlink_version", required_argument, NULL, 's'},
59 {"stlinkv1", no_argument, NULL, '1'},
60 {"listen_port", required_argument, NULL, 'p'},
63 const char * help_str = "%s - usage:\n\n"
64 " -h, --help\t\tPrint this help\n"
65 " -vXX, --verbose=XX\tspecify a specific verbosity level (0..99)\n"
66 " -v, --verbose\tspecify generally verbose logging\n"
67 " -d <device>, --device=/dev/stlink2_1\n"
68 "\t\t\tWhere is your stlink device connected?\n"
69 " -s X, --stlink_version=X\n"
70 "\t\t\tChoose what version of stlink to use, (defaults to 2)\n"
71 " -1, --stlinkv1\tForce stlink version 1\n"
72 " -p 4242, --listen_port=1234\n"
73 "\t\t\tSet the gdb server listen port. "
74 "(default port: " STRINGIFY(DEFAULT_GDB_LISTEN_PORT) ")\n"
81 while ((c = getopt_long(argc, argv, "hv::d:s:1p:", long_options, &option_index)) != -1) {
84 printf("XXXXX Shouldn't really normally come here, only if there's no corresponding option\n");
85 printf("option %s", long_options[option_index].name);
87 printf(" with arg %s", optarg);
92 printf(help_str, argv[0]);
97 st->logging_level = atoi(optarg);
99 st->logging_level = DEFAULT_LOGGING_LEVEL;
103 if (strlen(optarg) > sizeof (st->devicename)) {
104 fprintf(stderr, "device name too long: %zd\n", strlen(optarg));
106 strcpy(st->devicename, optarg);
110 st->stlink_version = 1;
113 sscanf(optarg, "%i", &q);
114 if (q < 0 || q > 2) {
115 fprintf(stderr, "stlink version %d unknown!\n", q);
118 st->stlink_version = q;
121 sscanf(optarg, "%i", &q);
123 fprintf(stderr, "Can't use a negative port to listen on: %d\n", q);
132 printf("non-option ARGV-elements: ");
133 while (optind < argc)
134 printf("%s ", argv[optind++]);
141 int main(int argc, char** argv) {
146 memset(&state, 0, sizeof(state));
148 state.stlink_version = 2;
149 state.logging_level = DEFAULT_LOGGING_LEVEL;
150 state.listen_port = DEFAULT_GDB_LISTEN_PORT;
151 parse_options(argc, argv, &state);
152 switch (state.stlink_version) {
154 sl = stlink_open_usb(state.logging_level);
155 if(sl == NULL) return 1;
158 sl = stlink_v1_open(state.logging_level);
159 if(sl == NULL) return 1;
163 printf("Chip ID is %08x, Core ID is %08x.\n", sl->chip_id, sl->core_id);
167 current_memory_map = make_memory_map(sl);
169 while(serve(sl, state.listen_port) == 0);
171 /* Switch back to mass storage mode before closing. */
173 stlink_exit_debug_mode(sl);
179 static const char* const memory_map_template_F4 =
180 "<?xml version=\"1.0\"?>"
181 "<!DOCTYPE memory-map PUBLIC \"+//IDN gnu.org//DTD GDB Memory Map V1.0//EN\""
182 " \"http://sourceware.org/gdb/gdb-memory-map.dtd\">"
184 " <memory type=\"rom\" start=\"0x00000000\" length=\"0x100000\"/>" // code = sram, bootrom or flash; flash is bigger
185 " <memory type=\"ram\" start=\"0x20000000\" length=\"0x30000\"/>" // sram
186 " <memory type=\"flash\" start=\"0x08000000\" length=\"0x10000\">" //Sectors 0..3
187 " <property name=\"blocksize\">0x4000</property>" //16kB
189 " <memory type=\"flash\" start=\"0x08010000\" length=\"0x10000\">" //Sector 4
190 " <property name=\"blocksize\">0x10000</property>" //64kB
192 " <memory type=\"flash\" start=\"0x08020000\" length=\"0x70000\">" //Sectors 5..11
193 " <property name=\"blocksize\">0x20000</property>" //128kB
195 " <memory type=\"ram\" start=\"0x40000000\" length=\"0x1fffffff\"/>" // peripheral regs
196 " <memory type=\"ram\" start=\"0xe0000000\" length=\"0x1fffffff\"/>" // cortex regs
197 " <memory type=\"rom\" start=\"0x1fff0000\" length=\"0x7800\"/>" // bootrom
198 " <memory type=\"rom\" start=\"0x1fffc000\" length=\"0x10\"/>" // option byte area
201 static const char* const memory_map_template =
202 "<?xml version=\"1.0\"?>"
203 "<!DOCTYPE memory-map PUBLIC \"+//IDN gnu.org//DTD GDB Memory Map V1.0//EN\""
204 " \"http://sourceware.org/gdb/gdb-memory-map.dtd\">"
206 " <memory type=\"rom\" start=\"0x00000000\" length=\"0x%x\"/>" // code = sram, bootrom or flash; flash is bigger
207 " <memory type=\"ram\" start=\"0x20000000\" length=\"0x%x\"/>" // sram 8k
208 " <memory type=\"flash\" start=\"0x08000000\" length=\"0x%x\">"
209 " <property name=\"blocksize\">0x%x</property>"
211 " <memory type=\"ram\" start=\"0x40000000\" length=\"0x1fffffff\"/>" // peripheral regs
212 " <memory type=\"ram\" start=\"0xe0000000\" length=\"0x1fffffff\"/>" // cortex regs
213 " <memory type=\"rom\" start=\"0x%08x\" length=\"0x%x\"/>" // bootrom
214 " <memory type=\"rom\" start=\"0x1ffff800\" length=\"0x8\"/>" // option byte area
217 char* make_memory_map(stlink_t *sl) {
218 /* This will be freed in serve() */
219 char* map = malloc(4096);
222 if(sl->chip_id==STM32F4_CHIP_ID) {
223 strcpy(map, memory_map_template_F4);
225 snprintf(map, 4096, memory_map_template,
228 sl->flash_size, sl->flash_pgsz,
229 sl->sys_base, sl->sys_size);
236 * DWT_COMP0 0xE0001020
237 * DWT_MASK0 0xE0001024
238 * DWT_FUNCTION0 0xE0001028
239 * DWT_COMP1 0xE0001030
240 * DWT_MASK1 0xE0001034
241 * DWT_FUNCTION1 0xE0001038
242 * DWT_COMP2 0xE0001040
243 * DWT_MASK2 0xE0001044
244 * DWT_FUNCTION2 0xE0001048
245 * DWT_COMP3 0xE0001050
246 * DWT_MASK3 0xE0001054
247 * DWT_FUNCTION3 0xE0001058
250 #define DATA_WATCH_NUM 4
252 enum watchfun { WATCHDISABLED = 0, WATCHREAD = 5, WATCHWRITE = 6, WATCHACCESS = 7 };
254 struct code_hw_watchpoint {
260 struct code_hw_watchpoint data_watches[DATA_WATCH_NUM];
262 static void init_data_watchpoints(stlink_t *sl) {
264 printf("init watchpoints\n");
267 // set trcena in debug command to turn on dwt unit
268 stlink_read_mem32(sl, 0xE000EDFC, 4);
270 stlink_write_mem32(sl, 0xE000EDFC, 4);
272 // make sure all watchpoints are cleared
273 memset(sl->q_buf, 0, 4);
274 for(int i = 0; i < DATA_WATCH_NUM; i++) {
275 data_watches[i].fun = WATCHDISABLED;
276 stlink_write_mem32(sl, 0xe0001028 + i * 16, 4);
280 static int add_data_watchpoint(stlink_t *sl, enum watchfun wf, stm32_addr_t addr, unsigned int len)
286 // find a free watchpoint
296 if((mask != -1) && (mask < 16)) {
297 for(i = 0; i < DATA_WATCH_NUM; i++) {
298 // is this an empty slot ?
299 if(data_watches[i].fun == WATCHDISABLED) {
301 printf("insert watchpoint %d addr %x wf %u mask %u len %d\n", i, addr, wf, mask, len);
304 data_watches[i].fun = wf;
305 data_watches[i].addr = addr;
306 data_watches[i].mask = mask;
308 // insert comparator address
309 sl->q_buf[0] = (addr & 0xff);
310 sl->q_buf[1] = ((addr >> 8) & 0xff);
311 sl->q_buf[2] = ((addr >> 16) & 0xff);
312 sl->q_buf[3] = ((addr >> 24) & 0xff);
314 stlink_write_mem32(sl, 0xE0001020 + i * 16, 4);
317 memset(sl->q_buf, 0, 4);
319 stlink_write_mem32(sl, 0xE0001024 + i * 16, 4);
322 memset(sl->q_buf, 0, 4);
324 stlink_write_mem32(sl, 0xE0001028 + i * 16, 4);
326 // just to make sure the matched bit is clear !
327 stlink_read_mem32(sl, 0xE0001028 + i * 16, 4);
334 printf("failure: add watchpoints addr %x wf %u len %u\n", addr, wf, len);
339 static int delete_data_watchpoint(stlink_t *sl, stm32_addr_t addr)
343 for(i = 0 ; i < DATA_WATCH_NUM; i++) {
344 if((data_watches[i].addr == addr) && (data_watches[i].fun != WATCHDISABLED)) {
346 printf("delete watchpoint %d addr %x\n", i, addr);
349 memset(sl->q_buf, 0, 4);
350 data_watches[i].fun = WATCHDISABLED;
351 stlink_write_mem32(sl, 0xe0001028 + i * 16, 4);
358 printf("failure: delete watchpoint addr %x\n", addr);
364 #define CODE_BREAK_NUM 6
365 #define CODE_BREAK_LOW 0x01
366 #define CODE_BREAK_HIGH 0x02
368 struct code_hw_breakpoint {
373 struct code_hw_breakpoint code_breaks[CODE_BREAK_NUM];
375 static void init_code_breakpoints(stlink_t *sl) {
376 memset(sl->q_buf, 0, 4);
377 sl->q_buf[0] = 0x03; // KEY | ENABLE
378 stlink_write_mem32(sl, CM3_REG_FP_CTRL, 4);
379 printf("KARL - should read back as 0x03, not 60 02 00 00\n");
380 stlink_read_mem32(sl, CM3_REG_FP_CTRL, 4);
382 memset(sl->q_buf, 0, 4);
383 for(int i = 0; i < CODE_BREAK_NUM; i++) {
384 code_breaks[i].type = 0;
385 stlink_write_mem32(sl, CM3_REG_FP_COMP0 + i * 4, 4);
389 static int update_code_breakpoint(stlink_t *sl, stm32_addr_t addr, int set) {
390 stm32_addr_t fpb_addr = addr & ~0x3;
391 int type = addr & 0x2 ? CODE_BREAK_HIGH : CODE_BREAK_LOW;
394 fprintf(stderr, "update_code_breakpoint: unaligned address %08x\n", addr);
399 for(int i = 0; i < CODE_BREAK_NUM; i++) {
400 if(fpb_addr == code_breaks[i].addr ||
401 (set && code_breaks[i].type == 0)) {
408 if(set) return -1; // Free slot not found
409 else return 0; // Breakpoint is already removed
412 struct code_hw_breakpoint* brk = &code_breaks[id];
414 brk->addr = fpb_addr;
416 if(set) brk->type |= type;
417 else brk->type &= ~type;
419 memset(sl->q_buf, 0, 4);
423 printf("clearing hw break %d\n", id);
426 stlink_write_mem32(sl, 0xe0002008 + id * 4, 4);
428 sl->q_buf[0] = ( brk->addr & 0xff) | 1;
429 sl->q_buf[1] = ((brk->addr >> 8) & 0xff);
430 sl->q_buf[2] = ((brk->addr >> 16) & 0xff);
431 sl->q_buf[3] = ((brk->addr >> 24) & 0xff) | (brk->type << 6);
434 printf("setting hw break %d at %08x (%d)\n",
435 id, brk->addr, brk->type);
436 printf("reg %02x %02x %02x %02x\n",
437 sl->q_buf[3], sl->q_buf[2], sl->q_buf[1], sl->q_buf[0]);
440 stlink_write_mem32(sl, 0xe0002008 + id * 4, 4);
452 struct flash_block* next;
455 static struct flash_block* flash_root;
457 static int flash_add_block(stm32_addr_t addr, unsigned length, stlink_t *sl) {
459 if(addr < FLASH_BASE || addr + length > FLASH_BASE + sl->flash_size) {
460 fprintf(stderr, "flash_add_block: incorrect bounds\n");
464 stlink_calculate_pagesize(sl, addr);
465 if(addr % FLASH_PAGE != 0 || length % FLASH_PAGE != 0) {
466 fprintf(stderr, "flash_add_block: unaligned block\n");
470 struct flash_block* new = malloc(sizeof(struct flash_block));
471 new->next = flash_root;
474 new->length = length;
475 new->data = calloc(length, 1);
482 static int flash_populate(stm32_addr_t addr, uint8_t* data, unsigned length) {
483 int fit_blocks = 0, fit_length = 0;
485 for(struct flash_block* fb = flash_root; fb; fb = fb->next) {
486 /* Block: ------X------Y--------
490 * Block intersects with data, if:
494 unsigned X = fb->addr, Y = fb->addr + fb->length;
495 unsigned a = addr, b = addr + length;
497 // from start of the block
498 unsigned start = (a > X ? a : X) - X;
499 unsigned end = (b > Y ? Y : b) - X;
501 memcpy(fb->data + start, data, end - start);
504 fit_length += end - start;
508 if(fit_blocks == 0) {
509 fprintf(stderr, "Unfit data block %08x -> %04x\n", addr, length);
513 if(fit_length != length) {
514 fprintf(stderr, "warning: data block %08x -> %04x truncated to %04x\n",
515 addr, length, fit_length);
516 fprintf(stderr, "(this is not an error, just a GDB glitch)\n");
522 static int flash_go(stlink_t *sl) {
525 // Some kinds of clock settings do not allow writing to flash.
528 for(struct flash_block* fb = flash_root; fb; fb = fb->next) {
530 printf("flash_do: block %08x -> %04x\n", fb->addr, fb->length);
533 unsigned length = fb->length;
534 for(stm32_addr_t page = fb->addr; page < fb->addr + fb->length; page += FLASH_PAGE) {
537 stlink_calculate_pagesize(sl, page);
540 printf("flash_do: page %08x\n", page);
543 if(stlink_write_flash(sl, page, fb->data + (page - fb->addr),
544 length > FLASH_PAGE ? FLASH_PAGE : length) < 0)
554 for(struct flash_block* fb = flash_root, *next; fb; fb = next) {
565 int serve(stlink_t *sl, int port) {
566 int sock = socket(AF_INET, SOCK_STREAM, 0);
572 unsigned int val = 1;
573 setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val));
575 struct sockaddr_in serv_addr = {0};
576 serv_addr.sin_family = AF_INET;
577 serv_addr.sin_addr.s_addr = inet_addr("127.0.0.1");
578 serv_addr.sin_port = htons(port);
580 if(bind(sock, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0) {
585 if(listen(sock, 5) < 0) {
590 stlink_force_debug(sl);
592 init_code_breakpoints(sl);
593 init_data_watchpoints(sl);
595 printf("Listening at *:%d...\n", port);
597 int client = accept(sock, NULL, NULL);
598 signal (SIGINT, SIG_DFL);
606 printf("GDB connected.\n");
609 * To allow resetting the chip from GDB it is required to
610 * emulate attaching and detaching to target.
612 unsigned int attached = 1;
617 int status = gdb_recv_packet(client, &packet);
619 fprintf(stderr, "cannot recv: %d\n", status);
624 printf("recv: %s\n", packet);
632 if(packet[1] == 'P' || packet[1] == 'C' || packet[1] == 'L') {
637 char *separator = strstr(packet, ":"), *params = "";
638 if(separator == NULL) {
639 separator = packet + strlen(packet);
641 params = separator + 1;
644 unsigned queryNameLength = (separator - &packet[1]);
645 char* queryName = calloc(queryNameLength + 1, 1);
646 strncpy(queryName, &packet[1], queryNameLength);
649 printf("query: %s;%s\n", queryName, params);
652 if(!strcmp(queryName, "Supported")) {
653 reply = strdup("PacketSize=3fff;qXfer:memory-map:read+");
654 } else if(!strcmp(queryName, "Xfer")) {
655 char *type, *op, *s_addr, *s_length;
657 char *annex __attribute__((unused));
659 type = strsep(&tok, ":");
660 op = strsep(&tok, ":");
661 annex = strsep(&tok, ":");
662 s_addr = strsep(&tok, ",");
665 unsigned addr = strtoul(s_addr, NULL, 16),
666 length = strtoul(s_length, NULL, 16);
669 printf("Xfer: type:%s;op:%s;annex:%s;addr:%d;length:%d\n",
670 type, op, annex, addr, length);
673 const char* data = NULL;
675 if(!strcmp(type, "memory-map") && !strcmp(op, "read"))
676 data = current_memory_map;
679 unsigned data_length = strlen(data);
680 if(addr + length > data_length)
681 length = data_length - addr;
686 reply = calloc(length + 2, 1);
688 strncpy(&reply[1], data, length);
703 char *cmdName = strtok_r(packet, ":;", ¶ms);
705 cmdName++; // vCommand -> Command
707 if(!strcmp(cmdName, "FlashErase")) {
708 char *s_addr, *s_length;
711 s_addr = strsep(&tok, ",");
714 unsigned addr = strtoul(s_addr, NULL, 16),
715 length = strtoul(s_length, NULL, 16);
718 printf("FlashErase: addr:%08x,len:%04x\n",
722 if(flash_add_block(addr, length, sl) < 0) {
723 reply = strdup("E00");
725 reply = strdup("OK");
727 } else if(!strcmp(cmdName, "FlashWrite")) {
731 s_addr = strsep(&tok, ":");
734 unsigned addr = strtoul(s_addr, NULL, 16);
735 unsigned data_length = status - (data - packet);
737 // Length of decoded data cannot be more than
738 // encoded, as escapes are removed.
739 // Additional byte is reserved for alignment fix.
740 uint8_t *decoded = calloc(data_length + 1, 1);
741 unsigned dec_index = 0;
742 for(int i = 0; i < data_length; i++) {
743 if(data[i] == 0x7d) {
745 decoded[dec_index++] = data[i] ^ 0x20;
747 decoded[dec_index++] = data[i];
752 if(dec_index % 2 != 0)
756 printf("binary packet %d -> %d\n", data_length, dec_index);
759 if(flash_populate(addr, decoded, dec_index) < 0) {
760 reply = strdup("E00");
762 reply = strdup("OK");
764 } else if(!strcmp(cmdName, "FlashDone")) {
765 if(flash_go(sl) < 0) {
766 reply = strdup("E00");
768 reply = strdup("OK");
770 } else if(!strcmp(cmdName, "Kill")) {
773 reply = strdup("OK");
786 int status = gdb_check_for_interrupt(client);
788 fprintf(stderr, "cannot check for int: %d\n", status);
793 stlink_force_debug(sl);
798 if(sl->core_stat == STLINK_CORE_HALTED) {
805 reply = strdup("S05"); // TRAP
811 reply = strdup("S05"); // TRAP
816 reply = strdup("S05"); // TRAP
818 /* Stub shall reply OK if not attached. */
819 reply = strdup("OK");
824 stlink_read_all_regs(sl, ®p);
826 reply = calloc(8 * 16 + 1, 1);
827 for(int i = 0; i < 16; i++)
828 sprintf(&reply[i * 8], "%08x", htonl(regp.r[i]));
833 unsigned id = strtoul(&packet[1], NULL, 16);
834 unsigned myreg = 0xDEADDEAD;
837 stlink_read_reg(sl, id, ®p);
838 myreg = htonl(regp.r[id]);
839 } else if(id == 0x19) {
840 stlink_read_reg(sl, 16, ®p);
841 myreg = htonl(regp.xpsr);
843 reply = strdup("E00");
846 reply = calloc(8 + 1, 1);
847 sprintf(reply, "%08x", myreg);
853 char* s_reg = &packet[1];
854 char* s_value = strstr(&packet[1], "=") + 1;
856 unsigned reg = strtoul(s_reg, NULL, 16);
857 unsigned value = strtoul(s_value, NULL, 16);
860 stlink_write_reg(sl, ntohl(value), reg);
861 } else if(reg == 0x19) {
862 stlink_write_reg(sl, ntohl(value), 16);
864 reply = strdup("E00");
868 reply = strdup("OK");
875 for(int i = 0; i < 16; i++) {
877 strncpy(str, &packet[1 + i * 8], 8);
878 uint32_t reg = strtoul(str, NULL, 16);
879 stlink_write_reg(sl, ntohl(reg), i);
882 reply = strdup("OK");
886 char* s_start = &packet[1];
887 char* s_count = strstr(&packet[1], ",") + 1;
889 stm32_addr_t start = strtoul(s_start, NULL, 16);
890 unsigned count = strtoul(s_count, NULL, 16);
892 unsigned adj_start = start % 4;
894 stlink_read_mem32(sl, start - adj_start, (count % 4 == 0) ?
895 count : count + 4 - (count % 4));
897 reply = calloc(count * 2 + 1, 1);
898 for(int i = 0; i < count; i++) {
899 reply[i * 2 + 0] = hex[sl->q_buf[i + adj_start] >> 4];
900 reply[i * 2 + 1] = hex[sl->q_buf[i + adj_start] & 0xf];
907 char* s_start = &packet[1];
908 char* s_count = strstr(&packet[1], ",") + 1;
909 char* hexdata = strstr(packet, ":") + 1;
911 stm32_addr_t start = strtoul(s_start, NULL, 16);
912 unsigned count = strtoul(s_count, NULL, 16);
914 for(int i = 0; i < count; i ++) {
915 char hex[3] = { hexdata[i*2], hexdata[i*2+1], 0 };
916 uint8_t byte = strtoul(hex, NULL, 16);
920 if((count % 4) == 0 && (start % 4) == 0) {
921 stlink_write_mem32(sl, start, count);
923 stlink_write_mem8(sl, start, count);
926 reply = strdup("OK");
933 stm32_addr_t addr = strtoul(&packet[3], &endptr, 16);
934 stm32_addr_t len = strtoul(&endptr[1], NULL, 16);
938 if(update_code_breakpoint(sl, addr, 1) < 0) {
939 reply = strdup("E00");
941 reply = strdup("OK");
945 case '2': // insert write watchpoint
946 case '3': // insert read watchpoint
947 case '4': // insert access watchpoint
950 if(packet[1] == '2') {
952 } else if(packet[1] == '3') {
956 if(add_data_watchpoint(sl, wf, addr, len) < 0) {
957 reply = strdup("E00");
959 reply = strdup("OK");
972 stm32_addr_t addr = strtoul(&packet[3], &endptr, 16);
973 //stm32_addr_t len = strtoul(&endptr[1], NULL, 16);
976 case '1': // remove breakpoint
977 update_code_breakpoint(sl, addr, 0);
978 reply = strdup("OK");
981 case '2' : // remove write watchpoint
982 case '3' : // remove read watchpoint
983 case '4' : // remove access watchpoint
984 if(delete_data_watchpoint(sl, addr) < 0) {
985 reply = strdup("E00");
987 reply = strdup("OK");
999 * Enter extended mode which allows restarting.
1000 * We do support that always.
1003 reply = strdup("OK");
1009 /* Reset the core. */
1012 init_code_breakpoints(sl);
1013 init_data_watchpoints(sl);
1017 reply = strdup("OK");
1028 printf("send: %s\n", reply);
1031 int result = gdb_send_packet(client, reply);
1033 fprintf(stderr, "cannot send: %d\n", result);