--- trunk/src/emul.c 2007/10/08 16:19:37 22 +++ trunk/src/emul.c 2007/10/08 16:20:10 26 @@ -25,7 +25,7 @@ * SUCH DAMAGE. * * - * $Id: emul.c,v 1.247 2006/02/04 12:27:12 debug Exp $ + * $Id: emul.c,v 1.255 2006/06/24 19:52:27 debug Exp $ * * Emulation startup and misc. routines. */ @@ -39,7 +39,6 @@ #include #include "arcbios.h" -#include "bintrans.h" #include "cpu.h" #include "emul.h" #include "console.h" @@ -56,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[]; @@ -105,12 +108,12 @@ uint64_t addr; int res = get_symbol_addr(&m->symbol_context, m->breakpoint_string[i], &addr); - if (!res) + if (!res) { fprintf(stderr, - "WARNING! Breakpoint '%s' could not be" + "ERROR! Breakpoint '%s' could not be" " parsed\n", m->breakpoint_string[i]); - else { + } else { dp = addr; string_flag = 1; } @@ -940,9 +943,6 @@ if (m->arch == ARCH_ALPHA) m->arch_pagesize = 8192; - if (m->arch != ARCH_MIPS) - m->bintrans_enable = 0; - machine_memsize_fix(m); /* @@ -990,18 +990,17 @@ } memset(m->cpus, 0, sizeof(struct cpu *) * m->ncpus); - /* Initialize dynamic binary translation, if available: */ - if (m->bintrans_enable) - bintrans_init(m, m->memory); - debug("cpu0"); if (m->ncpus > 1) debug(" .. cpu%i", m->ncpus - 1); debug(": "); for (i=0; incpus; i++) { m->cpus[i] = cpu_new(m->memory, m, i, m->cpu_name); - if (m->bintrans_enable) - bintrans_init_cpu(m->cpus[i]); + if (m->cpus[i] == NULL) { + fprintf(stderr, "Unable to create CPU object. " + "Aborting."); + exit(1); + } } debug("\n"); @@ -1012,8 +1011,6 @@ m->cpus[m->ncpus] = cpu_new(m->memory, m, 0 /* use 0 here to show info with debug() */, "Allegrex" /* TODO */); - if (m->bintrans_enable) - bintrans_init_cpu(m->cpus[m->ncpus]); debug("\n"); m->ncpus ++; } @@ -1355,10 +1352,6 @@ symbol_recalc_sizes(&m->symbol_context); - if (m->max_random_cycles_per_chunk > 0) - debug("using random cycle chunks (1 to %i cycles)\n", - m->max_random_cycles_per_chunk); - /* Special hack for ARC/SGI emulation: */ if ((m->machine_type == MACHINE_ARC || m->machine_type == MACHINE_SGI) && m->prom_emulation) @@ -1493,32 +1486,12 @@ { int iadd = DEBUG_INDENTATION; struct emul *e = emul_new(fname); - FILE *f; - char buf[128]; - size_t len; debug("Creating emulation from configfile \"%s\":\n", fname); debug_indentation(iadd); - f = fopen(fname, "r"); - if (f == NULL) { - perror(fname); - exit(1); - } - - /* Read header: (must be !!gxemul) */ - len = fread(buf, 1, 8, f); - if (len != 8 || strncmp(buf, "!!gxemul", 8) != 0) { - fprintf(stderr, "%s: must start with '!!gxemul'\n", fname); - exit(1); - } - - /* Restart from beginning: */ - rewind(f); - - emul_parse_config(e, f); + emul_parse_config(e, fname); - fclose(f); debug_indentation(-iadd); return e; } @@ -1608,20 +1581,50 @@ while (go) { go = 0; - x11_check_event(emuls, n_emuls); - - for (i=0; in_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]->ncycles > + emuls[0]->machines[0]->ncycles_flush + (1<<18)) { + x11_check_event(emuls, n_emuls); + console_flush(); + emuls[0]->machines[0]->ncycles_flush = + emuls[0]->machines[0]->ncycles; + } + + if (emuls[0]->machines[0]->ncycles > + emuls[0]->machines[0]->ncycles_show + (1<<25)) { + emuls[0]->machines[0]->ncycles_since_gettimeofday += + (emuls[0]->machines[0]->ncycles - + emuls[0]->machines[0]->ncycles_show); + cpu_show_cycles(emuls[0]->machines[0], 0); + emuls[0]->machines[0]->ncycles_show = + emuls[0]->machines[0]->ncycles; + } + + 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; } }