lua-users home
lua-l archive

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


I wanna achieve a function that mark value as a watch point, when the value changes, it triggers an event LUA_HOOKWATCH. My intention is to find at witch point and who stealthily changed the value of a specific address(TValue).

I redefine TValuefiled as "Value value_, int watch_:1, int tt_:31". So when TValue, the variant,  who stores the value executes assignment operation, it notifies, if watch_ flag == 1;

I also redefine setobj "...; if (o1->watch_) luaD_hook(LUA_HOOKWATCH); o1->value_ = o2->value_; o1->tt_ = o2->tt_";

My issue is how to mark all Tvalues born with watch_ = 0(not to be watched by default);  and how to locate the Tvalue I hope to watch so that I can mark its watch_ = 1.

More detail, what assignment macros such as setobj, setobj2s, should I redefine?