8.8.1.1.2.3.2. Exceptions

exception ScriptingTimeoutError

Exception that is raised when a scripting command times out

The timeout duration can be configured with setScriptingTimeout() or as an argument to initScripting().

# configure with a timeout of 10 seconds
ds = initScripting({ "timeout": 10000 })

# this also works
ds.setScriptingTimeout(10000)

# Configure a debug session and load a program on the first CPU
ds.configure("/path/to/my/ccxml_file.ccxml")
session = ds.openSession()
session.memory.loadProgram("/path/to/my/program.out")

# We expect our program to reach the function foo()
session.breakpoints.add("foo")

try:
    # Will resume execution and wait for the cpu to halt
    session.target.run()

    # CPU halted, did it halt at foo?
    if session.registers.read("PC") == session.expressions.evaluate("foo"):
        print("CPU halted at foo()")
    else:
        print("CPU halted, but not at foo")

except ScriptingTimeoutError:
    print("CPU did not halt, gave up after 10 seconds")
    session.target.halt()

ds.shutdown()