mirror of
https://git.k-space.ee/arti/vt1200.git
synced 2026-10-30 12:03:54 +02:00
40 lines
1.1 KiB
Lua
40 lines
1.1 KiB
Lua
-- Is the firmware making forward progress, or orbiting a fixed set of addresses?
|
|
--
|
|
-- Samples the PC once per emulated frame and, every COV_WINDOW frames, reports
|
|
-- how many *new* PCs appeared in that window. A plateau means a loop; a steady
|
|
-- trickle means it is still executing new code.
|
|
--
|
|
-- COV_FRAMES=3000 COV_WINDOW=100 <mame> vt1200 ... \
|
|
-- -autoboot_script harness/mame/coverage.lua -autoboot_delay 0
|
|
|
|
local machine = manager.machine
|
|
local cpu = machine.devices[':maincpu']
|
|
local dbg = machine.debugger
|
|
local pc = cpu.state['PC']
|
|
|
|
local maxframes = tonumber(os.getenv("COV_FRAMES") or "3000")
|
|
local window = tonumber(os.getenv("COV_WINDOW") or "100")
|
|
|
|
local seen = {}
|
|
local frames, winnew, total = 0, 0, 0
|
|
|
|
emu.register_frame_done(function()
|
|
frames = frames + 1
|
|
local v = pc.value
|
|
if not seen[v] then
|
|
seen[v] = true
|
|
winnew = winnew + 1
|
|
total = total + 1
|
|
end
|
|
if frames % window == 0 then
|
|
print(string.format("frame %5d new=%4d total_distinct=%5d PC=%08X",
|
|
frames, winnew, total, v))
|
|
winnew = 0
|
|
end
|
|
if frames >= maxframes then
|
|
machine:exit()
|
|
end
|
|
end, "vt1200-coverage")
|
|
|
|
dbg.execution_state = 'run'
|