lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hello,

I have implemented a Lua debugger embed in my application (SCADA system for Industrial Automation).
In step-by-step debugging mode, I would like to evaluate a command string
in the context of the current executing Lua function in a given Lua state.

In other words, a user debugging the code "local some_var = 1; print(some_var)"
would like to execute the expression "some_var = 3" during a debug session
to change the value of that local variable before the next statement in the
debugged code.

My current approach is to load the command (creating a new chunk) in the Lua state
and invoke it with pcall.
The problem is that I cannot write local variables inside the debugged
target function, because the debug expression is a new chunk.

My question is: How to change local variables (from C code) ?
I read several threads about merging upvalues, and did some experiments
but  my current understanding is that it will not work because
local variables are registers and are not stored in _ENV.

Is this possible ? How ?

Any pointers would be appreciated.
best regards,
Rod Senra

http://rodrigo.senra.nom.br