local cpu = manager.machine.devices[":maincpu"] if os.getenv("TRACE_SYMBOLS") then for name, entry in pairs(cpu.state) do print("STATE", name, entry.symbol, entry.visible) end manager.machine:exit() return end local dbg = manager.machine.debugger dbg.visible_cpu = cpu local stop = tonumber(os.getenv("TRACE_FRAMES")) local frames = 0 dbg:command('trace trace.txt,,noloop,{logerror "%04X %04X %04X %04X %04X %04X %04X %04X %04X %02X %d\n",' .. 'curpc,r0,r1,r2,r3,r4,r5,r6,r7,curflags,totalcycles}') -- Held in a global: a local subscription is garbage-collected and stops firing. frame_tap = emu.add_machine_frame_notifier(function() frames = frames + 1 if frames >= stop then dbg:command("trace off") manager.machine:exit() end end) dbg:command("go")