4 * Copyright (c) 2003-2008 Fabrice Bellard
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, see <http://www.gnu.org/licenses/>.
25 #include <machine/trap.h>
26 #include <sys/types.h>
30 #include "qemu-common.h"
34 #define DEBUG_LOGFILE "/tmp/qemu.log"
38 static const char *interp_prefix = CONFIG_QEMU_PREFIX;
39 const char *qemu_uname_release = CONFIG_UNAME_RELEASE;
40 extern char **environ;
42 /* XXX: on x86 MAP_GROWSDOWN only works if ESP <= address + 32, so
43 we allocate a bigger stack. Need a better solution, for example
44 by remapping the process stack directly at the right place */
45 unsigned long x86_stack_size = 512 * 1024;
47 void gemu_log(const char *fmt, ...)
52 vfprintf(stderr, fmt, ap);
56 #if defined(TARGET_I386)
57 int cpu_get_pic_interrupt(CPUState *env)
63 /* These are no-ops because we are not threadsafe. */
64 static inline void cpu_exec_start(CPUState *env)
68 static inline void cpu_exec_end(CPUState *env)
72 static inline void start_exclusive(void)
76 static inline void end_exclusive(void)
84 void fork_end(int child)
87 gdbserver_fork(thread_env);
91 void cpu_list_lock(void)
95 void cpu_list_unlock(void)
100 /***********************************************************/
101 /* CPUX86 core interface */
103 void cpu_smm_update(CPUState *env)
107 uint64_t cpu_get_tsc(CPUX86State *env)
109 return cpu_get_real_ticks();
112 static void write_dt(void *ptr, unsigned long addr, unsigned long limit,
117 e1 = (addr << 16) | (limit & 0xffff);
118 e2 = ((addr >> 16) & 0xff) | (addr & 0xff000000) | (limit & 0x000f0000);
125 static uint64_t *idt_table;
127 static void set_gate64(void *ptr, unsigned int type, unsigned int dpl,
128 uint64_t addr, unsigned int sel)
131 e1 = (addr & 0xffff) | (sel << 16);
132 e2 = (addr & 0xffff0000) | 0x8000 | (dpl << 13) | (type << 8);
136 p[2] = tswap32(addr >> 32);
139 /* only dpl matters as we do only user space emulation */
140 static void set_idt(int n, unsigned int dpl)
142 set_gate64(idt_table + n * 2, 0, dpl, 0, 0);
145 static void set_gate(void *ptr, unsigned int type, unsigned int dpl,
146 uint32_t addr, unsigned int sel)
149 e1 = (addr & 0xffff) | (sel << 16);
150 e2 = (addr & 0xffff0000) | 0x8000 | (dpl << 13) | (type << 8);
156 /* only dpl matters as we do only user space emulation */
157 static void set_idt(int n, unsigned int dpl)
159 set_gate(idt_table + n, 0, dpl, 0, 0);
163 void cpu_loop(CPUX86State *env, enum BSDType bsd_type)
167 //target_siginfo_t info;
170 trapnr = cpu_x86_exec(env);
173 /* syscall from int $0x80 */
174 env->regs[R_EAX] = do_openbsd_syscall(env,
185 /* linux syscall from syscall intruction */
186 env->regs[R_EAX] = do_openbsd_syscall(env,
194 env->eip = env->exception_next_eip;
200 info.si_signo = SIGBUS;
202 info.si_code = TARGET_SI_KERNEL;
203 info._sifields._sigfault._addr = 0;
204 queue_signal(env, info.si_signo, &info);
207 /* XXX: potential problem if ABI32 */
208 #ifndef TARGET_X86_64
209 if (env->eflags & VM_MASK) {
210 handle_vm86_fault(env);
214 info.si_signo = SIGSEGV;
216 info.si_code = TARGET_SI_KERNEL;
217 info._sifields._sigfault._addr = 0;
218 queue_signal(env, info.si_signo, &info);
222 info.si_signo = SIGSEGV;
224 if (!(env->error_code & 1))
225 info.si_code = TARGET_SEGV_MAPERR;
227 info.si_code = TARGET_SEGV_ACCERR;
228 info._sifields._sigfault._addr = env->cr[2];
229 queue_signal(env, info.si_signo, &info);
232 #ifndef TARGET_X86_64
233 if (env->eflags & VM_MASK) {
234 handle_vm86_trap(env, trapnr);
238 /* division by zero */
239 info.si_signo = SIGFPE;
241 info.si_code = TARGET_FPE_INTDIV;
242 info._sifields._sigfault._addr = env->eip;
243 queue_signal(env, info.si_signo, &info);
248 #ifndef TARGET_X86_64
249 if (env->eflags & VM_MASK) {
250 handle_vm86_trap(env, trapnr);
254 info.si_signo = SIGTRAP;
256 if (trapnr == EXCP01_DB) {
257 info.si_code = TARGET_TRAP_BRKPT;
258 info._sifields._sigfault._addr = env->eip;
260 info.si_code = TARGET_SI_KERNEL;
261 info._sifields._sigfault._addr = 0;
263 queue_signal(env, info.si_signo, &info);
268 #ifndef TARGET_X86_64
269 if (env->eflags & VM_MASK) {
270 handle_vm86_trap(env, trapnr);
274 info.si_signo = SIGSEGV;
276 info.si_code = TARGET_SI_KERNEL;
277 info._sifields._sigfault._addr = 0;
278 queue_signal(env, info.si_signo, &info);
282 info.si_signo = SIGILL;
284 info.si_code = TARGET_ILL_ILLOPN;
285 info._sifields._sigfault._addr = env->eip;
286 queue_signal(env, info.si_signo, &info);
290 /* just indicate that signals should be handled asap */
297 sig = gdb_handlesig (env, TARGET_SIGTRAP);
302 info.si_code = TARGET_TRAP_BRKPT;
303 queue_signal(env, info.si_signo, &info);
309 pc = env->segs[R_CS].base + env->eip;
310 fprintf(stderr, "qemu: 0x%08lx: unhandled CPU exception 0x%x - aborting\n",
314 process_pending_signals(env);
320 #define SPARC64_STACK_BIAS 2047
323 /* WARNING: dealing with register windows _is_ complicated. More info
324 can be found at http://www.sics.se/~psm/sparcstack.html */
325 static inline int get_reg_index(CPUSPARCState *env, int cwp, int index)
327 index = (index + cwp * 16) % (16 * env->nwindows);
328 /* wrap handling : if cwp is on the last window, then we use the
329 registers 'after' the end */
330 if (index < 8 && env->cwp == env->nwindows - 1)
331 index += 16 * env->nwindows;
335 /* save the register window 'cwp1' */
336 static inline void save_window_offset(CPUSPARCState *env, int cwp1)
341 sp_ptr = env->regbase[get_reg_index(env, cwp1, 6)];
342 #ifdef TARGET_SPARC64
344 sp_ptr += SPARC64_STACK_BIAS;
346 #if defined(DEBUG_WIN)
347 printf("win_overflow: sp_ptr=0x" TARGET_ABI_FMT_lx " save_cwp=%d\n",
350 for(i = 0; i < 16; i++) {
351 /* FIXME - what to do if put_user() fails? */
352 put_user_ual(env->regbase[get_reg_index(env, cwp1, 8 + i)], sp_ptr);
353 sp_ptr += sizeof(abi_ulong);
357 static void save_window(CPUSPARCState *env)
359 #ifndef TARGET_SPARC64
360 unsigned int new_wim;
361 new_wim = ((env->wim >> 1) | (env->wim << (env->nwindows - 1))) &
362 ((1LL << env->nwindows) - 1);
363 save_window_offset(env, cpu_cwp_dec(env, env->cwp - 2));
366 save_window_offset(env, cpu_cwp_dec(env, env->cwp - 2));
372 static void restore_window(CPUSPARCState *env)
374 #ifndef TARGET_SPARC64
375 unsigned int new_wim;
377 unsigned int i, cwp1;
380 #ifndef TARGET_SPARC64
381 new_wim = ((env->wim << 1) | (env->wim >> (env->nwindows - 1))) &
382 ((1LL << env->nwindows) - 1);
385 /* restore the invalid window */
386 cwp1 = cpu_cwp_inc(env, env->cwp + 1);
387 sp_ptr = env->regbase[get_reg_index(env, cwp1, 6)];
388 #ifdef TARGET_SPARC64
390 sp_ptr += SPARC64_STACK_BIAS;
392 #if defined(DEBUG_WIN)
393 printf("win_underflow: sp_ptr=0x" TARGET_ABI_FMT_lx " load_cwp=%d\n",
396 for(i = 0; i < 16; i++) {
397 /* FIXME - what to do if get_user() fails? */
398 get_user_ual(env->regbase[get_reg_index(env, cwp1, 8 + i)], sp_ptr);
399 sp_ptr += sizeof(abi_ulong);
401 #ifdef TARGET_SPARC64
403 if (env->cleanwin < env->nwindows - 1)
411 static void flush_windows(CPUSPARCState *env)
417 /* if restore would invoke restore_window(), then we can stop */
418 cwp1 = cpu_cwp_inc(env, env->cwp + offset);
419 #ifndef TARGET_SPARC64
420 if (env->wim & (1 << cwp1))
423 if (env->canrestore == 0)
428 save_window_offset(env, cwp1);
431 cwp1 = cpu_cwp_inc(env, env->cwp + 1);
432 #ifndef TARGET_SPARC64
433 /* set wim so that restore will reload the registers */
434 env->wim = 1 << cwp1;
436 #if defined(DEBUG_WIN)
437 printf("flush_windows: nb=%d\n", offset - 1);
441 void cpu_loop(CPUSPARCState *env, enum BSDType bsd_type)
443 int trapnr, ret, syscall_nr;
444 //target_siginfo_t info;
447 trapnr = cpu_sparc_exec (env);
450 #ifndef TARGET_SPARC64
455 syscall_nr = env->gregs[1];
456 if (bsd_type == target_freebsd)
457 ret = do_freebsd_syscall(env, syscall_nr,
458 env->regwptr[0], env->regwptr[1],
459 env->regwptr[2], env->regwptr[3],
460 env->regwptr[4], env->regwptr[5]);
461 else if (bsd_type == target_netbsd)
462 ret = do_netbsd_syscall(env, syscall_nr,
463 env->regwptr[0], env->regwptr[1],
464 env->regwptr[2], env->regwptr[3],
465 env->regwptr[4], env->regwptr[5]);
466 else { //if (bsd_type == target_openbsd)
467 #if defined(TARGET_SPARC64)
468 syscall_nr &= ~(TARGET_OPENBSD_SYSCALL_G7RFLAG |
469 TARGET_OPENBSD_SYSCALL_G2RFLAG);
471 ret = do_openbsd_syscall(env, syscall_nr,
472 env->regwptr[0], env->regwptr[1],
473 env->regwptr[2], env->regwptr[3],
474 env->regwptr[4], env->regwptr[5]);
476 if ((unsigned int)ret >= (unsigned int)(-515)) {
477 #if defined(TARGET_SPARC64) && !defined(TARGET_ABI32)
478 env->xcc |= PSR_CARRY;
480 env->psr |= PSR_CARRY;
483 #if defined(TARGET_SPARC64) && !defined(TARGET_ABI32)
484 env->xcc &= ~PSR_CARRY;
486 env->psr &= ~PSR_CARRY;
489 env->regwptr[0] = ret;
490 /* next instruction */
491 #if defined(TARGET_SPARC64)
492 if (bsd_type == target_openbsd &&
493 env->gregs[1] & TARGET_OPENBSD_SYSCALL_G2RFLAG) {
494 env->pc = env->gregs[2];
495 env->npc = env->pc + 4;
496 } else if (bsd_type == target_openbsd &&
497 env->gregs[1] & TARGET_OPENBSD_SYSCALL_G7RFLAG) {
498 env->pc = env->gregs[7];
499 env->npc = env->pc + 4;
502 env->npc = env->npc + 4;
506 env->npc = env->npc + 4;
509 case 0x83: /* flush windows */
514 /* next instruction */
516 env->npc = env->npc + 4;
518 #ifndef TARGET_SPARC64
519 case TT_WIN_OVF: /* window overflow */
522 case TT_WIN_UNF: /* window underflow */
529 info.si_signo = SIGSEGV;
531 /* XXX: check env->error_code */
532 info.si_code = TARGET_SEGV_MAPERR;
533 info._sifields._sigfault._addr = env->mmuregs[4];
534 queue_signal(env, info.si_signo, &info);
539 case TT_SPILL: /* window overflow */
542 case TT_FILL: /* window underflow */
549 info.si_signo = SIGSEGV;
551 /* XXX: check env->error_code */
552 info.si_code = TARGET_SEGV_MAPERR;
553 if (trapnr == TT_DFAULT)
554 info._sifields._sigfault._addr = env->dmmuregs[4];
556 info._sifields._sigfault._addr = env->tsptr->tpc;
557 //queue_signal(env, info.si_signo, &info);
563 /* just indicate that signals should be handled asap */
569 sig = gdb_handlesig (env, TARGET_SIGTRAP);
575 info.si_code = TARGET_TRAP_BRKPT;
576 //queue_signal(env, info.si_signo, &info);
582 printf ("Unhandled trap: 0x%x\n", trapnr);
583 cpu_dump_state(env, stderr, fprintf, 0);
586 process_pending_signals (env);
592 static void usage(void)
594 printf("qemu-" TARGET_ARCH " version " QEMU_VERSION ", Copyright (c) 2003-2008 Fabrice Bellard\n"
595 "usage: qemu-" TARGET_ARCH " [options] program [arguments...]\n"
596 "BSD CPU emulator (compiled for %s emulation)\n"
598 "Standard options:\n"
599 "-h print this help\n"
600 "-g port wait gdb connection to port\n"
601 "-L path set the elf interpreter prefix (default=%s)\n"
602 "-s size set the stack size in bytes (default=%ld)\n"
603 "-cpu model select CPU (-cpu ? for list)\n"
604 "-drop-ld-preload drop LD_PRELOAD for target process\n"
605 "-bsd type select emulated BSD type FreeBSD/NetBSD/OpenBSD (default)\n"
608 "-d options activate log (logfile=%s)\n"
609 "-p pagesize set the host page size to 'pagesize'\n"
610 "-singlestep always run in singlestep mode\n"
611 "-strace log system calls\n"
613 "Environment variables:\n"
614 "QEMU_STRACE Print system calls and arguments similar to the\n"
615 " 'strace' program. Enable by setting to any value.\n"
624 THREAD CPUState *thread_env;
626 /* Assumes contents are already zeroed. */
627 void init_task_state(TaskState *ts)
632 ts->first_free = ts->sigqueue_table;
633 for (i = 0; i < MAX_SIGQUEUE_SIZE - 1; i++) {
634 ts->sigqueue_table[i].next = &ts->sigqueue_table[i + 1];
636 ts->sigqueue_table[i].next = NULL;
639 int main(int argc, char **argv)
641 const char *filename;
642 const char *cpu_model;
643 struct target_pt_regs regs1, *regs = ®s1;
644 struct image_info info1, *info = &info1;
645 TaskState ts1, *ts = &ts1;
649 int gdbstub_port = 0;
650 int drop_ld_preload = 0, environ_count = 0;
651 char **target_environ, **wrk, **dst;
652 enum BSDType bsd_type = target_openbsd;
658 cpu_set_log_filename(DEBUG_LOGFILE);
670 if (!strcmp(r, "-")) {
672 } else if (!strcmp(r, "d")) {
674 const CPULogItem *item;
680 mask = cpu_str_to_log_mask(r);
682 printf("Log items (comma separated):\n");
683 for(item = cpu_log_items; item->mask != 0; item++) {
684 printf("%-10s %s\n", item->name, item->help);
689 } else if (!strcmp(r, "s")) {
691 x86_stack_size = strtol(r, (char **)&r, 0);
692 if (x86_stack_size <= 0)
695 x86_stack_size *= 1024 * 1024;
696 else if (*r == 'k' || *r == 'K')
697 x86_stack_size *= 1024;
698 } else if (!strcmp(r, "L")) {
699 interp_prefix = argv[optind++];
700 } else if (!strcmp(r, "p")) {
701 qemu_host_page_size = atoi(argv[optind++]);
702 if (qemu_host_page_size == 0 ||
703 (qemu_host_page_size & (qemu_host_page_size - 1)) != 0) {
704 fprintf(stderr, "page size must be a power of two\n");
707 } else if (!strcmp(r, "g")) {
708 gdbstub_port = atoi(argv[optind++]);
709 } else if (!strcmp(r, "r")) {
710 qemu_uname_release = argv[optind++];
711 } else if (!strcmp(r, "cpu")) {
712 cpu_model = argv[optind++];
713 if (strcmp(cpu_model, "?") == 0) {
714 /* XXX: implement xxx_cpu_list for targets that still miss it */
715 #if defined(cpu_list)
716 cpu_list(stdout, &fprintf);
720 } else if (!strcmp(r, "drop-ld-preload")) {
722 } else if (!strcmp(r, "bsd")) {
723 if (!strcasecmp(argv[optind], "freebsd")) {
724 bsd_type = target_freebsd;
725 } else if (!strcasecmp(argv[optind], "netbsd")) {
726 bsd_type = target_netbsd;
727 } else if (!strcasecmp(argv[optind], "openbsd")) {
728 bsd_type = target_openbsd;
733 } else if (!strcmp(r, "singlestep")) {
735 } else if (!strcmp(r, "strace")) {
744 filename = argv[optind];
747 memset(regs, 0, sizeof(struct target_pt_regs));
749 /* Zero out image_info */
750 memset(info, 0, sizeof(struct image_info));
752 /* Scan interp_prefix dir for replacement files. */
753 init_paths(interp_prefix);
755 if (cpu_model == NULL) {
756 #if defined(TARGET_I386)
758 cpu_model = "qemu64";
760 cpu_model = "qemu32";
762 #elif defined(TARGET_SPARC)
763 #ifdef TARGET_SPARC64
764 cpu_model = "TI UltraSparc II";
766 cpu_model = "Fujitsu MB86904";
772 cpu_exec_init_all(0);
773 /* NOTE: we need to init the CPU at this stage to get
774 qemu_host_page_size */
775 env = cpu_init(cpu_model);
777 fprintf(stderr, "Unable to find CPU definition\n");
782 if (getenv("QEMU_STRACE")) {
790 target_environ = malloc((environ_count + 1) * sizeof(char *));
793 for (wrk = environ, dst = target_environ; *wrk; wrk++) {
794 if (drop_ld_preload && !strncmp(*wrk, "LD_PRELOAD=", 11))
796 *(dst++) = strdup(*wrk);
798 *dst = NULL; /* NULL terminate target_environ */
800 if (loader_exec(filename, argv+optind, target_environ, regs, info) != 0) {
801 printf("Error loading %s\n", filename);
805 for (wrk = target_environ; *wrk; wrk++) {
809 free(target_environ);
811 if (qemu_log_enabled()) {
814 qemu_log("start_brk 0x" TARGET_ABI_FMT_lx "\n", info->start_brk);
815 qemu_log("end_code 0x" TARGET_ABI_FMT_lx "\n", info->end_code);
816 qemu_log("start_code 0x" TARGET_ABI_FMT_lx "\n",
818 qemu_log("start_data 0x" TARGET_ABI_FMT_lx "\n",
820 qemu_log("end_data 0x" TARGET_ABI_FMT_lx "\n", info->end_data);
821 qemu_log("start_stack 0x" TARGET_ABI_FMT_lx "\n",
823 qemu_log("brk 0x" TARGET_ABI_FMT_lx "\n", info->brk);
824 qemu_log("entry 0x" TARGET_ABI_FMT_lx "\n", info->entry);
827 target_set_brk(info->brk);
831 /* build Task State */
832 memset(ts, 0, sizeof(TaskState));
837 #if defined(TARGET_I386)
838 cpu_x86_set_cpl(env, 3);
840 env->cr[0] = CR0_PG_MASK | CR0_WP_MASK | CR0_PE_MASK;
841 env->hflags |= HF_PE_MASK;
842 if (env->cpuid_features & CPUID_SSE) {
843 env->cr[4] |= CR4_OSFXSR_MASK;
844 env->hflags |= HF_OSFXSR_MASK;
847 /* enable 64 bit mode if possible */
848 if (!(env->cpuid_ext2_features & CPUID_EXT2_LM)) {
849 fprintf(stderr, "The selected x86 CPU does not support 64 bit mode\n");
852 env->cr[4] |= CR4_PAE_MASK;
853 env->efer |= MSR_EFER_LMA | MSR_EFER_LME;
854 env->hflags |= HF_LMA_MASK;
857 /* flags setup : we activate the IRQs by default as in user mode */
858 env->eflags |= IF_MASK;
860 /* linux register setup */
862 env->regs[R_EAX] = regs->rax;
863 env->regs[R_EBX] = regs->rbx;
864 env->regs[R_ECX] = regs->rcx;
865 env->regs[R_EDX] = regs->rdx;
866 env->regs[R_ESI] = regs->rsi;
867 env->regs[R_EDI] = regs->rdi;
868 env->regs[R_EBP] = regs->rbp;
869 env->regs[R_ESP] = regs->rsp;
870 env->eip = regs->rip;
872 env->regs[R_EAX] = regs->eax;
873 env->regs[R_EBX] = regs->ebx;
874 env->regs[R_ECX] = regs->ecx;
875 env->regs[R_EDX] = regs->edx;
876 env->regs[R_ESI] = regs->esi;
877 env->regs[R_EDI] = regs->edi;
878 env->regs[R_EBP] = regs->ebp;
879 env->regs[R_ESP] = regs->esp;
880 env->eip = regs->eip;
883 /* linux interrupt setup */
885 env->idt.limit = 511;
887 env->idt.limit = 255;
889 env->idt.base = target_mmap(0, sizeof(uint64_t) * (env->idt.limit + 1),
890 PROT_READ|PROT_WRITE,
891 MAP_ANONYMOUS|MAP_PRIVATE, -1, 0);
892 idt_table = g2h(env->idt.base);
915 /* linux segment setup */
918 env->gdt.base = target_mmap(0, sizeof(uint64_t) * TARGET_GDT_ENTRIES,
919 PROT_READ|PROT_WRITE,
920 MAP_ANONYMOUS|MAP_PRIVATE, -1, 0);
921 env->gdt.limit = sizeof(uint64_t) * TARGET_GDT_ENTRIES - 1;
922 gdt_table = g2h(env->gdt.base);
924 write_dt(&gdt_table[__USER_CS >> 3], 0, 0xfffff,
925 DESC_G_MASK | DESC_B_MASK | DESC_P_MASK | DESC_S_MASK |
926 (3 << DESC_DPL_SHIFT) | (0xa << DESC_TYPE_SHIFT));
928 /* 64 bit code segment */
929 write_dt(&gdt_table[__USER_CS >> 3], 0, 0xfffff,
930 DESC_G_MASK | DESC_B_MASK | DESC_P_MASK | DESC_S_MASK |
932 (3 << DESC_DPL_SHIFT) | (0xa << DESC_TYPE_SHIFT));
934 write_dt(&gdt_table[__USER_DS >> 3], 0, 0xfffff,
935 DESC_G_MASK | DESC_B_MASK | DESC_P_MASK | DESC_S_MASK |
936 (3 << DESC_DPL_SHIFT) | (0x2 << DESC_TYPE_SHIFT));
939 cpu_x86_load_seg(env, R_CS, __USER_CS);
940 cpu_x86_load_seg(env, R_SS, __USER_DS);
942 cpu_x86_load_seg(env, R_DS, __USER_DS);
943 cpu_x86_load_seg(env, R_ES, __USER_DS);
944 cpu_x86_load_seg(env, R_FS, __USER_DS);
945 cpu_x86_load_seg(env, R_GS, __USER_DS);
946 /* This hack makes Wine work... */
947 env->segs[R_FS].selector = 0;
949 cpu_x86_load_seg(env, R_DS, 0);
950 cpu_x86_load_seg(env, R_ES, 0);
951 cpu_x86_load_seg(env, R_FS, 0);
952 cpu_x86_load_seg(env, R_GS, 0);
954 #elif defined(TARGET_SPARC)
958 env->npc = regs->npc;
960 for(i = 0; i < 8; i++)
961 env->gregs[i] = regs->u_regs[i];
962 for(i = 0; i < 8; i++)
963 env->regwptr[i] = regs->u_regs[i + 8];
966 #error unsupported target CPU
970 gdbserver_start (gdbstub_port);
971 gdb_handlesig(env, 0);
973 cpu_loop(env, bsd_type);