ZeroBrane studio
#11
(02-25-2014, 09:02 AM)paulclinger Wrote:
(02-24-2014, 10:54 PM)FakeTruth Wrote: I tried to use remote debugging in my own project but it didn't work at all. I have compiled Lua into my project (static linked), could this be the problem and should I use the dll?

Yes, this can be problematic. What happens is this: you have an internal interpreter (statically linked), but socket library is linked against lua51.dll that is included with ZBS. So when you do require"socket" (directly or indirectly through require"mobdebug"), it loads socket.dll, which loads lua51.dll and you end up with two lua engines (and one of them may be "normal" lua and another LuaJIT), which leads to a crash.

There are two ways to deal with it:

(1) statically compile luasocket into your executable that has lua interpreter. That's what some engines do, like love2d.
(2) use a "proxy" DLL that replaces lua51.dll and will simply forward calls to your "static" executable. You can see some details here (http://studio.zerobrane.com/doc-lua52-debugging.html ) described in the context of Lua52 interpreter, but the same thing applies to statically compiled lua51 interpreter as well.

I can provide a proxy DLL if you want to experiment with it. In fact, I've been thinking about including it in the build/ folder of the IDE for cases like this. You'd just need to drop it into the same folder as your executable and the debugging should work.

That's what the documentation said as well. In my case nothing crashed however so I thought something else might be going wrong. Running ZBS and the debugger had no effect at all, it simply didn't do anything for me. (Also I'm using Lua 5.2).
Reply
Thanks given by:
#12
(02-25-2014, 04:39 PM)FakeTruth Wrote: That's what the documentation said as well. In my case nothing crashed however so I thought something else might be going wrong. Running ZBS and the debugger had no effect at all, it simply didn't do anything for me. (Also I'm using Lua 5.2).

That's interesting. And you added "require('mobdebug').start()" to your script and there was no run-time error (so it found both socket module and mobdebug)?
Reply
Thanks given by:
#13
Ah apparently it could not find mobdebugTongue

Is there any way to set up the environment variables from within Visual Studio (2012)?
I tried to set it up like this http://i59.tinypic.com/2my13r4.png but it still cannot find the file.

This is what I get as an error
Code:
Assets/Scripts/MyComponent.lua:2: module 'mobdebug' not found:
        no field package.preload['mobdebug']
        no file './mobdebug.lua'
        no file '/lualibs/mobdebug/mobdebug.lua'
        no file '/lualibs/mobdebug.lua'
        no file '/bin/mobdebug.dll'
        no file '/bin/clibs/mobdebug.dll'



I changed the Environments setting to
Code:
ZBS=E:\Programs\ZeroBraneStudio
LUA_PATH=.\?.lua;E:\Programs\ZeroBraneStudio\lualibs\?\?.lua;E:\Programs\ZeroBraneStudio\lualibs\?.lua
LUA_CPATH=E:\Programs\ZeroBraneStudio\bin\?.dll;E:\Programs\ZeroBraneStudio\bin\clibs\?.dll
And now it crashes as expectedTongue



I tried to compile luasocket into my project but it seems incompatible with Lua 5.2. I made a few edits so it compiles but then it still crashes when require('mobdebug').start() is called.
Reply
Thanks given by:
#14
I have managed to get ZBS debugging working with MCS. There are a few hiccups along the way and it isn't yet too comfortable, but the basics are there Smile
Reply
Thanks given by:
#15
And we have a crash. Turns out two Lua DLLs don't like fighting each otherTongue We need to rename ours to match what LuaSocket expects to find, so that it's loaded instead of the ZBS's one.
Reply
Thanks given by:
#16
(02-27-2014, 04:40 AM)FakeTruth Wrote: I tried to compile luasocket into my project but it seems incompatible with Lua 5.2. I made a few edits so it compiles but then it still crashes when require('mobdebug').start() is called.

If you include the socket library, then none of the libraries that are shipped with ZBS should be used. What module does it crash in?

If you don't use statically compiled socket, then you need to reference clibs52/ instead of clibs/ folder as clibs/ has modules for Lua 5.1. You probably still need the proxy DLL (this one, but compiled for Lua52: http://lua-users.org/wiki/LuaProxyDllFour).

(02-28-2014, 06:27 AM)xoft Wrote: And we have a crash. Turns out two Lua DLLs don't like fighting each otherTongue We need to rename ours to match what LuaSocket expects to find, so that it's loaded instead of the ZBS's one.

It seems like you got it working based on the discussion here.
Reply
Thanks given by:
#17
Basic integration is finished, ZBS can be used to debug MCS plugins. Plus it provides a nice IDE with a good editor.
Now the question that burns me the most: Can the Analyze function be extended (natively or by a plugin) to analyze all the .lua files in a folder, loaded alphabetically one after another? So that we can quickly see if the plugin is using a global value rather than a local, or a typo.
Reply
Thanks given by:
#18
(03-01-2014, 01:29 AM)xoft Wrote: Basic integration is finished, ZBS can be used to debug MCS plugins. Plus it provides a nice IDE with a good editor.
Now the question that burns me the most: Can the Analyze function be extended (natively or by a plugin) to analyze all the .lua files in a folder, loaded alphabetically one after another? So that we can quickly see if the plugin is using a global value rather than a local, or a typo.

Yes, it should be possible, but requires couple of tweaks to the analyzer to expose proper API. I can then make a plugin that will expose a menu item that will analyze all files (like Analyze All). Or maybe just integrate it into the IDE itself; something to think about... Thank you for the suggestion!
Reply
Thanks given by:
#19
I think it would be more suited as a plugin, because the load order of the files is important, and a plugin could implement a specific load order. For example MCS loads all files alphabetically sorted, except for Info.lua, which is always loaded last. If there was a way to account for all this, I'd be super-happy Smile
Reply
Thanks given by:
#20
(03-01-2014, 11:53 AM)xoft Wrote: I think it would be more suited as a plugin, because the load order of the files is important, and a plugin could implement a specific load order. For example MCS loads all files alphabetically sorted, except for Info.lua, which is always loaded last. If there was a way to account for all this, I'd be super-happy Smile

I got it working to process all the Lua files in a project directory one by one in the alphabetical order. Why would you care about a specific order? All the files are processed independently anyway. It would be the same result as if you opened each of them and run "Analyze", just in a more convenient way to process them all together in one click.
Reply
Thanks given by:




Users browsing this thread: 11 Guest(s)