[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Evaluate expressions that modify local variables
- From: Rodrigo Dias Arruda Senra <rodrigo.senra@...>
- Date: Tue, 24 Apr 2012 12:16:38 -0300
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