lua-users home
lua-l archive

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


> Seems I am missing something. But what?

Not sure; I changed the hook to be a count hook, but lines 5 and 6
don't appear in the output, which is the expected result:

debug.sethook(function(ev, line) print(ev, line, debug.getinfo(2,
"l").currentline) end, "", 1)
print(coroutine.running())
print(debug.gethook(coroutine.running()))
coroutine.resume(coroutine.create(function()
      print(coroutine.running())
      print(debug.gethook(coroutine.running()))
    end))
debug.sethook()
print("done")

> And how do you deal with threads created with lua_newthread? You don't
get a change to install the debugger hook, do you?

Correct; for the Lua code I do the same thing that Thijs suggested: I
overwrite coroutine.create (when the user desires) to install the hook
for every Lua coroutine. If it's created using the C API, it doesn't
get the hook (but there is still a way to add it with an explicit
call).

> I use this threads primary for callbacks from the C-side.

I have on/off calls that install/remove hook for the current coroutine
(you can get it with coroutine.running()), which works for coroutines
created from the C-side as well.

Paul.