github.com/arnodel/golua@v0.0.0-20230215163904-e0b5347eaaa1/lib/debuglib/lua/debughooks.lua (about) 1 local function hook() end 2 3 do 4 debug.sethook(hook, "clr", 10) 5 print(debug.gethook()) 6 --> ~function.*\tcrl\t10 7 8 debug.sethook() 9 print(debug.gethook()) 10 --> =nil 0 11 end 12 13 do 14 local co = coroutine.create(function() end) 15 debug.sethook(co, hook, "cr", -8) 16 print(debug.gethook(co)) 17 --> ~function.*\tcr\t0 18 19 debug.sethook(co) 20 print(debug.gethook(co)) 21 --> =nil 0 22 end 23 24 -- Errors 25 do 26 local co = coroutine.create(function() end) 27 28 print(pcall(debug.gethook, false)) 29 --> ~false\t.*#1 must be a thread 30 31 print(pcall(debug.sethook, 123)) 32 --> ~false\t.*#1 must be a thread 33 34 print(pcall(debug.sethook, co, hook)) 35 --> ~false\t.*3 arguments needed 36 37 print(pcall(debug.sethook, co, hook, {})) 38 --> ~false\t.*#3 must be a string 39 40 print(pcall(debug.sethook, hook, "cr", "hello")) 41 --> ~false\t.*#3 must be an integer 42 43 end