mirror of
https://git.k-space.ee/arti/vt1200.git
synced 2026-10-31 12:05:05 +02:00
41 lines
1.2 KiB
Lua
41 lines
1.2 KiB
Lua
-- probe_hook.lua -- investigation only: log the DI hook stages of blinkpc.
|
|
-- Sets breakpoints at entry / ret_hook / the stock OS handler after the hook is
|
|
-- installed, prints PC/SP/ST, and resumes. Never writes memory.
|
|
local machine = manager.machine
|
|
local cpu = machine.devices[':maincpu']
|
|
local dbg = machine.debugger
|
|
if not dbg then print("ERROR: no debugger"); machine:exit(); return end
|
|
local ARM = tonumber(os.getenv("HOOK_ARM") or "3450")
|
|
local STOP = tonumber(os.getenv("HOOK_STOP") or "3520")
|
|
local f = 0
|
|
local armed = false
|
|
local clock = os.getenv("FRAME_CLOCK")
|
|
|
|
local function bp(addr, tag)
|
|
dbg:command(string.format(
|
|
'bpset %s,,{ printf "HOOK %s pc=%%08X sp=%%08X st=%%08X a0=%%08X\\n", pc, sp, st, a0 ; g }',
|
|
addr, tag))
|
|
end
|
|
|
|
emu.register_frame_done(function()
|
|
f = f + 1
|
|
if clock then
|
|
local fh = io.open(clock, "w")
|
|
if fh then fh:write(f .. "\n"); fh:close() end
|
|
end
|
|
if f == ARM and not armed then
|
|
armed = true
|
|
bp("1840190", "ENTRY")
|
|
bp("18402d0", "RET")
|
|
bp("3f7146d0", "OSH")
|
|
print(string.format("probe_hook: armed at frame %d", f))
|
|
end
|
|
if f >= STOP then
|
|
print("probe_hook: stopping")
|
|
machine:exit()
|
|
end
|
|
end, "vt1200-probe-hook")
|
|
|
|
dbg.visible_cpu = cpu
|
|
dbg.execution_state = 'run'
|