openMSX debugging using tcl commands

بواسطة jepmsx

Master (170)

صورة jepmsx

30-10-2021, 18:22

Hi!

I want to run the emulator step by step and store the command that is running in a file for every step.

If I do these two steps after the emulator is in breaked state:

debug step
disasm

and iterate over them, I've got the command that is going to be run in each moment.

But when I do:

for {set k 0} {$k<500} {incr k} {
        debug step;             # 
        save_to_file out${k}.txt [disasm]
    }

the different files have the same disasm output, always running the same step, like debug step didn't run, it doesn't advance step by step, it is stopped at the same instruction.

What am I doing wrong?

Login أوregister لوضع تعليقاتك

بواسطة Grauw

Ascended (10619)

صورة Grauw

30-10-2021, 19:45

You need to suspend the TCL execution to let the emulator actually run. The emulation is halted during TCL execution.

Not sure if there's an easy way to do that, probably you'll need to build an asynchronous loop using breakpoints...

بواسطة jepmsx

Master (170)

صورة jepmsx

30-10-2021, 19:39

Oh, I see. The problem is not the script.

Thanks Grauw for your answer.

So I think the best approach is to use a socket for communicating with the openMSX to control it remotely as it is explained in https://openmsx.org/manual/openmsx-control.html. I'll try to do it

بواسطة wouter_

Champion (486)

صورة wouter_

30-10-2021, 22:34

Grauw is right, when the Tcl script is executing MSX emulation is paused. You can trigger a Tcl callback after each instruction using 'debug conditions' (for more info execute help debug set_condition in the openMSX console).

Though if your goal is to get a trace of the executed instructions, then using the cputrace setting may be simpler.

بواسطة jepmsx

Master (170)

صورة jepmsx

31-10-2021, 08:07

It's been easier than I thought.

I've found the socket as it is explained in control openmsx in my /tmp/openMSX-user/socket.XXXX and with python I've done:

import socket

s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
s.connect('/tmp/openmsx-jep/socket.4828')
s.send(bytes("debug step","utf-8"))
s.send(bytes("save_to_file out.txt [disasm]","utf-8"))
s.close()

and I can control it without problem from python