| author | Julien Desgats | 2013-01-20 14:31:45 (EST) |
|---|---|---|
| committer | Simon Bernard | 2013-02-26 11:34:19 (EST) |
| commit | c9e2fafc4538541ec5c7d3dc5acfe1412e8c725c (patch) (side-by-side diff) | |
| tree | 765571fc7dcbbb4478585a858c4d91a2a5d53576 | |
| parent | ba70f77ce90c5b934b1e24f02a3e589ec63b9ac4 (diff) | |
| download | org.eclipse.koneki.ldt-c9e2fafc4538541ec5c7d3dc5acfe1412e8c725c.zip org.eclipse.koneki.ldt-c9e2fafc4538541ec5c7d3dc5acfe1412e8c725c.tar.gz org.eclipse.koneki.ldt-c9e2fafc4538541ec5c7d3dc5acfe1412e8c725c.tar.bz2 | |
Bug 396930,379965: Continue program execution when debug socket closes
| -rw-r--r-- | libraries/luadbgpclient/debugger/init.lua | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/libraries/luadbgpclient/debugger/init.lua b/libraries/luadbgpclient/debugger/init.lua index 7e547ed..cfd37e1 100644 --- a/libraries/luadbgpclient/debugger/init.lua +++ b/libraries/luadbgpclient/debugger/init.lua @@ -296,6 +296,17 @@ function core.previous_context_response(self, reason) self.previous_context = nil end +local function cleanup() + coroutine.resume, coroutine.wrap = coresume, cowrap + for _, coro in pairs(core.active_coroutines.from_id) do + debug.sethook(coro) + end + -- to remove hook on the main coroutine, it must be the current one (otherwise, this is a no-op) and this function + -- have to be called adain later on the main thread to finish cleaup + debug.sethook() + core.active_coroutines.from_id, core.active_coroutines.from_coro = { }, { } +end + --- This function handles the debugger commands while the execution is paused. This does not use coroutines because there is no -- way to get main coro in Lua 5.1 (only in 5.2) local function debugger_loop(self, async_packet) @@ -312,7 +323,13 @@ local function debugger_loop(self, async_packet) while true do -- reads packet - local packet = async_packet or assert(dbgp.read_packet(self.skt)) + local packet = async_packet or dbgp.read_packet(self.skt) + if not packet then + log("WARNING", "lost debugger connection") + cleanup() + break + end + async_packet = nil log("DEBUG", packet) local cmd, args, data = dbgp.cmd_parse(packet) |

