--- trunk/src/emul.c 2007/10/08 16:19:56 24 +++ trunk/src/emul.c 2007/10/08 16:20:40 30 @@ -25,7 +25,7 @@ * SUCH DAMAGE. * * - * $Id: emul.c,v 1.254 2006/06/22 13:22:40 debug Exp $ + * $Id: emul.c,v 1.260 2006/07/26 23:21:47 debug Exp $ * * Emulation startup and misc. routines. */ @@ -55,13 +55,17 @@ #include "x11.h" -extern int force_debugger_at_exit; - extern int extra_argc; extern char **extra_argv; extern int verbose; extern int quiet_mode; +extern int force_debugger_at_exit; +extern int single_step; +extern int old_show_trace_tree; +extern int old_instruction_trace; +extern int old_quiet_mode; +extern int quiet_mode; extern struct emul *debugger_emul; extern struct diskimage *diskimages[]; @@ -1267,7 +1271,7 @@ break; case ARCH_SH: - if (cpu->cd.sh.bits == 32) + if (cpu->cd.sh.cpu_type.bits == 32) cpu->pc &= 0xffffffffULL; cpu->pc &= ~1; break; @@ -1275,6 +1279,10 @@ case ARCH_SPARC: break; + case ARCH_TRANSPUTER: + cpu->pc &= 0xffffffffULL; + break; + case ARCH_X86: /* * NOTE: The toc field is used to indicate an ELF32 @@ -1328,8 +1336,7 @@ useremul_setup(cpu, n_load, load_names); /* Startup the bootstrap CPU: */ - cpu->bootstrap_cpu_flag = 1; - cpu->running = 1; + cpu->running = 1; /* ... or pause all CPUs, if start_paused is set: */ if (m->start_paused) { @@ -1577,24 +1584,50 @@ while (go) { go = 0; - x11_check_event(emuls, n_emuls); - - for (i=0; in_machines; j++) { - if (e->machines[j]->gdb.port > 0) - debugger_gdb_check_incoming( - e->machines[j]); - - /* TODO: cpu_run() is a strange name, since - there can be multiple cpus in a machine */ - anything = cpu_run(e, e->machines[j]); - if (anything) - go = 1; - } + /* Flush X11 and serial console output every now and then: */ + if (emuls[0]->machines[0]->ninstrs > + emuls[0]->machines[0]->ninstrs_flush + (1<<19)) { + x11_check_event(emuls, n_emuls); + console_flush(); + emuls[0]->machines[0]->ninstrs_flush = + emuls[0]->machines[0]->ninstrs; + } + + if (emuls[0]->machines[0]->ninstrs > + emuls[0]->machines[0]->ninstrs_show + (1<<25)) { + emuls[0]->machines[0]->ninstrs_since_gettimeofday += + (emuls[0]->machines[0]->ninstrs - + emuls[0]->machines[0]->ninstrs_show); + cpu_show_cycles(emuls[0]->machines[0], 0); + emuls[0]->machines[0]->ninstrs_show = + emuls[0]->machines[0]->ninstrs; + } + + if (single_step == ENTER_SINGLE_STEPPING) { + /* TODO: Cleanup! */ + old_instruction_trace = + emuls[0]->machines[0]->instruction_trace; + old_quiet_mode = quiet_mode; + old_show_trace_tree = + emuls[0]->machines[0]->show_trace_tree; + emuls[0]->machines[0]->instruction_trace = 1; + emuls[0]->machines[0]->show_trace_tree = 1; + quiet_mode = 0; + single_step = SINGLE_STEPPING; + } + + if (single_step == SINGLE_STEPPING) + debugger(); + + e = emuls[0]; /* Note: Only 1 emul supported now. */ + + for (j=0; jn_machines; j++) { + if (e->machines[j]->gdb.port > 0) + debugger_gdb_check_incoming(e->machines[j]); + + anything = machine_run(e->machines[j]); + if (anything) + go = 1; } }