lua-users home
lua-l archive

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


I was playing with debug gethook...

local count = 0
local mt = coroutine.running()
local function hack(trigger, line)
  local h,m,c = debug.gethook(mt)
  print(h,m,c)
  if (trigger == "call" or trigger == "tail call") and m:find("c") then
    return h(trigger, line)
  elseif trigger == "return" and m:find("r") then
    return h(trigger, line)
  elseif trigger == "line" and m:find("l") then
    return h(trigger, line)
  elseif trigger == "count" and c ~= 0 and count >= c then
    count = count % c
    return h(trigger, line)
  end
end
local co = coroutine.create(function() while true do end end)
debug.sethook(co,hack,"clr",1)
coroutine.resume(co)

When I type ^C this happens:

external hook    cr    1

How can I call "external hook"?