lua-users home
lua-l archive

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


Hi Luiz,

Thanks for your reply. Maybe I can focus on Lua code only, so ignoring user values for now. So using the custom memory allocator, I could work off a C array for the memory contents. If I save the array to a binary file and then let the interpreter proceed, then it continues to make changes to the array. Now maybe I pause execution somehow by using a co-routine or the debug library.

Then later can I simply restore the array contents from the file and then resume the interpretor, and the interpretor would continue executing from the saved point? And I could repeat this as many times as I want maybe after changing a value of a variable using the debug library :) ?

Thanks,
Abhijit


On Fri, Nov 1, 2019 at 4:15 PM Luiz Henrique de Figueiredo <lhf@tecgraf.puc-rio.br> wrote:
> Is it possible to save the Lua VM state and restore it?

In principle, it can be done since the Lua API accepts a memory
allocator. Like you've said, it is tricky to handle userdata.

I've experimented with LPSM to make a Lua state persistent across
invocations of the interpreter. It worked reasonably well for a while.
The LPSM library is available at http://freshmeat.net/projects/lpsm/
but it does not seem to work on modern systems. I'd love to hear about
a modern replacement.