[pypy-svn] r60002 - pypy/trunk/pypy/lang/gameboy/debug

cami at codespeak.net cami at codespeak.net
Thu Nov 20 00:22:29 CET 2008


Author: cami
Date: Thu Nov 20 00:22:29 2008
New Revision: 60002

Added:
   pypy/trunk/pypy/lang/gameboy/debug/debug_comparator.py
   pypy/trunk/pypy/lang/gameboy/debug/debug_rpc_xml_connection.py
   pypy/trunk/pypy/lang/gameboy/debug/debug_util.py
Removed:
   pypy/trunk/pypy/lang/gameboy/debug/debug.py
   pypy/trunk/pypy/lang/gameboy/debug/debug_rpc_xml_memory.py
Modified:
   pypy/trunk/pypy/lang/gameboy/debug/gameboy_debug_entry_point.py
   pypy/trunk/pypy/lang/gameboy/debug/gameboy_debug_implementation.py
Log:
resfactored remote debugger
added separated comparator classes for checking each part on its own
renamed xml memory to xml connection



Added: pypy/trunk/pypy/lang/gameboy/debug/debug_comparator.py
==============================================================================
--- (empty file)
+++ pypy/trunk/pypy/lang/gameboy/debug/debug_comparator.py	Thu Nov 20 00:22:29 2008
@@ -0,0 +1,320 @@
+
+class printframe(object):
+    open = 0
+    def __init__(self, text):
+        global DEBUG, open
+        printframe.open = 0
+        self.text = text
+        
+    def __call__(self, f):
+        def wrapper(*args, **kwargs):
+            global DEBUG
+            shift =  "    "*printframe.open
+            if DEBUG:
+                print "python:", shift, self.text, "..."
+            printframe.open += 1
+            val = f(*args, **kwargs)
+            if DEBUG:
+                print "python:", shift, self.text, "DONE"
+            printframe.open -= 1
+            return val
+        
+        return wrapper
+    
+    
+# -----------------------------------------------------------------------------
+
+class Comparator():
+
+    def __init__(self, debug_connection):
+        self.debug_connection = debug_connection
+        
+    
+    def compare(self, data):
+        pass
+    
+    def compare_memory(self, name, expected, new):
+        self.print_compare(name+" length", len(expected), len(new))
+        if len(expected) != len(new): return
+        for address in range(0, len(expected), 1):
+            self.print_compare(name+" value at "+hex(address), \
+                    expected[address], new[address])
+    
+    def print_compare(self, msg, expected, got, output=False):
+        if expected != got:
+            self.compare_failed = True
+            print "python: !!", msg, "expected:", expected, "got:", got, "!!"
+            
+    
+    def print_mismatch(self, part, expected, got):
+        print "python:", str(part), "expected:", str(expected), "got:", str(got)
+        
+        
+          
+# -----------------------------------------------------------------------------
+
+class GameboyComparator(Comparator):
+    
+    def __init__(self, debug_connection, gameboy):
+        Comparator.__init__(self, debug_connection)
+        self.gameboy = gameboy
+        self.create_part_comparators()
+        
+    def create_part_comparators(debug_connection):
+        self.cpu_comparator = CPUComparator(debug_connection, self.gameboy.cpu)
+        self.timer_comparator = TimerComparator(debug_connection, self.gameboy.timer)
+        self.interrupt_comparator = InterruptComparator(debug_connection, self.gameboy)
+        self.video_comparator = VideoComparator(debug_connection, self.gameboy.video)
+        self.ram_comparator = RAMComparator(debug_connection, self.gameboy)
+    
+    def compare(self, data):
+        self.compare_cycles(data["cycles"])
+        self.cpu_comparator.compare(data["cpu"])
+        self.timer_comparator.compare(data["timer"])
+        self.interrupt_comparator.compare(data["interrupt"])
+        self.video_comparator.compare(data["video"])
+        self.ram_comparator.compare(data["ram"])
+    
+    @printframe("comparing cycles")        
+    def compare_cycles(data):
+        self.print_check("cycles video", self.video.cycles, data["video"])
+        self.print_check("cycles cpu", 
+                self.gameboy_debug.cpu.cycles, data["cpu"])
+        self.print_check("cycles serial",
+                self.gameboy_debug.serial.cycles, data["serial"])
+        self.print_check("cycles joypad",
+                self.gameboy_debug.joypad.cycles, data["joypad"])   
+        #sound not yet implemented so no  use for checking cycles here
+        #self.print_check("cycles sound", #self.gameboy_debug.sound.cycles, 
+        #                    0, data["sound"])   
+
+class ROMComparator():
+    
+    def __init__(self, debug_connection, gameboy):
+        Comparator.__init__(self, debug_connection)
+        self.gameboy = gameboy
+        self.cartridgeComparator = CartridgeComparator(debug_connection, 
+                                        self.gameboy_debug.cartridge_manager)
+   
+    @printframe("checking ROM")     
+    def compare(self, data):
+        self.compare_memory("ROM", self.rom, data["rom"])
+        self.compare_memory("registeredBitmap", constants.REGISTERED_BITMAP, \
+                            data["registeredBitmap"])
+        self.compare_cartridge(data)
+        
+
+class CartridgeComparator(Comparator):
+    
+    def __init__(self, debug_connection, catridge_manager):
+        Comparator.__init__(self, debug_connection)
+        self.cartridge_manager = cartridge_manager
+        
+    @printframe("checking cartridge data")           
+    def compare(self, data):
+        self.print_compare("cartridge ROM size",
+                self.cartridge_manager.get_rom_size(),
+                data["ramSize"])
+        self.print_compare("cartridge RAM size", 
+                self.cartridge_manager.get_ram_size(),
+                data["romSize"])
+        self.print_compare("cartridge Memory Bank Type",
+                self.cartridge_manager.get_memory_bank_type(),
+                data["type"])
+        self.print_compare("cartridge checksum",
+                self.cartridge_manager.get_checksum(),
+                data["checksum"])
+        self.print_compare("cartridge has battery",
+                self.cartridge_manager.has_battery(),
+                data["hasBattery"])
+        
+
+class InterruptComparator(Comparator):
+    
+    def __init__(self, debug_connection, gameboy):
+        Comparator.__init__(self, debug_connection)
+        self.cpu = gameboy.cpu
+        self.interrupt = gameboy.interrupt
+        
+    @printframe("comparing interrupts")
+    def compare(self, data):
+        self.print_check("interrupt ime", self.cpu.ime,  data["ime"])
+        self.print_check("interrupt halted" , self.cpu.halted, data["halted"])
+        self.print_check("interrupt enable" ,
+                self.interrupt.get_enable_mask(), data["enabled"])
+        self.print_check("interrupt flag" ,
+                self.interrupt.get_interrupt_flag(), data["flag"])
+                       
+        
+class CPUComparator(Comparator):
+
+    def __init__(self, debug_connection, cpu):
+        Comparator.__init__(self, debug_connection);
+        self.cpu = cpu
+        
+    @printframe("comparing CPU")    
+    def compare(self, data):
+        self.print_check("instruction count",
+                         self.cpu.instruction_counter, 
+                         data["instruction_count"])
+        self.compare_opcodes(data)
+        self.compare_registers(data)
+   
+    @printframe("comparing op codes")     
+    def compare_opcodes(data):
+        self.print_check("last opCode" , self.cpu.last_op_code, 
+                         data["last_op_code"])
+        self.print_check("last opCode" , self.cpu.last_fetch_execute_op_code,
+                         data["last_fetch_exec_op_code"])
+        
+    @printframe("comparing registers")
+    def compare_registers(data):
+        registers = data["registers"]
+        display_results = []
+        mapping =  [("a",  self.cpu.a.get()),  ("f",  self.cpu.flag.get()),
+        ("b",  self.cpu.b.get()),  ("c",  self.cpu.c.get()),
+        ("d",  self.cpu.d.get()),  ("e",  self.cpu.e.get()),
+        ("h",  self.cpu.h.get()),  ("l",  self.cpu.l.get()),
+        ("sp", self.cpu.sp.get()), ("pc", self.cpu.pc.get())];
+        
+        for reg in mapping:
+            display_results.append(( reg[1], registers[reg[0]]))
+            self.print_check("register %s" % reg[0], reg[1], registers[reg[0]], output=True)
+            
+            line = ""
+            for i in range(len(display_results)):
+                line += mapping[i][0].rjust(2) + ": "
+                line += str(display_results[i][0]).rjust(3) + " | "
+                print line
+               
+                line =""
+                for i in range(len(display_results)):
+                    line += "    " + str(display_results[i][0]).rjust(3) + " | "
+                print line
+                
+                pc = self.cpu.pc.get(use_cycles=False)
+                print "fetch:", self.cpu.fetch(use_cycles=False)
+                self.cpu.pc.set(pc, use_cycles=False)
+                
+      
+class TimerComparator(Comparator):
+    
+    def __init__(self, debug_connection, timer):
+        Comparator.__init__(self, debug_connection)
+        self.timer = timer
+    
+    @printframe("comparing timer")      
+    def compare(self, data):
+        self.print_check("timer div", \
+                self.timer.divider, \
+                data["div"])
+        self.print_check("timer dividerCycles", \
+                self.timer.divider_cycles, \
+                data["dividerCycles"])
+        self.print_check("timer tac", \
+                self.timer.timer_control, \
+                data["tac"])
+        self.print_check("timer tima", \
+                self.timer.timer_counter, \
+                data["tima"])
+        self.print_check("timer timerClock", \
+                self.timer.timer_clock, \
+                data["timerClock"])
+        self.print_check("timer timerCycles", \
+                self.timer.timer_cycles, \
+                data["timerCycles"])
+        self.print_check("timer tma", \
+                self.timer.timer_modulo, \
+                data["tma"])             
+           
+        
+class RAMComparator(Comparator):
+    
+    def __init__(self, debug_connection, gameboy_debug):
+        Comparator.__init__(self, debug_connection)
+        self.gameboy_debug = gameboy_debug
+    
+    @printframe("comparing RAM")   
+    def compare(self, data):
+       self.compare_memory("wram", \
+               self.gameboy_debug.ram.work_ram, ram["wram"])
+       self.compare_memory("hram", \
+                self.gameboy_debug.ram.hi_ram, ram["hram"])
+       self.compare_memory("catridge external", \
+                self.get_external_cartridge_ram(), ram["ext"])
+    
+    def get_external_cartridge_ram(self):
+        ram = [0xFF] * (0xBFFF-0xA000+1)
+        if self.gameboy_debug.cartridge_manager.mbc.ram_enable:
+            for i in range(len(ram)):
+                ram[i] = self.gameboy_debug.read(0xA000+i)
+        return ram
+            
+        
+
+class VideoComparator(Comparator):
+    
+    def __init__(self, debug_connection, video):
+        Comparator.__init__(self, debug_connection)
+        self.video = video
+     
+    @printframe("comparing video")   
+    def compare(self, data):
+        self.compare_memory(video)
+        self.compare_registers(video)
+       
+    @printframe("comparing memory")  
+    def compare_memory(data):
+        self.compare_memory("video vram", self.video.vram,
+                            data["vram"])
+        self.compare_memory("video object attribute memory oam",
+                            self.video.oam, data["oam"])
+        self.compare_memory("video line", self.video.line,
+                            data["line"])
+        self.compare_memory("video objects", self.video.objects,
+                            data["objects"])
+        self.compare_memory("video palette", self.video.palette,
+                            data["palette"])        
+    
+    @printframe("comparing registers")    
+    def compare_registers(data):
+        self.print_check("video dirty", \
+                self.video.dirty, data["dirty"])
+        self.print_check("video display", \
+                self.video.display, data["display"])
+        self.print_check("video bgp", \
+                self.video.background_palette, \
+                data["bgp"])
+        self.print_check("video dma", \
+                self.video.dma, data["dma"])
+        self.print_check("video frames", \
+                self.video.frames, data["frames"])
+        self.print_check("video frameSkip", \
+                self.video.frame_skip, \
+                data["frameSkip"])
+        self.print_check("video lcdc", \
+                self.video.control.read(), data["lcdc"])
+        self.print_check("video ly", \
+                self.video.line_y, data["ly"])
+        self.print_check("video obp0", \
+                self.video.object_palette_0, \
+                data["obp0"])
+        self.print_check("video obp1", \
+                self.video.object_palette_1, \
+                data["obp1"])
+        self.print_check("video scx", \
+                self.video.background.scroll_x, data["scx"])
+        self.print_check("video scy", \
+                self.video.background.scroll_y, data["scy"])
+        self.print_check("video stat", \
+                self.video.status.read(), data["stat"])
+        self.print_check("video transfer", \
+                self.video.transfer, data["transfer"])
+        self.print_check("video vblank", \
+                self.video.v_blank, data["vblank"])
+        self.print_check("video wly", \
+                self.video.window.line_y, data["wly"])
+        self.print_check("video wx", \
+                self.video.window.x, data["wx"])
+        self.print_check("video wy", \
+                self.video.window.y, data["wy"])        
\ No newline at end of file

Added: pypy/trunk/pypy/lang/gameboy/debug/debug_rpc_xml_connection.py
==============================================================================
--- (empty file)
+++ pypy/trunk/pypy/lang/gameboy/debug/debug_rpc_xml_connection.py	Thu Nov 20 00:22:29 2008
@@ -0,0 +1,194 @@
+
+from socket import *
+from pypy.lang.gameboy import cartridge
+from pypy.lang.gameboy import constants
+from socket import *
+from SimpleXMLRPCServer import *
+import sys, threading, time, pdb
+
+
+# -----------------------------------------------------------------------------
+
+DEBUG = False
+
+class printframe(object):
+    open = 0
+    def __init__(self, text):
+        global DEBUG, open
+        printframe.open = 0
+        self.text = text
+        
+    def __call__(self, f):
+        def wrapper(*args, **kwargs):
+            global DEBUG
+            shift =  "    "*printframe.open
+            if DEBUG:
+                print "python:", shift, self.text, "..."
+            printframe.open += 1
+            val = f(*args, **kwargs)
+            if DEBUG:
+                print "python:", shift, self.text, "DONE"
+            printframe.open -= 1
+            return val
+            
+        return wrapper
+        
+# -----------------------------------------------------------------------------        
+
+class DebugRpcXmlConnection(SimpleXMLRPCServer, threading.Thread):
+    
+    
+    def __init__(self, gameboy_debug, debuggerPort, skipExecs):
+        threading.Thread.__init__(self)
+        SimpleXMLRPCServer.__init__(self, ("localhost", debuggerPort))
+        print "python: DEBUGGER PORT:", debuggerPort
+        self.skipExecs            = skipExecs;
+        self.debuggerPort         = debuggerPort
+        self.gameboy_debug        = gameboy_debug
+        self.ini_fields()
+        #self.rpc_paths.append("/pygirl")
+        self.register_introspection_functions()
+        self.register_functions()
+        self.start()
+        
+   def ini_fields():
+        self.pending = False
+        self.started = False
+        self.rom_checked = False
+        self.pending_steps =  0
+        self.showed_skip_message_count = 0
+        self.logRequests = False
+        self.compare_failed = False
+        self.is_closed = False
+        
+    def run(self):
+        self.serve_forever()
+        
+    def register_functions(self):
+        for fn in [(self.start_debug,       "start"),
+                   (self.compare_rom,       "check_rom"),
+                   (self.close,             "close"),
+                   (self.compare_system,    "compare"),
+                   (self.has_next,          "has_next"),
+                   (self.next,              "next")]:
+            self.register_function(fn[0], fn[1])
+    
+    #  ===================================================================
+    
+    def check_rom(self, data):
+        self.gameboy_debug.compare_rom(data)
+    
+    def compare_system(self, data):
+        self.gameboy_debug.compare_system(data)
+
+    #  ===================================================================
+        
+    def close(self):
+    	pdb.set_trace()
+        if not self.is_closed:
+            print "python: called close"
+            self.server_close()
+            self.is_closed = True
+            raise Exception("CLOSED CONNECTION")
+    
+    def start_debug(self):
+        print "python: called start"
+        self.started = True
+        return "started"
+    
+    @printframe("checking rom")
+    def check_rom(self, data):
+        # XXX
+        self.rom_checked = True
+        return "checkedRom"
+    
+    @printframe("compare elements")
+    def compare(self, last_op_code, last_fetch_exec_op_code, instruction_count,
+                registers, interrupts, ram, video, timer, cycles):
+        self.compare_op_codes(last_op_code, last_fetch_exec_op_code)
+        self.compare_registers(registers)
+        self.compare_interrupts(interrupts)
+        self.compare_ram(ram)
+        self.compare_video(video)
+        self.compare_timer(timer)
+        self.compare_cycles(cycles)
+        self.pending = False
+        return "checked"
+    
+    @printframe("waiting for next")
+    def next(self):
+        self.wait_for_next_op_code()
+        return "next"
+    
+    def has_next(self):
+        print "python: called has_next"
+        return self.pending
+
+    # ==========================================================================
+
+    def wait_for_client_start(self):
+        print "python:    waiting for client to start"
+        while not self.started:
+            self.sleep()
+        
+    def wait_for_rom_check(self):
+        print "python:    waiting for client to send rom"
+        while not self.rom_checked:
+            self.sleep()
+    
+    def wait_until_checked(self):
+        while self.pending: 
+            self.sleep()
+        
+    def wait_for_next_op_code(self):
+        while not self.pending:
+            self.sleep()
+        
+    def sleep(self):
+        time.sleep(10/1000)
+        
+    def wait_for_user_input(self):
+        if self.compare_failed:
+            self.compare_failed = False
+            self.handle_compare_failed()
+        if self.pending_steps > 0:
+            self.pending_steps -= 1
+            return
+        self.prompt_for_user_input()
+        
+    def prompt_for_user_input(self):
+        if self.showed_skip_message_count < 2:
+            print ">>  enter skip, default is 0:"
+            self.showed_skip_message_count += 1
+        read = sys.stdin.readline()
+        try:
+            if int(read) > 0:
+                self.pending_steps = int(read)
+            if read == "pdb":
+            	pdb.set_trace()
+        except Exception:
+            if ("stop" in read) or ("exit" in read) or (read is "Q"):
+                raise Exception("Debug mode Stopped by User")
+    
+    def handle_compare_failed(self):
+        for i in range(3):
+            time.sleep(1)
+            print '\a'
+        self.pending_steps = 0
+            
+    # ==========================================================================
+   
+    @printframe("waiting for client to start")
+    def start_debug_session(self):
+        self.wait_for_client_start()
+        self.wait_for_rom_check()
+        
+    @printframe("handle_executed_op_code")
+    def handle_executed_op_code(self, is_fetch_execute=False):
+        if self.cpu.instruction_counter > self.skipExecs:
+            self.pending = True
+        self.wait_for_user_input()
+        self.wait_until_checked()
+        #if self.cpu.instruction_counter == 6154:
+            #pdb.set_trace()
+    

Added: pypy/trunk/pypy/lang/gameboy/debug/debug_util.py
==============================================================================
--- (empty file)
+++ pypy/trunk/pypy/lang/gameboy/debug/debug_util.py	Thu Nov 20 00:22:29 2008
@@ -0,0 +1,76 @@
+import operator
+from pypy.lang.gameboy import cpu
+import pdb
+
+# ----------------------------------------------------------------------------
+# This files contains some static function for print and loggin opcodes
+#
+# ----------------------------------------------------------------------------
+
+DEBUG = True
+DEBUG_PRINT_LOGS = True
+op_codes               = [0] * (0xFF+1)
+fetch_execute_op_codes = [0] * (0xFF+1)
+COUNT                  = [0]
+
+BAR_WIDTH = 79
+PRINT_OPCODE=True
+
+def log(opCode, is_fetch_execute=False):
+    global COUNT, op_codes, fetch_execute_op_codes
+    if DEBUG_PRINT_LOGS:
+        print "=" * BAR_WIDTH
+        if is_fetch_execute:
+            print COUNT[0], "  FETCH EXEC: %i | %s  | %s" % (opCode, hex(opCode), resolve_fetch_opcode_name(opCode))
+        else:
+            print COUNT[0], "  EXEC: %i | %s | %s" % (opCode, hex(opCode), resolve_opcode_name(opCode))
+        print "-" * BAR_WIDTH
+    
+    if is_fetch_execute:
+        fetch_execute_op_codes[opCode ]+= 1
+    else:
+        op_codes[opCode] += 1
+    COUNT[0] += 1
+    #if COUNT % 1000 == 0:
+    #    print "."
+        
+def resolve_opcode_name(opcode):
+    method = cpu.OP_CODES[opcode].__name__
+    if method == "<lambda>":
+        try:
+            functions = "[ "
+            for func_closure in cpu.OP_CODES[opcode].func_closure:
+                functions += func_closure.cell_contents.im_func.__name__+ ", ";
+            return functions + "]";
+        except:
+            return cpu.OP_CODES[opcode].func_code.co_names;
+    else:
+        return method;
+	
+def resolve_fetch_opcode_name(opcode):
+    method = cpu.OP_CODES[opcode].__name__
+    if method == "<lambda>":
+        pdb.set_trace()
+    else:
+        return method;
+    
+
+def print_results():
+    global COUNT, op_codes, fetch_execute_op_codes
+    
+    print_function = (lambda x: "%4s" % hex(x))
+    codes = zip(map( print_function, range(len(op_codes))), op_codes)
+    
+    print_function = (lambda x:  "%4s %4s" % (hex(x[0]), hex(x[1])))
+    opcode_range = range(len(fetch_execute_op_codes))
+    arguments = zip([0x83]  * len(fetch_execute_op_codes), opcode_range)
+    fetch_exec_keys = map( print_function, opcode_range, arguments )
+	# Append the fetchexecuted opcodes to the list
+    codes.extend(zip(fetch_exec_keys, fetch_execute_op_codes))
+    
+    codes = sorted(codes, key=operator.itemgetter(1))
+    for code in codes:
+        if code[1] != 0:
+            print "%8s \t %s" % (code[0], code[1])
+
+    
\ No newline at end of file

Modified: pypy/trunk/pypy/lang/gameboy/debug/gameboy_debug_entry_point.py
==============================================================================
--- pypy/trunk/pypy/lang/gameboy/debug/gameboy_debug_entry_point.py	(original)
+++ pypy/trunk/pypy/lang/gameboy/debug/gameboy_debug_entry_point.py	Thu Nov 20 00:22:29 2008
@@ -1,3 +1,6 @@
+
+dont_import_rsdl = True
+
 from pypy.lang.gameboy.debug.gameboy_debug_implementation import *
 from pypy.lang.gameboy.debug.debug_rpc_xml_memory import *
 import py
@@ -15,11 +18,10 @@
 # ------------------------------------------------------------------------------
 
 ROM_PATH    = str(py.magic.autopath().dirpath().dirpath())+"/rom"
-filename    = "/Users/cami/Ausbildung/08_UNIBE_FS/bachelor/docs/roms/DieMaus.gb"
 filename    = ROM_PATH + "/rom9/rom9.gb"
-SOCKET_PORT = 55687
+SOCKET_PORT = 55691
 skipExecs   = 22545
-skipExecs   = 0
+skipExecs   = 1000000
 
 # ------------------------------------------------------------------------------
 
@@ -54,7 +56,7 @@
                         .dirpath().dirpath()\
                         .dirpath().dirpath()) + "/jmario"
 
-JAVA_CLASSPATH =[ JMARIO_DIR + "/bin/", JMARIO_DIR+"/build/", 
+JAVA_CLASSPATH =[ JMARIO_DIR+"/build/", 
                   JMARIO_DIR + "/lib/xmlrpc-client-3.1.jar",
                   JMARIO_DIR + "/lib/xmlrpc-common-3.1.jar",
                   JMARIO_DIR + "/lib/ws-commons-util-1.0.2.jar",
@@ -68,6 +70,7 @@
               filename + " " + \
               str(SOCKET_PORT) + " " + \
               str(skipExecs)
+    print command
     #command = "java" + \
     #          " -classpath "+ (':'.join(JAVA_CLASSPATH)) +\
     #          " gameboy.platform.j2se.Main " + \

Modified: pypy/trunk/pypy/lang/gameboy/debug/gameboy_debug_implementation.py
==============================================================================
--- pypy/trunk/pypy/lang/gameboy/debug/gameboy_debug_implementation.py	(original)
+++ pypy/trunk/pypy/lang/gameboy/debug/gameboy_debug_implementation.py	Thu Nov 20 00:22:29 2008
@@ -4,7 +4,7 @@
 from pypy.lang.gameboy.gameboy_implementation import *
 from pypy.lang.gameboy.debug.debug_cpu import DebugCPU
 from pypy.lang.gameboy.debug import debug
-from pypy.lang.gameboy.debug.debug_socket_memory import *
+from pypy.lang.gameboy.debug.debug_socket_debug_connection import *
 import time
 import pdb
 
@@ -12,15 +12,28 @@
 
 class GameBoyDebugImplementation(GameBoyImplementation):
     
-    def __init__(self, debuggerPort, skipExecs=0, memory_class=DebugSocketMemory):
+    def __init__(self, debugger_port, skip_execs=0, debug_connection_class=None):
         GameBoyImplementation.__init__(self)
         self.cpu = DebugCPU(self.interrupt, self)
-        self.init_sdl()
-        self.memory = memory_class(self, debuggerPort, skipExecs)
+        self.debug_connection = debug_connection_class(self, debugger_port, skip_execs)
+        self.create_comparators()
         
+     # ------------------------------------------------------------------------   
+    def create_comparators(self):
+        self.gameboy_comparator = GameboyComparator(self.debug_connection, self)
+        self.rom_comparator = ROMComparator(self, self.debug_connection, self)
+    
+    def compare_rom(data):
+         self.rom_comparator.compare(data)
+         
+    def compare_system(data):
+        self.gameboy_comparator.compare(data)
+        
+    # ------------------------------------------------------------------------
+    
     def init_sdl(self):
         pass;
-    
+        
     def create_drivers(self):
         # make sure only the debug drivers are implemented
         self.clock = Clock()
@@ -33,17 +46,17 @@
    
     def handle_execution_error(self, error):
     	print error
-        print "closing socket connections"
+        print "closing socket debug_connections"
         pdb.set_trace()
         self.is_running = False
         debug.print_results()
-        self.memory.close()
+        self.debug_connection.close()
     
     def handle_executed_op_code(self, is_fetch_execute=True):
-        self.memory.handle_executed_op_code(is_fetch_execute)
+        self.debug_connection.handle_executed_op_code(is_fetch_execute)
         
     def mainLoop(self):
-        self.memory.start_debug_session()
+        self.debug_connection.start_debug_session()
         GameBoyImplementation.mainLoop(self)
         
     



More information about the Pypy-commit mailing list