How to debug Lua remotely?
I'm searching for the best way to debug Lua remotely, ( like from a web browser ).
I saw RemDebug, but the last project update was done on 2006. It works with Lua 5.0 and 5.1, but Lua 5.2 is quite close, and I don't see RemDebug to get an update anytime soon.
I could mount a small embedded web-server on my debug host, and use something like RemDebug to communicate with it, 开发者_开发问答and perform remote debugging via HTTP.
Suggestions are appreciated.
I have developed a new debugger based on RemDebug (MobDebug) with new commands, new features, bugfixes, and integration with IDEs.
MobDebug is based on TCP interaction between the client (debugee) and the server (controller). This is also the case for RemDebug and most other remote debuggers. You might be able to run on top of something else (like WebSockets or HTTP), but you still need to be able to run coroutines and debug hook to control the application being debugged.
The architecture of the debugging process is quite simple:
- You have an application you want to debug
- You also have your debugger with a controller
- The application loads the client components of the debugger, which opens a connection to the controller
- The controller accepts commands from a command line or an IDE (MobDebug provides both; it integrates with ZeroBraneStudio and also provides a scriptable way to run it)
- When the application is loaded, the debugger installs a debug hook, which is run on every line/call/return. From this debug hook a resume call is made to the debugger, which can then execute commands from the controller (like install a breakpoint, evaluate an expression and so on). When the next executable command is send (like run or step), the debugger yields back to the hook, which then returns back to the app allowing it to proceed.
It may be possible to mimic the existing socket interface (as it's only using connect/send/receive and select/timeout to abort the application) and reuse most of the library. I'm still not sure why you'd want to run this in a browser though as you can run the application on anything that supports TCP already (I have a working prototype debugging an application running on a mobile device from my desktop).
I found Hillin's Remote Lua Debugger 1.2.0.218
I was not sure if you need to debug lua remotely or ask about doing so over HTTP; I'm answering about the former and am not aware of a way to do so over HTTP.
Both LuaEdit and Decoda allow you to connect remotely to a running lua script (both on a different process on the same machine and on a remote machine).
Decoda can do magic and do so for a lua VM without requiring any change to the VM; with LuaEdit you need to create the VM in a specific way, using a provided DLL or library.
I'm not sure if this is right. Hope it helps though:
Source: http://www.keplerproject.org/remdebug/example.html
This is an example of a debugging session of the following script (test.lua):
1 require"remdebug.engine"
2
3 remdebug.engine.start()
4
5 local tab = {
6 foo = 1,
7 bar = 2
8 }
9
10 print("Start")
11
12 function bar()
13 print("In bar 1")
14 print("In bar 2")
15 end
16
17 for i = 1, 10 do
18 print("Loop")
19 bar()
20 tab.foo = tab.foo * 2
21 end
22
23 print("End")
First run the RemDebug controller:
% lua50 controller.lua Lua Remote Debugger Run the program you wish to debug At this moment you can run your target program (in another window):
% lua50 test.lua Now go back to the window where you ran controller.lua (this assumes you are running test.lua inside C:\development\kepler on a Windows system):
Paused at file C:/development/kepler/test.lua Type 'help' for commands
basedir C:/development/kepler/ New base directory is C:/development/kepler/ basedir C:/development/kepler/ step Paused at file C:/development/kepler/test.lua line 6 over Paused at file C:/development/kepler/test.lua line 7 over Paused at file C:/development/kepler/test.lua line 10 over Paused at file C:/development/kepler/test.lua line 15 setb test.lua 19 run You can change to the application window anytime to see its output. Back to the debugger session:
Paused at file C:/development/kepler/test.lua line 19
run Paused at file C:/development/kepler/test.lua line 19 eval tab.foo 2 eval tab.bar 2 exec old_tab = tab nil exec tab = 2 nil eval tab 2 exec tab = old_tab nil eval tab.foo 2 run Paused at file C:/development/kepler/test.lua line 19 eval tab.foo 4 delb test.lua 19 setw tab.foo == 32 Inserted watch exp no. 1 run Paused at file C:/development/kepler/test.lua line 17 (watch expression 1: [tab.foo = 32]) eval tab.foo 32 delw 1 run Program finished
Don't know for web-browser debugging (the idea seems weird to me, maybe you can detail why you would need a web-browser debugger ?)
For a standalone debugger however, I've written a remote debugger with GUI : http://cushy-code.com/grld
It communicates with the debugged program with the socket API, so any network connection will do, no need for HTTP.
Hope this helps.
精彩评论