def dump_vamos_error(self): e = self.vamos_error if e == None: return # memory error? if isinstance(e, InvalidMemoryAccessError): addr = e.addr if self.label_mgr != None: label, offset = self.label_mgr.get_label_offset(addr) else: label = None if label != None: log_main.error("%s -> +%06x %s", e, offset, label) else: log_main.error(e) else: log_main.error(e) # give CPU state dump pc = self.cpu_state.pc if self.label_mgr != None: label, offset = self.label_mgr.get_label_offset(pc) else: label = None if label != None: log_main.error("PC=%08x -> +%06x %s", pc, offset, label) for d in self.cpu_state.dump(): log_main.error(d)
def run(self, cycles_per_run=1000, max_cycles=0): """main run loop of vamos""" log_main.info("start cpu: %06x", self.ctx.process.prog_start) total_cycles = 0 start_time = time.clock() # main loop while self.stay: total_cycles += self.cpu.execute(cycles_per_run) # end after enough cycles if max_cycles > 0 and total_cycles >= max_cycles: break # some error fored a quit? if self.et.has_errors: break end_time = time.clock() # calc benchmark values if self.benchmark: self._calc_benchmark( total_cycles, end_time - start_time ) # if errors happened then report them now if self.et.has_errors: log_main.error("After %d cycles:", total_cycles) self.et.dump() exit_code = 1 else: # get exit code from CPU exit_code = int(self.cpu.r_reg(REG_D0)) log_main.info("exit code=%d", exit_code) return exit_code
def reset_func(self): """this callback is entered from CPU whenever a RESET opcode is encountered. dispatch to end vamos. """ pc = self.cpu.r_pc() - 2 # addr == 0 or an error occurred -> end reached if pc != 0 and not self.et.has_errors: log_main.error("RESET encountered - abort") # stop all self.cpu.end() self.stay = False
def log(self): """after logging is setup dump info and other remarks""" if len(self.found_files) == 0: log_main.info("no config file found: %s" % ",".join(self.files)) else: log_main.info("read config file: %s" % ",".join(self.found_files)) # dump config self._dump() # print recorded errors if len(self.errors) > 0: for e in self.errors: log_main.error("config error: " + e)
def reset_func(self): """this callback is entered from CPU whenever a RESET opcode is encountered. dispatch to end vamos. """ pc = self.cpu.r_pc() - 2 sp = self.cpu.r_reg(REG_A7) a6 = self.cpu.r_reg(REG_A6) # addr == 0 or an error occurred -> end reached if pc != 0 and not self.et.has_errors: log_main.error("RESET encountered at pc 0x%06x sp 0x%06x a6 0x%06x - abort",pc,sp,a6) for x in range(-32,32,2): w = self.mem.access.r32(sp+x) log_main.error("sp+%d : 0x%02x",x,w) # stop all self.cpu.end() self.stay = False
def reset_func(self): """this callback is entered from CPU whenever a RESET opcode is encountered. dispatch to end vamos. """ pc = self.cpu.r_pc() - 2 sp = self.cpu.r_reg(REG_A7) a6 = self.cpu.r_reg(REG_A6) # addr == 0 or an error occurred -> end reached if pc != self.reset_addr and not self.et.has_errors: log_main.error( "RESET encountered at pc 0x%06x sp 0x%06x a6 0x%06x - abort", pc, sp, a6) for x in range(-32, 32, 2): w = self.mem.r32(sp + x) log_main.error("sp+%d : 0x%02x", x, w) # stop all self.cpu.end() self.stay = False
def dump_vamos_error(self): e = self.vamos_error if e == None: return # memory error? if isinstance(e, InvalidMemoryAccessError): addr = e.addr label,offset = self.label_mgr.get_label_offset(addr) if label != None: log_main.error("%s -> +%06x %s",e,offset,label) else: log_main.error(e) else: log_main.error(e) # give CPU state dump pc = self.cpu_state['pc'] label,offset = self.label_mgr.get_label_offset(pc) if label != None: log_main.error("PC=%08x -> +%06x %s",pc,offset,label) for d in self.cpu.dump_state(self.cpu_state): log_main.error(d)
def run(self, cycles_per_run=1000, max_cycles=0): """main run loop of vamos""" log_main.info("start cpu: %06x", self.ctx.process.prog_start) total_cycles = 0 start_time = time.clock() # main loop while self.stay: total_cycles += self.cpu.execute(cycles_per_run) # end after enough cycles if max_cycles > 0 and total_cycles >= max_cycles: break # some error fored a quit? if self.et.has_errors: break end_time = time.clock() delta_time = end_time - start_time cpu_time = delta_time - self.trap_time mhz = total_cycles / (1000000.0 * delta_time) cpu_percent = cpu_time * 100.0 / delta_time trap_percent = 100.0 - cpu_percent log_main.info( "done %d cycles in host time %.4fs -> %5.2f MHz m68k CPU", total_cycles, cpu_time, mhz) log_main.info("code time %.4fs (%.2f %%), trap time %.4fs (%.2f %%) -> total time %.4fs", \ cpu_time, cpu_percent, self.trap_time, trap_percent, delta_time) # if errors happened then report them now if self.et.has_errors: log_main.error("After %d cycles:", total_cycles) self.et.dump() exit_code = 1 else: # get exit code from CPU exit_code = int(self.cpu.r_reg(REG_D0)) log_main.info("exit code=%d", exit_code) return exit_code
def run(self, cycles_per_run=1000, max_cycles=0): """main run loop of vamos""" log_main.info("start cpu: %06x", self.ctx.process.prog_start) total_cycles = 0 start_time = time.clock() # main loop while self.stay: total_cycles += self.cpu.execute(cycles_per_run) # end after enough cycles if max_cycles > 0 and total_cycles >= max_cycles: break # some error fored a quit? if self.et.has_errors: break end_time = time.clock() delta_time = end_time - start_time cpu_time = delta_time - self.trap_time mhz = total_cycles / (1000000.0 * delta_time) cpu_percent = cpu_time * 100.0 / delta_time trap_percent = 100.0 - cpu_percent log_main.info("done %d cycles in host time %.4fs -> %5.2f MHz m68k CPU", total_cycles, cpu_time, mhz) log_main.info("code time %.4fs (%.2f %%), trap time %.4fs (%.2f %%) -> total time %.4fs", \ cpu_time, cpu_percent, self.trap_time, trap_percent, delta_time) # if errors happened then report them now if self.et.has_errors: log_main.error("After %d cycles:", total_cycles) self.et.dump() exit_code = 1 else: # get exit code from CPU exit_code = int(self.cpu.r_reg(REG_D0)) log_main.info("exit code=%d", exit_code) return exit_code
def run(self, cycles_per_run=1000, max_cycles=0): """main run loop of vamos""" log_main.info("start cpu: %06x", self.ctx.process.prog_start) total_cycles = 0 start_time = time.clock() # main loop try: while self.stay: total_cycles += self.cpu.execute(cycles_per_run) # end after enough cycles if max_cycles > 0 and total_cycles >= max_cycles: break # some error fored a quit? if self.et.has_errors: break except Exception as e: self.et.report_error(e) end_time = time.clock() # calc benchmark values if self.benchmark: self._calc_benchmark( total_cycles, end_time - start_time ) # if errors happened then report them now if self.et.has_errors: log_main.error("After %d cycles:", total_cycles) self.et.dump() exit_code = 1 else: # get exit code from CPU exit_code = int(self.cpu.r_reg(REG_D0)) log_main.info("exit code=%d", exit_code) return exit_code
def dump_other_error(self): e = self.other_error if e == None: return if self.other_type == KeyboardInterrupt: log_main.error("Keyboard Abort") else: log_main.error("*** Python EXCEPTION: %s (%s) ***",self.other_value,self.other_type) for t in self.other_tb: log_main.error("%s:%d in %s: %s",*t)
def dump_other_error(self): e = self.other_error if e == None: return if self.other_type == KeyboardInterrupt: log_main.error("Keyboard Abort") else: log_main.error("*** Python EXCEPTION: %s (%s) ***", self.other_value, self.other_type) for t in self.other_tb: log_main.error("%s:%d in %s: %s", *t)