下载地址
http://studio.zerobrane.com/download?not-this-time
github地址:
https://github.com/pkulchenko/ZeroBraneStudio
安装步骤
无需安装,直接在文件中找到zbstudio文件夹,可运行程序在里面。
ZeroBrane Studio常用窗口
-
Console window
类似终端实时交互模式
Stack window
简而言之就是获取断点数据(返回的函数名,变量),也可单独进入table里面查看数据。
问题:发现没有用local定义的变量无法在stack中显示。
-
Watch window
利用addwatch添加自己要关注的变量。
How debugging works
在IDE中一共有两种方式启动debug。他们的工作方式是相同的:在进行debug调试的时候首先将debugger组件载入应用程序中。与IDE建立起socket连接。IDE接受用户的命令(单步调试,断点,等等信息)。然后IDE发送这些命令给给应用程序中的debugger组件。如果有返回数据IDE还会进行处理。
当应用程序由于(单步,断点,break命令)挂起的时候。IDE将会去寻找哪里使得应用程序挂起的源文件。如果这个文件已经在IDE中打开,将会在当前行有绿色箭头的默认标签(与大部分编译器是一样的)。如果文件没有在IDE中打开,但是如果配置信息 (editor.autoactivate = true),文件也会被加载到IDE中(貌似我都是拉进去直接设置断点)。
远程调试(Remote debugging)
- Open ZeroBrane Studio. Go to Project | Start Debugger Server and start the debugger server
- Open the Lua file you want to debug.
- Select the project directory by going to Project | Project Directory | Choose...or using Project | Project Directory | Set From Current File.(打开工程)
- 将
require('mobdebug').start()
添加进去lua文件中。如果应用程序是在别的计算机上运行,就必须去定位IP地址在格式变为require('mobdebug').start("12.345.67.89")
orrequire('mobdebug').start("domain.name")
(暂时没有去用过,官方介绍使用)
Make mobdebug.lua and luasocket available to your application
可以通过三种方式
First:Setup environment for debugging(设置环境变量)
Windows平台
set ZBS=D:\path\to\ZeroBraneStudio
set LUA\_PATH=./?.lua;%ZBS%/lualibs/?/?.lua;%ZBS%/lualibs/?.lua
set LUA_CPATH=%ZBS%/bin/?.dll;%ZBS%/bin/clibs/?.dll
\./myapplication
Macosx && Linux
export ZBS=/opt/zbstudio
export LUA_PATH="./?.lua;$ZBS/lualibs/?/?.lua;$ZBS/lualibs/?.lua"
export LUA_CPATH="$ZBS/bin/linux/x64/?.dll;$ZBS/bin/linux/x64/clibs/?.dll"
./myapplication
其中LUA_CPATH如果已经配置过环境变量以及配置过luasocket的路径就不需要在这边再次配了。注意点:上面路径要根据自己电脑的路径来写,比如linux/x64是很多不需要的。
Second:Configure path for debugging
设置package.path 和 package.path(如果需要的话)(暂时未使用过这种方法)
package.path = package.path .. ";/opt/zbstudio/lualibs/mobdebug/?.lua"
Third:Include mobdebug.lua with your application
copying mobdebug.lua
from lualibs/mobdebug/mobdebug.lua (this assumes your application already provides luasocket support).
然后在你的文件中require('mobdebug').start()
Troubleshooting
- 如何找到
mobdebug.lua
?在Linux中路径是/opt/zbstudio
。而在Mac OS X中路径应该是/Applications/ZeroBraneStudio.app/Contents/ZeroBraneStudio
。右键ZeroBraneStudio ,打开显示包内容,去获得你的完全路径。(上面ZBS的路径)
其他一些问题也是官网上有的。暂时没有在编译过程中遇到问题。所以下面就不进行中文解释了。
I can’t step into functions defined in other files in my project. You either need to open them in the IDE before you want to step through them, or to configure the IDE to auto-open files requested during debugging using editor.autoactivate = true.
The host name is detected incorrectly. In some rare cases the domain name detected by ZeroBrane Studio cannot be resolved, which prevents the debugger from working. You can specify the domain name or address you want to use by configuring the IDE with debugger.hostname="domain".
I get dynamic libraries not enabled error.You may get the following error when loading socket.core on Linux: error loading module ‘socket.core’ from file ‘/opt/zstudio/bin/linux/x86/clibs/socket/core.so’: dynamic libraries not enabled; check your Lua installation. This most likely means that the Lua interpreter you are using was built without LUA_USE_DLOPEN option enabled. You can either enable it or statically link your application with luasocket.
(这个问题发生在了colortouch调试的时候,因为不接受动态库,所以应该将luasocket编译到工程中)**(Note: you should not see this error if you are using v0.38 or later) I get “Debugger error: unexpected response after EXEC/LOAD ‘201 Started …’”. This is caused by not having a filename associated with a dynamic chunk loaded by your application. If you are using loadstring(), you should pass a second parameter that is a filename for the fragment (and that file can then be debugged in ZeroBrane Studio if it’s placed in the project directory). If you are using luaL_loadstring (which has no option to label the chunk with its file path), you can switch to using luaL_loadbuffer to pass that information.