<html><head><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><span style="font-family: Menlo-Regular;" class="">Subject: </span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">An RFC on bringing debugger facility into Tarantool.</span><br style="font-family: Menlo-Regular;" class=""><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">Part of #5857</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">---</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">doc/rfc/inter-fiber-debugger.md | 204 ++++++++++++++++++++++++++++++++</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">1 file changed, 204 insertions(+)</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">create mode 100644 doc/rfc/inter-fiber-debugger.md</span><br style="font-family: Menlo-Regular;" class=""><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">diff --git a/doc/rfc/inter-fiber-debugger.md b/doc/rfc/inter-fiber-debugger.md</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">new file mode 100644</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">index 000000000..e4b64490c</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">--- /dev/null</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+++ b/doc/rfc/inter-fiber-debugger.md</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">@@ -0,0 +1,204 @@</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+# Inter-fiber Debugger for Tarantool</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+* **Status**: In progress</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+* **Start date**: 20-01-2021</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+* **Authors**: Sergey Ostanevich @sergos </span><a href="mailto:sergos@tarantool.org" style="font-family: Menlo-Regular;" class="">sergos@tarantool.org</a><span style="font-family: Menlo-Regular;" class="">,</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+ Igor Munkin @imun </span><a href="mailto:imun@tarantool.org" style="font-family: Menlo-Regular;" class="">imun@tarantool.org</a><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+* **Discussion**: </span><a href="https://github.com/tarantool/tarantool/discussions/5857" style="font-family: Menlo-Regular;" class="">https://github.com/tarantool/tarantool/discussions/5857</a><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+[TOC]</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+### Rationale</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+To make Tarantool platform developer-friendly we should provide a set of basic</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+developer tools. One of such tool is debugger. There are number of debuggers</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+available for the Lua environments, although all of them are missing the</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+critical feature needed for the Tarantool platform: they should not cause a</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+full-stop of the debugged program during the debug session.</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+In this RFC I propose to overcome the problem with a solution that will stop</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+only the fiber to be debugged. It will allow developers to debug their</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+application, while Tarantool can keep processing requests, perform replication</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+and so on.</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+### Approach</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+To do not reinvent the debugger techniques we may borrow the already existent</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+Lua debugger, put the rules about fiber use, data manipulation tweaks and so</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+on.</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+Every fiber can be considered as a 'debuggee' or a regular fiber, switching</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+from one state to the other. To control the status we can either patch fiber</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+machinery - which seems excessive as fibers can serve pure C tasks - or tweak</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+the breakpoint hook to employ the fiber yield. The fiber will appear in a state</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+it waits for commands from the debugger and set the LuaJIT machinery hooks to</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+be prepared for the next fiber to be scheduled.</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+### Debug techniques</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+Regular debuggers provide interruption for all threads at once hence they don't</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+distinguish breakpoints appearance across the threads - they just stop</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+execution. For our case we have to introduce some specifics so that debugger</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+will align with the fiber nature of the server behavior. Let's consider some</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+techniques we can propose to the user.</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+#### 1) Break first fiber met</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+User puts a breakpoint that triggers once, stopping the first fiber the break</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+happens in. After breakpoint is met the fiber reports its status to the</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+debugger server, put itself in a wait state, clears the breakpoint and yields.</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+As soon as server issue a command, the debuggee will reset the breakpoint,</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+handle the command and proceed with execution or yield again.</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+#### 2) Regular breakpoint</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+This mode will start the same way as previous mode, but keep the breakpoint</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+before yield, so that the breakpoint still can trigger in another fiber. As the</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+server may deliver huge number of fibers during its performance, we have to set</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+up a user-configurable limit for the number of debuggee fibers can be set at</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+once. As soon as limit is reached the debuggee fiber starts behave exactly as</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+in previous mode, clearing the breakpoint before the yield from the debuggee.</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+#### 3) Run a function under debug session</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+This is the most straightforward way to debug a function: perform a call</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+through the debug interface. A new fiber will be created and break will appear</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+at the function entrance. The limit of debuggee fibers should be increased and</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+the fiber will behave similar to the modes above.</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+#### 4) Attach debugger to a fiber by ID</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+Every fiber has its numerical ID, so debugger can provide interface to start</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+debugging for a particular fiber. The fiber will be put in a wait state as soon</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+as it start execution after the debugger is attached.</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+### Basic mechanism</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+The Tarantool side of the debugger will consist of a dedicated fiber named</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+DebugSRV that will handle requests from the developer and make bookkeeping of</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+debuggee fibers and their breakpoints and a Lua function DebugHook set as a</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+hook in Lua debug [</span><a href="https://www.lua.org/pil/23.html" style="font-family: Menlo-Regular;" class="">https://www.lua.org/pil/23.html</a><span style="font-family: Menlo-Regular;" class="">] library. Users should not</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+use this hook for the period of debugging to avoid interference. The external</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+interface can be organized over arbitrary protocol, be it a socket connection,</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+console or even IPROTO (using IPROTO_CALL).</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+Debuggee fiber will be controlled by a debug hook function named DebugHook. It</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+is responsibility of the DebugHook to set the debuggee fiber status, check the</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+breakpoints appearance, its condition including the ignore count and update</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+hit_count. As soon as breakpoint is met, the DebugHook has to put its state to</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+pending and wait for command from the DebugSRV.</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+Communication between DebugSRV and the debuggee fiber can be done via</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+fiber.channel mechanism. It will simplify the wait-for semantics.</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+#### Data structure</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+Every debuggee fiber is present in the corresponding table in the DebugSRV</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+fiber. The table has the following format:</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+```</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+debuggees = {</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+ max_debuggee = number,</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+ preserved_hook = {</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+ [1] = function,</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+ [2] = type,</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+ [3] = number</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+ }</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+ fibers = {</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+ [<fiber_id>] = {</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+ state = ['pending'|'operation'],</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+ current_breakpoint = <breakpoint_id>,</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+ channel = fiber.channel,</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+ breakpoints = {</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+ [<breakpoint_id>] = {</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+ type = ['l'|'c'|'r'|'i'],</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+ value = [number|string]</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+ condition = function,</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+ hit_count = number,</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+ ignore_count = number</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+ }</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+ }</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+ }</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+ }</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+ global_breakpoints = {</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+ [<breakpoint_id>] = {</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+ type = ['l'|'c'|'r'|'i'],</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+ value = [number|string]</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+ condition = function,</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+ hit_count = number,</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+ ignore_count = number</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+ }</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+}</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+```</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+As DebugSRV receives commands it updates the structure of the debuggees and</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+forces the fiber wakeup to reset its hook state. The state of the debuggee is</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+one of the following:</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+- 'operation': the fiber is already in the debuggees list, but it issued yield</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+ without any breakpoint met</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+- 'pending': DebugHook waits for a new command from the channel in the</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+ debuggees.fibers of its own ID</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+#### DebugHook behavior</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+For the techniques 3) and 4) fiber appears in the list of debuggees.fibers</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+first, with its status set as 'operation' with a list of breakpoints set.</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+For the techniques 1) and 2) there is a list of global_breakpoints that should</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+be checked by every fiber.</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+In case a fiber receives control from the debug machinery it should check if it</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+is present in ```debuggees.fibers[ID]```. If it is - it should check if its</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+current position meets any breakpoint from the</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+```debuggees.fibers[ID].breakpoints``` or ```debuggees.global_breakponts```. If</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+breakpoint is met, the fiber sets its state into 'pending' and waits for a</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+command from the ```debuggees.fibers[ID].channel```.</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+In case a fiber is not present in the ```debuggees.fibers[ID]``` it should</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+check that the number of fibers entries in the debuggees structure is less than</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+max_debuggee. In such a case it checks if it met any of the</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+```global_breakpoint``` it and put itself into the fibers list, updating the</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+array size [</span><a href="https://www.lua.org/pil/19.1.html" style="font-family: Menlo-Regular;" class="">https://www.lua.org/pil/19.1.html</a><span style="font-family: Menlo-Regular;" class="">]. Also it should open a channel</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+to the DebugSVR and put itself into the 'pending' state.</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+#### DebugSRV behavior</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+DebugSRV handles the input from the user and supports the following list of</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+commands (as mentioned, it can be used from any interface, so commands are</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+function calls for general case):</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+- ```break_info([fiber ID])``` - list all breakpoints with counts and</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+ conditions, limits output for the fiber with ID</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+- ```break_cond(<breakpoint id>, <condition>)``` - set a condition for the</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+ breakpoint, condition should be Lua code evaluating into a boolean value</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+- ```break_ignore(<breakpoint id>, <count>)``` - ignore the number of</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+ breakpoint executions</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+- ```break_delete(<breakpoint id>)``` - removes a breakpoint</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+- ```step(<fiber ID>)``` - continue execution, stepping into the call</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+- ```step_over(<fiber ID>)``` - continue execution until the next source line,</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+ skip calls</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+- ```step_out(<fiber ID>)``` - continue execution until return from the current</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+ function</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+The functions above are common for many debuggers, just some tweaks to adopt</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+fibers. Functions below are more specific, so let's get into some details:</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+- ```set_max_debuggee(number)``` - set the number of fibers can be debugged</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+ simultaneously. It modifies the ```debuggees.max_debuggee``` so that new fibers</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+ will respect the amount of debuggees. For example, if at some point of</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+ debugging there were 5 debuggee fibers user can set this value to 3 - it will</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+ not cause any problem, just a new fiber will not become a debuggee if it meet</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+ some global breakpoint.</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+- ```debug_eval(<fiber ID>, <code>)``` - allows to evaluate the code in the</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+ context of the debuggee fiber if it is in 'pending' mode. User can issue a</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+ ```debug_eval(113, function() return </span><a href="http://fiber.id" style="font-family: Menlo-Regular;" class="">fiber.id</a><span style="font-family: Menlo-Regular;" class="">() end)``` to receive 113 as a</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+ result</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+- ```break(<breakpoint description>, [fiber ID])``` - add a new breakpoint in</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+ the fiber's breakpoint list on in the global list if no fiber ID provided</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+- ```debug_start()``` - starts debug session: creates debuggees structure,</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+ preserve current debug hook in ```debuggees.preserved_hook``` and sets</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+ DebugHook as the current hook</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+- ```debug_stop()``` - quits debug session: resets the debug hook, clears</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+ debuggees structure</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">+</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">--</span><br style="font-family: Menlo-Regular;" class=""><span style="font-family: Menlo-Regular;" class="">2.24.3 (Apple Git-128)</span></body></html>