Quirrel4.53.0

Debug interface

The hooks a debugger, profiler or coverage tool attaches to.

sq_setdebughook installs a callback that the VM calls as the script runs: when a function is called, when it returns, and, if line hooks are enabled, when execution comes to a new source line. A call or a return also starts a new line, even if the line number stays the same.

This hook is enough to build a stepping debugger. sq_stackinfos gives one frame of the call stack, and a stack trace is made from these frames. Code that the compiler runs to evaluate a constant has no frame for the code that uses the constant; sq_getconstevalpos gives that position.

Line information has a cost and can be turned off.

SQRESULT sq_stackinfos(HSQUIRRELVM v, SQInteger level, SQStackInfos *si)

Retrieve the calls stack informations of a ceratain level in the calls stack.

SQRESULT sq_getconstevalpos(HSQUIRRELVM v, SQStackInfos *si)

Retrieves the source position of the constant that the compiler evaluates, while the code that the evaluation runs calls it. Returns SQ_ERROR when no constant is being evaluated.

void sq_setdebughook(HSQUIRRELVM v)

Pops a closure from the stack and sets it as the debug hook, replacing any hook already set, native or not. A null disables it.

void sq_setnativedebughook(HSQUIRRELVM v, SQDEBUGHOOK hook)

Sets the native debug hook. When a native hook is set it overrides any previously set native or non native hooks. if the hook is NULL the debug hook will be disabled.

SQGETTHREAD sq_set_thread_id_function(HSQUIRRELVM v, SQGETTHREAD func)

Tells the VM how to obtain the current OS thread id, which the thread access checks need.

SQCOMPILELINEHOOK sq_set_compile_line_hook(HSQUIRRELVM v, SQCOMPILELINEHOOK hook)

Sets a callback the compiler calls per source line, for coverage tools.

void sq_forbidglobalconstrewrite(HSQUIRRELVM v, SQBool on)

Makes redefining an existing global constant an error.