From 76ab48df3b23669142dc925680cdb00a33192f87 Mon Sep 17 00:00:00 2001 From: Cloud Wu Date: Thu, 12 Feb 2015 14:34:52 +0800 Subject: [PATCH] bugfix: watch hook begin at next call --- lualib/skynet/remotedebug.lua | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/lualib/skynet/remotedebug.lua b/lualib/skynet/remotedebug.lua index 8b7c89e3..1fa04155 100644 --- a/lualib/skynet/remotedebug.lua +++ b/lualib/skynet/remotedebug.lua @@ -114,8 +114,7 @@ function linehook(mode, line) return end end - -- Lua 5.3 report currentline seems wrong - change_prompt(string.format("%s(%d)>",ctx.filename, line-1)) + change_prompt(string.format("%s(%d)>",ctx.filename, line)) return true -- yield end end @@ -124,14 +123,18 @@ local function add_watch_hook() local co = coroutine.running() local ctx = {} ctx_active[co] = ctx - local level = 3 - sethook(function() - level = level - 1 - if level == 0 then - ctx.needupdate = true - sethook(linehook, "crl") + local level = 1 + sethook(function(mode) + if mode == "return" then + level = level - 1 + else + level = level + 1 + if level == 0 then + ctx.needupdate = true + sethook(linehook, "crl") + end end - end, "r") + end, "cr") end local function watch_proto(protoname, cond)