- added instructions how to update the online documentation
[bochs-mirror.git] / gdbstub.cc
bloba488bdb2680777ad261abdfd593e911cefa2b4d2
1 /////////////////////////////////////////////////////////////////////////
2 // $Id: gdbstub.cc,v 1.35 2008/12/05 22:34:42 sshwarts Exp $
3 /////////////////////////////////////////////////////////////////////////
4 //
5 // Copyright (C) 2002-2006 The Bochs Project Team
6 //
7 // This library is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU Lesser General Public
9 // License as published by the Free Software Foundation; either
10 // version 2 of the License, or (at your option) any later version.
12 // This library is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 // Lesser General Public License for more details.
17 // You should have received a copy of the GNU Lesser General Public
18 // License along with this library; if not, write to the Free Software
19 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 #include <stdio.h>
22 #include <stdlib.h>
23 #include <sys/types.h>
24 #ifdef __MINGW32__
25 #include <winsock2.h>
26 #define SIGTRAP 5
27 #else
28 #include <sys/socket.h>
29 #include <netinet/in.h>
30 #include <netinet/tcp.h>
31 #include <arpa/inet.h>
32 #include <signal.h>
33 #include <netdb.h>
34 #endif
36 #define NEED_CPU_REG_SHORTCUTS 1
38 #include "bochs.h"
39 #include "cpu/cpu.h"
40 #include "iodev/iodev.h"
42 #define LOG_THIS gdbstublog->
43 #define IFDBG(x) x
45 static int last_stop_reason = GDBSTUB_STOP_NO_REASON;
47 #define GDBSTUB_EXECUTION_BREAKPOINT (0xac1)
48 #define GDBSTUB_TRACE (0xac2)
49 #define GDBSTUB_USER_BREAK (0xac3)
51 static bx_list_c *gdbstub_list;
52 static int listen_socket_fd;
53 static int socket_fd;
54 static logfunctions *gdbstublog;
56 static int hex(char ch)
58 if ((ch >= 'a') && (ch <= 'f')) return(ch - 'a' + 10);
59 if ((ch >= '0') && (ch <= '9')) return(ch - '0');
60 if ((ch >= 'A') && (ch <= 'F')) return(ch - 'A' + 10);
61 return(-1);
64 static char buf[4096], *bufptr = buf;
66 static void flush_debug_buffer()
68 char *p = buf;
69 while (p != bufptr) {
70 int n = send(socket_fd, p, bufptr-p, 0);
71 if (n == -1) {
72 BX_ERROR(("error on debug socket: %m"));
73 break;
75 p += n;
77 bufptr = buf;
80 static void put_debug_char(char ch)
82 if (bufptr == buf + sizeof buf)
83 flush_debug_buffer();
84 *bufptr++ = ch;
87 static char get_debug_char(void)
89 char ch;
91 recv(socket_fd, &ch, 1, 0);
93 return(ch);
96 static const char hexchars[]="0123456789abcdef";
98 static void put_reply(char* buffer)
100 unsigned char csum;
101 int i;
103 BX_DEBUG(("put_buffer '%s'", buffer));
105 do {
106 put_debug_char('$');
108 csum = 0;
110 i = 0;
111 while (buffer[i] != 0)
113 put_debug_char(buffer[i]);
114 csum = csum + buffer[i];
115 i++;
118 put_debug_char('#');
119 put_debug_char(hexchars[csum >> 4]);
120 put_debug_char(hexchars[csum % 16]);
121 flush_debug_buffer();
122 } while (get_debug_char() != '+');
125 static void get_command(char* buffer)
127 unsigned char checksum;
128 unsigned char xmitcsum;
129 char ch;
130 unsigned int count;
131 unsigned int i;
133 do {
134 while ((ch = get_debug_char()) != '$');
136 checksum = 0;
137 xmitcsum = 0;
138 count = 0;
140 while (1)
142 ch = get_debug_char();
143 if (ch == '#') break;
144 checksum = checksum + ch;
145 buffer[count] = ch;
146 count++;
148 buffer[count] = 0;
150 if (ch == '#')
152 xmitcsum = hex(get_debug_char()) << 4;
153 xmitcsum += hex(get_debug_char());
154 if (checksum != xmitcsum)
156 BX_INFO(("Bad checksum"));
160 if (checksum != xmitcsum)
162 put_debug_char('-');
163 flush_debug_buffer();
165 else
167 put_debug_char('+');
168 if (buffer[2] == ':')
170 put_debug_char(buffer[0]);
171 put_debug_char(buffer[1]);
172 count = strlen(buffer);
173 for (i = 3; i <= count; i++)
175 buffer[i - 3] = buffer[i];
178 flush_debug_buffer();
180 } while (checksum != xmitcsum);
183 void hex2mem(char* buf, unsigned char* mem, int count)
185 unsigned char ch;
187 for (int i = 0; i<count; i++)
189 ch = hex(*buf++) << 4;
190 ch = ch + hex(*buf++);
191 *mem++ = ch;
195 char* mem2hex(char* mem, char* buf, int count)
197 unsigned char ch;
199 for (int i = 0; i<count; i++)
201 ch = *mem++;
202 *buf++ = hexchars[ch >> 4];
203 *buf++ = hexchars[ch % 16];
205 *buf = 0;
206 return(buf);
209 int hexdigit(char c)
211 if (isdigit(c))
212 return c - '0';
213 else if (isupper(c))
214 return c - 'A' + 10;
215 else
216 return c - 'a' + 10;
219 Bit64u read_little_endian_hex(char *&buf)
221 int byte;
222 Bit64u ret = 0;
223 int n = 0;
224 while (isxdigit(*buf)) {
225 byte = hexdigit(*buf++);
226 if (isxdigit(*buf))
227 byte = (byte << 4) | hexdigit(*buf++);
228 ret |= (unsigned long long)byte << (n*8);
229 ++n;
231 return ret;
234 static int continue_thread = -1;
235 static int other_thread = 0;
237 #if !BX_SUPPORT_X86_64
238 #define NUMREGS (16)
239 #define NUMREGSBYTES (NUMREGS * 4)
240 static int registers[NUMREGS];
241 #endif
243 #define MAX_BREAKPOINTS (255)
244 static unsigned int breakpoints[MAX_BREAKPOINTS] = {0,};
245 static unsigned int nr_breakpoints = 0;
247 static int stub_trace_flag = 0;
248 static int instr_count = 0;
249 static int saved_eip = 0;
250 static int bx_enter_gdbstub = 0;
252 void bx_gdbstub_break(void)
254 bx_enter_gdbstub = 1;
257 int bx_gdbstub_check(unsigned int eip)
259 unsigned int i;
260 unsigned char ch;
261 long arg;
262 int r;
263 #if defined(__CYGWIN__) || defined(__MINGW32__)
264 fd_set fds;
265 struct timeval tv = {0, 0};
266 #endif
268 if (bx_enter_gdbstub)
270 bx_enter_gdbstub = 0;
271 last_stop_reason = GDBSTUB_EXECUTION_BREAKPOINT;
272 return GDBSTUB_EXECUTION_BREAKPOINT;
275 instr_count++;
277 if ((instr_count % 500) == 0)
279 #if !defined(__CYGWIN__) && !defined(__MINGW32__)
280 arg = fcntl(socket_fd, F_GETFL);
281 fcntl(socket_fd, F_SETFL, arg | O_NONBLOCK);
282 r = recv(socket_fd, &ch, 1, 0);
283 fcntl(socket_fd, F_SETFL, arg);
284 #else
285 FD_ZERO(&fds);
286 FD_SET(socket_fd, &fds);
287 r = select(socket_fd + 1, &fds, NULL, NULL, &tv);
288 if (r == 1)
290 r = recv(socket_fd, (char *)&ch, 1, 0);
292 #endif
293 if (r == 1)
295 BX_INFO(("Got byte %x", (unsigned int)ch));
296 last_stop_reason = GDBSTUB_USER_BREAK;
297 return GDBSTUB_USER_BREAK;
301 for (i = 0; i < nr_breakpoints; i++)
303 if (eip == breakpoints[i])
305 BX_INFO(("found breakpoint at %x", eip));
306 last_stop_reason = GDBSTUB_EXECUTION_BREAKPOINT;
307 return GDBSTUB_EXECUTION_BREAKPOINT;
311 if (stub_trace_flag == 1)
313 last_stop_reason = GDBSTUB_TRACE;
314 return GDBSTUB_TRACE;
316 last_stop_reason = GDBSTUB_STOP_NO_REASON;
317 return GDBSTUB_STOP_NO_REASON;
320 static int remove_breakpoint(unsigned int addr, int len)
322 unsigned int i;
324 if (len != 1)
326 return(0);
329 for (i = 0; i < MAX_BREAKPOINTS; i++)
331 if (breakpoints[i] == addr)
333 BX_INFO(("Removing breakpoint at %x", addr));
334 breakpoints[i] = 0;
335 return(1);
338 return(0);
341 static void insert_breakpoint(unsigned int addr)
343 unsigned int i;
345 BX_INFO(("setting breakpoint at %x", addr));
347 for (i = 0; i < (unsigned)MAX_BREAKPOINTS; i++)
349 if (breakpoints[i] == 0)
351 breakpoints[i] = addr;
352 if (i >= nr_breakpoints)
354 nr_breakpoints = i + 1;
356 return;
359 BX_INFO(("No slot for breakpoint"));
362 static void do_pc_breakpoint(int insert, unsigned long long addr, int len)
364 for (int i = 0; i < len; ++i)
365 if (insert)
366 insert_breakpoint(addr+i);
367 else
368 remove_breakpoint(addr+i, 1);
371 static void do_breakpoint(int insert, char* buffer)
373 char* ebuf;
374 unsigned long type = strtoul(buffer, &ebuf, 16);
375 unsigned long long addr = strtoull(ebuf+1, &ebuf, 16);
376 unsigned long len = strtoul(ebuf+1, &ebuf, 16);
377 switch (type) {
378 case 0:
379 case 1:
380 do_pc_breakpoint(insert, addr, len);
381 put_reply("OK");
382 break;
383 default:
384 put_reply("");
385 break;
389 static void write_signal(char* buf, int signal)
391 buf[0] = hexchars[signal >> 4];
392 buf[1] = hexchars[signal % 16];
393 buf[2] = 0;
396 static int access_linear(Bit64u laddress,
397 unsigned len,
398 unsigned int rw,
399 Bit8u* data)
401 bx_phy_address phys;
402 bx_bool valid;
404 if (((laddress & 0xfff) + len) > 4096)
406 valid = access_linear(laddress,
407 4096 - (laddress & 0xfff),
409 data);
410 if (!valid) return(0);
412 valid = access_linear(laddress,
413 len + (laddress & 0xfff) - 4096,
415 (Bit8u *)((unsigned long)data +
416 4096 - (laddress & 0xfff)));
417 return(valid);
420 valid = BX_CPU(0)->dbg_xlate_linear2phy(laddress, (bx_phy_address*)&phys);
421 if (!valid) return(0);
423 if (rw & 1) {
424 valid = BX_MEM(0)->dbg_set_mem(phys, len, data);
425 } else {
426 valid = BX_MEM(0)->dbg_fetch_mem(BX_CPU(0), phys, len, data);
429 return(valid);
432 static void debug_loop(void)
434 char buffer[255];
435 char obuf[255];
436 int ne = 0;
437 unsigned char mem[255];
439 while (ne == 0)
441 get_command(buffer);
442 BX_DEBUG(("get_buffer '%s'", buffer));
444 switch (buffer[0])
446 case 'c':
448 char buf[255];
449 Bit32u new_eip;
451 if (buffer[1] != 0)
453 new_eip = (Bit32u) atoi(buffer + 1);
455 BX_INFO(("continuing at %x", new_eip));
457 for (int i=0; i<BX_SMP_PROCESSORS; i++) {
458 BX_CPU(i)->invalidate_prefetch_q();
461 saved_eip = EIP;
462 BX_CPU_THIS_PTR gen_reg[BX_32BIT_REG_EIP].dword.erx = new_eip;
465 stub_trace_flag = 0;
466 bx_cpu.cpu_loop(0);
468 DEV_vga_refresh();
470 if (buffer[1] != 0)
472 bx_cpu.invalidate_prefetch_q();
473 BX_CPU_THIS_PTR gen_reg[BX_32BIT_REG_EIP].dword.erx = saved_eip;
476 BX_INFO(("stopped with %x", last_stop_reason));
477 buf[0] = 'S';
478 if (last_stop_reason == GDBSTUB_EXECUTION_BREAKPOINT ||
479 last_stop_reason == GDBSTUB_TRACE)
481 write_signal(&buf[1], SIGTRAP);
483 else
485 write_signal(&buf[1], 0);
487 put_reply(buf);
488 break;
491 case 's':
493 char buf[255];
495 BX_INFO(("stepping"));
496 stub_trace_flag = 1;
497 bx_cpu.cpu_loop(0);
498 DEV_vga_refresh();
499 stub_trace_flag = 0;
500 BX_INFO(("stopped with %x", last_stop_reason));
501 buf[0] = 'S';
502 if (last_stop_reason == GDBSTUB_EXECUTION_BREAKPOINT ||
503 last_stop_reason == GDBSTUB_TRACE)
505 write_signal(&buf[1], SIGTRAP);
507 else
509 write_signal(&buf[1], SIGTRAP);
511 put_reply(buf);
512 break;
515 case 'M':
517 Bit64u addr;
518 int len;
519 unsigned char mem[255];
520 char* ebuf;
522 addr = strtoull(&buffer[1], &ebuf, 16);
523 len = strtoul(ebuf + 1, &ebuf, 16);
524 hex2mem(ebuf + 1, mem, len);
526 if (len == 1 && mem[0] == 0xcc)
528 insert_breakpoint(addr);
529 put_reply("OK");
531 else if (remove_breakpoint(addr, len))
533 put_reply("OK");
535 else
537 if (access_linear(addr, len, BX_WRITE, mem))
539 put_reply("OK");
541 else
543 put_reply("Eff");
546 break;
549 case 'm':
551 Bit64u addr;
552 int len;
553 char* ebuf;
555 addr = strtoull(&buffer[1], &ebuf, 16);
556 len = strtoul(ebuf + 1, NULL, 16);
557 BX_INFO(("addr %Lx len %x", addr, len));
559 access_linear(addr, len, BX_READ, mem);
560 mem2hex((char *)mem, obuf, len);
561 put_reply(obuf);
562 break;
565 case 'P':
567 int reg;
568 unsigned long long value;
569 char* ebuf;
571 reg = strtoul(&buffer[1], &ebuf, 16);
572 ++ebuf;
573 value = read_little_endian_hex(ebuf);
575 BX_INFO(("reg %d set to %Lx", reg, value));
576 #if BX_SUPPORT_X86_64 == 0
577 switch (reg)
579 case 0:
580 EAX = value;
581 break;
583 case 1:
584 ECX = value;
585 break;
587 case 2:
588 EBX = value;
589 break;
591 case 3:
592 EDX = value;
593 break;
595 case 4:
596 ESP = value;
597 break;
599 case 5:
600 EBP = value;
601 break;
603 case 6:
604 ESI = value;
605 break;
607 case 7:
608 EDI = value;
609 break;
611 case 8:
612 EIP = value;
613 BX_CPU_THIS_PTR invalidate_prefetch_q();
614 break;
616 default:
617 break;
619 #else
620 switch (reg)
622 case 0:
623 RAX = value;
624 break;
626 case 1:
627 RBX = value;
628 break;
630 case 2:
631 RCX = value;
632 break;
634 case 3:
635 RDX = value;
636 break;
638 case 4:
639 RSP = value;
640 break;
642 case 5:
643 RBP = value;
644 break;
646 case 6:
647 RSI = value;
648 break;
650 case 7:
651 RDI = value;
652 break;
654 case 8:
655 R8 = value;
656 break;
658 case 9:
659 R9 = value;
660 break;
662 case 10:
663 R10 = value;
664 break;
666 case 11:
667 R11 = value;
668 break;
670 case 12:
671 R12 = value;
672 break;
674 case 13:
675 R13 = value;
676 break;
678 case 14:
679 R15 = value;
680 break;
682 case 15:
683 R15 = value;
684 break;
686 case 16:
687 RIP = value;
688 BX_CPU_THIS_PTR invalidate_prefetch_q();
689 break;
691 default:
692 break;
694 #endif
695 put_reply("OK");
697 break;
700 case 'g':
701 #if BX_SUPPORT_X86_64 == 0
702 registers[0] = EAX;
703 registers[1] = ECX;
704 registers[2] = EDX;
705 registers[3] = EBX;
706 registers[4] = ESP;
707 registers[5] = EBP;
708 registers[6] = ESI;
709 registers[7] = EDI;
710 if (last_stop_reason == GDBSTUB_EXECUTION_BREAKPOINT)
712 registers[8] = EIP + 1;
714 else
716 registers[8] = EIP;
718 registers[9] = BX_CPU_THIS_PTR read_eflags();
719 registers[10] =
720 BX_CPU_THIS_PTR sregs[BX_SEG_REG_CS].selector.value;
721 registers[11] =
722 BX_CPU_THIS_PTR sregs[BX_SEG_REG_SS].selector.value;
723 registers[12] =
724 BX_CPU_THIS_PTR sregs[BX_SEG_REG_DS].selector.value;
725 registers[13] =
726 BX_CPU_THIS_PTR sregs[BX_SEG_REG_ES].selector.value;
727 registers[14] =
728 BX_CPU_THIS_PTR sregs[BX_SEG_REG_FS].selector.value;
729 registers[15] =
730 BX_CPU_THIS_PTR sregs[BX_SEG_REG_GS].selector.value;
731 mem2hex((char *)registers, obuf, NUMREGSBYTES);
732 #else
733 #define PUTREG(buf, val, len) do { \
734 Bit64u u = (val); \
735 (buf) = mem2hex((char*)&u, (buf), (len)); \
736 } while (0)
737 char* buf;
738 buf = obuf;
739 PUTREG(buf, RAX, 8);
740 PUTREG(buf, RBX, 8);
741 PUTREG(buf, RCX, 8);
742 PUTREG(buf, RDX, 8);
743 PUTREG(buf, RSI, 8);
744 PUTREG(buf, RDI, 8);
745 PUTREG(buf, RBP, 8);
746 PUTREG(buf, RSP, 8);
747 PUTREG(buf, R8, 8);
748 PUTREG(buf, R9, 8);
749 PUTREG(buf, R10, 8);
750 PUTREG(buf, R11, 8);
751 PUTREG(buf, R12, 8);
752 PUTREG(buf, R13, 8);
753 PUTREG(buf, R14, 8);
754 PUTREG(buf, R15, 8);
755 Bit64u rip;
756 rip = RIP;
757 if (last_stop_reason == GDBSTUB_EXECUTION_BREAKPOINT)
759 ++rip;
761 PUTREG(buf, rip, 8);
762 PUTREG(buf, BX_CPU_THIS_PTR read_eflags(), 4);
763 PUTREG(buf, BX_CPU_THIS_PTR sregs[BX_SEG_REG_CS].selector.value, 4);
764 PUTREG(buf, BX_CPU_THIS_PTR sregs[BX_SEG_REG_SS].selector.value, 4);
765 PUTREG(buf, BX_CPU_THIS_PTR sregs[BX_SEG_REG_DS].selector.value, 4);
766 PUTREG(buf, BX_CPU_THIS_PTR sregs[BX_SEG_REG_ES].selector.value, 4);
767 PUTREG(buf, BX_CPU_THIS_PTR sregs[BX_SEG_REG_FS].selector.value, 4);
768 PUTREG(buf, BX_CPU_THIS_PTR sregs[BX_SEG_REG_GS].selector.value, 4);
769 #endif
770 put_reply(obuf);
771 break;
773 case '?':
774 sprintf(obuf, "S%02x", SIGTRAP);
775 put_reply(obuf);
776 break;
778 case 'H':
779 if (buffer[1] == 'c')
781 continue_thread = strtol(&buffer[2], NULL, 16);
782 put_reply("OK");
784 else if (buffer[1] == 'g')
786 other_thread = strtol(&buffer[2], NULL, 16);
787 put_reply("OK");
789 else
791 put_reply("Eff");
793 break;
795 case 'q':
796 if (buffer[1] == 'C')
798 sprintf(obuf,"%Lx", (Bit64u)1);
799 put_reply(obuf);
801 else if (strncmp(&buffer[1], "Offsets", strlen("Offsets")) == 0)
803 sprintf(obuf, "Text=%x;Data=%x;Bss=%x",
804 SIM->get_param_num("text_base", gdbstub_list)->get(),
805 SIM->get_param_num("data_base", gdbstub_list)->get(),
806 SIM->get_param_num("bss_base", gdbstub_list)->get());
807 put_reply(obuf);
809 else if (strncmp(&buffer[1], "Supported", strlen("Supported")) == 0)
811 put_reply("");
813 else
815 put_reply("Eff");
817 break;
819 case 'Z':
820 do_breakpoint(1, buffer+1);
821 break;
822 case 'z':
823 do_breakpoint(0, buffer+1);
824 break;
825 case 'k':
826 BX_PANIC(("Debugger asked us to quit"));
827 break;
829 default:
830 put_reply("");
831 break;
836 static void wait_for_connect(int portn)
838 struct sockaddr_in sockaddr;
839 socklen_t sockaddr_len;
840 struct protoent *protoent;
841 int r;
842 int opt;
844 listen_socket_fd = socket(PF_INET, SOCK_STREAM, 0);
845 if (listen_socket_fd == -1)
847 BX_PANIC(("Failed to create socket"));
848 exit(1);
851 /* Allow rapid reuse of this port */
852 opt = 1;
853 #if __MINGW32__
854 r = setsockopt(listen_socket_fd, SOL_SOCKET, SO_REUSEADDR, (const char *)&opt, sizeof(opt));
855 #else
856 r = setsockopt(listen_socket_fd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt));
857 #endif
858 if (r == -1)
860 BX_INFO(("setsockopt(SO_REUSEADDR) failed"));
863 memset (&sockaddr, '\000', sizeof sockaddr);
864 #if BX_HAVE_SOCKADDR_IN_SIN_LEN
865 // if you don't have sin_len change that to #if 0. This is the subject of
866 // bug [ 626840 ] no 'sin_len' in 'struct sockaddr_in'.
867 sockaddr.sin_len = sizeof sockaddr;
868 #endif
869 sockaddr.sin_family = AF_INET;
870 sockaddr.sin_port = htons(portn);
871 sockaddr.sin_addr.s_addr = htonl(INADDR_ANY);
873 r = bind(listen_socket_fd, (struct sockaddr *)&sockaddr, sizeof(sockaddr));
874 if (r == -1)
876 BX_PANIC(("Failed to bind socket"));
879 r = listen(listen_socket_fd, 0);
880 if (r == -1)
882 BX_PANIC(("Failed to listen on socket"));
885 sockaddr_len = sizeof sockaddr;
886 socket_fd = accept(listen_socket_fd, (struct sockaddr *)&sockaddr, &sockaddr_len);
887 if (socket_fd == -1)
889 BX_PANIC(("Failed to accept on socket"));
891 close(listen_socket_fd);
893 protoent = getprotobyname ("tcp");
894 if (!protoent)
896 BX_INFO(("getprotobyname (\"tcp\") failed"));
897 return;
900 /* Disable Nagle - allow small packets to be sent without delay. */
901 opt = 1;
902 #ifdef __MINGW32__
903 r = setsockopt (socket_fd, protoent->p_proto, TCP_NODELAY, (const char *)&opt, sizeof(opt));
904 #else
905 r = setsockopt (socket_fd, protoent->p_proto, TCP_NODELAY, &opt, sizeof(opt));
906 #endif
907 if (r == -1)
909 BX_INFO(("setsockopt(TCP_NODELAY) failed"));
911 Bit32u ip = sockaddr.sin_addr.s_addr;
912 printf("Connected to %d.%d.%d.%d\n", ip & 0xff, (ip >> 8) & 0xff, (ip >> 16) & 0xff, (ip >> 24) & 0xff);
915 void bx_gdbstub_init(void)
917 gdbstublog = new logfunctions();
918 gdbstublog->put("GDBST");
919 gdbstublog->setonoff(LOGLEV_PANIC, ACT_FATAL);
921 gdbstub_list = (bx_list_c*) SIM->get_param(BXPN_GDBSTUB);
922 int portn = SIM->get_param_num("port", gdbstub_list)->get();
924 #ifdef __MINGW32__
925 WSADATA wsaData;
926 WSAStartup(2, &wsaData);
927 #endif
929 /* Wait for connect */
930 printf("Waiting for gdb connection on port %d\n", portn);
931 wait_for_connect(portn);
933 /* Do debugger command loop */
934 debug_loop();
936 /* CPU loop */
937 bx_cpu.cpu_loop(0);