Closed srdjan-m closed 11 years ago
@srdjan-m, yes, but I ran into some issues with using the debugger with Corona SDK. The problem is described in this SO question: http://stackoverflow.com/questions/12872106/corona-sdk-and-starting-app/.
I'll post details shortly if you want to try yourself.
@srdjan-m, you may try debugging your Corona app using the following steps:
(1) Open main.lua
in, let's say, Sample Code\GettingStarted\HelloWorld
folder and add the following line at the top of the file:
if (system.getInfo("environment")=="simulator") then require("mobdebug").start() end
(2) Add the following batch file to your Corona SDK
folder (let's call it run.bat
; adjust ZBS path):
set ZBS=D:\users\paul\ZeroBraneStudio
set LUA_PATH=.\?.lua;%ZBS%\lualibs/?/?.lua;%ZBS%\lualibs/?.lua
start "Corona" "Corona Simulator.exe" "Sample Code\GettingStarted\HelloWorld\main.lua"
(3) Start ZeroBrane Studio and start the debugger server by going to Project | Start Debugger Server
.
(4) Set the project path to ...Sample Code\GettingStarted\HelloWorld\
and open main.lua
file in the IDE.
You can now run run.bat
file and should see the green arrow in the IDE pointing to the line you added in step 1. You should be able to step through the script, set breakpoints, stop at breakpoints and so on.
You will see that the debugger is started two times: first time when you don't see any Corona UI elements and the second time when it sort of runs "normally" with the UI.
Unfortunately remote shell and expression watch functionality won't work with Corona as Corona SDK doesn't allow loadstring
calls, but you can still see all local variables and their values in the Stack window. Let me know if you have problems with getting it running.
If I can solve this "double start" problem, I can integrate it in a way that allows to run Corona projects from the IDE.
Hi Paul
There is problem (I think) with lua path in bat file. This is what I am getting:
Copyright (C) 2009-2012 C o r o n a L a b s I n c . Version: 2.0.0 Build: 2012.894 Runtime error module 'mobdebug' not found:resource (mobdebug.lu) does not exist in archive no field package.preload['mobdebug'] no file 'd:\work\zombies\corona\zombie\mobdebug.lua' no file 'C:\Program Files (x86)\Corona Labs\Corona SDK\Resources\mobdeRuntime error: module 'mobdebug' not found:resource (mobdebug.lu) does not exist in archive no field package.preload['mobdebug'] no file 'd:\work\zombies\corona\zombie\mobdebug.lua' no file 'C:\Program Files (x86)\Corona Labs\Corona SDK\Resources\mobdebug.lua' no fi
My bat file is: set ZBS=D:\Documents\Downloads\ZeroBraneStudio set LUA_PATH=.\?.lua;%ZBS%\lualibs/?/?.lua;%ZBS%\lualibs/?.lua start "Corona" "Corona Simulator.exe" "D:\Work\Zombies\corona\zombie\main.lua"
Am I doing something wrong?
S
You are right, my instructions were not correct as I skipped one step. You need to copy lualibs/mobdebug/mobdebug.lua
file to Corona SDK Resources
folder.
You can also simplify your batch file down to one command after you do this:
start "Corona" "Corona Simulator.exe" "D:\Work\Zombies\corona\zombie\main.lua"
Of course, it works now :-)
Wow!
But it works so fast! I have huge tables and I am able to inspect them very easy. I really like the Stack window...
There are some problems too. I am getting some errors plus not all local variables are visible. I'll try to find what is causing them and then I'll send you my findings - need to find patterns how to reproduce them...
It will be great to have ZBS as Corona editor. It reminds me of Processing IDE: simply and effective.
Best regards
@srdjan-m, super, glad to know it works for you.
Yes, please let me know what issues you run into and I'll see if I can reproduce them.
As for the local variables, I'm pretty sure all are shown, but keep in mind that not all local variables can be visible in a particular function. For example:
local a = 1
function foo()
local b = 2
end
foo()
When you are looking at the outermost stack frame, you will only see a
variable, but when you are inside function foo, you will only see b
variable, even though you probably expect to see a
and b
. It's because a
variable doesn't exist inside the function foo
. If you reference it, it will become an upvalue and will show up on the list of locals in that stack frame (it will have a slightly different icon associated with it).
If it is something else and you have an example of locals not shown, I'll take a look.
@srdjan-m, do you get the simulator started twice when you do the debugging? For example, I get this in the output:
Windows simulator build date: Jun 19 2012 @ 23:58:39
Copyright (C) 2009-2012 C o r o n a L a b s I n c .
Version: 2.0.0
Build: 2012.840
Copyright (C) 2009-2012 C o r o n a L a b s I n c .
Version: 2.0.0
Build: 2012.840
The debugger starts twice, but the first time without the Corona Simulator window and the second time with the window (like you'd normally in the simulator). Do you see anything similar?
Hi Paul
I don't know if this answer can help, but there is hint of what is going on with Corona debugger:
http://developer.coronalabs.com/forum/2012/07/21/debugger-isnt-working-properly
Regards
Yes, it indeed sheds some light on the issue. I think this is the critical part: "The double start bug always occurs because Corona seems to restart itself if it detects the main chunk stalling". I'll see if I can find a workaround for it.
I wish you luck :-) Hope you can find the solution because I just played with ZBS again: it's great!
One question - I examined the way how api files work (moai and glideros). If I make one for Corona, will it be recognized by ZBS?
Regards
If I make one for Corona, will it be recognized by ZBS?
@srdjan-m, most definitely. You just need to add a file that looks similar to one of those (moai is probably the closest to how Corona integration may work) and it will appear on the list.
In fact, I'm working on one right now as I want to try one option that may partially address this issue. I may have something for you try test in an hour or two.
Wow. Great!
@srdjan-m, I ran into a couple of issues, so it won't be an hour or two, but I think I found a good way to make the debugging work. It still starts twice, but I may have a way to minimize the effect.
Hi Paul
Take your time. It's very late here and I must leave now... Anyway, if you need any help regarding Corona - don't hesitate to ask me
Regards
@srdjan-m, give it a try. Select Corona as the interpreter. It should find your Corona SDK executable if you installed Corona in Program Files
on C: or D: drive (if it's in a non-standard location then set path.corona = 'd:/path/to/Corona SDK/Corona Simulator.exe'
in cfg/user.lua
). Start debugging from the IDE using F5
(or Project | Start Debugging
).
The debugging will start right away, so you may want to put a breakpoint on one of the event handlers. It will still start the debugging twice, but if the breakpoint is on one of the handlers, the first time will quickly finish and the second time will start "normally" and you will get your application running in the simulator. I'm still trying to avoid the first run, but don't see a way right now. Also, not only the stack window, but also watches and the remote console should work too. Break
doesn't work (the application doesn't stop); this is why you need to add a breakpoint before starting the debugger. Let me know if you run into any issues.
Hi Paul
Is there a link I can use to download the new version?
Ups. I've found it.
There is another common corona path: C:\Program Files (x86)\Corona Labs\Corona SDK
There is another common corona path: C:\Program Files (x86)\Corona Labs\Corona SDK
Srdjan, Good point; I'll add this one too.
There is problem with debugging: If I start the debugger - it opens simulator only, without console. And it happens only once. There are no second times. Also, nothing except Stop button is active. I set breakpoints but they are not working. So, currently, I can run and stop simulator. I have no errors, no starting of debugger twice, no cCorona console and no debugging features. It's not that bad. At least I can use it for programming in Corona now :-)
@srdjan-m, what do you see in the output window? This behavior usually indicates that the application can't conect to the debugger.
Did you see the message that mobdebug.lua file was copied to Corona SDK/Resources folder? Can you check if mobdebug.lua is indeed in that folder?
I have no errors, no starting of debugger twice, no Corona console and no debugging features.
Just to make sure we use the same setup. You still need to add this line to main.lua
:
if (system.getInfo("environment")=="simulator") then require("mobdebug").start() end
Also, make sure that you add breakpoints before you start debugging. You will only be able to add breakpoints before debugging is started or when the app is suspended in the debugger.
This is what I see:
Program starting as '"C:\Program Files (x86)\Corona Labs\Corona SDK\Corona Simulator.exe" -debug "D:\Work\Zombies\corona\zombie/main.lua"'. Program 'Corona Simulator.exe' started in 'D:\Work\Zombies\corona\zombie' (pid: 5100).
Mobdebug file is in the resources folder. It is the same as one I copied last night from the last version...
Yes, that was the cause of the problem! I am starting to play now :-D
|if (system.getInfo("environment")=="simulator") then require("mobdebug").start() end|
So, you got the debugger working so far?
And no double starts? This is interesting...
It works now!!! if (system.getInfo("environment")... solved the problem.
No :-) But no console neither...
Good; do you need console to see your debug output? It seems like the console is only shown when Corona.Debugger is used, but not when Corona Simulator is used.
I am on win and mac machines but I am mostly working on win. I did mistake calling win Corona Output window console. So, there are no output winow and, after some testing, I can see that Corona specific errors are not visible. ZBS checks for syntax and reports everything, but Corona bugs like sprite bugs are ommited. I did some mistakes for testing purposes and that is what I've found...
WOW! Remote console kicks ass!
It works quite fine. Apart from corona output there is only one thing I noticed so far: It looks like Pause is not working. During stepping it's gray. After it becomes active nothing happens when I click it...
Looking at the Output win again I can see that debugger starts two times as expected: Program starting as '"C:\Program Files (x86)\Corona Labs\Corona SDK\Corona Simulator.exe" -debug "D:\Work\Zombies\corona\zombie/main.lua"'. Program 'Corona Simulator.exe' started in 'D:\Work\Zombies\corona\zombie' (pid: 4752). Debugging session started in 'D:\Work\Zombies\corona\zombie\'. Debugging session completed (traced 0 instructions). Debugging session started in 'D:\Work\Zombies\corona\zombie\'.
No output window is actually great thing if you can manage to capture Corona output to ZBS Output win. No one wants another win on the screen.
Did I mention that Remote console rocks ?
It looks like Pause is not working. During stepping it's gray. After it becomes active nothing happens when I click it...
@srdjan-m, yes, this is what I mentioned as "Break" is not working. Not sure why yet, but it is using "socket.select" and I don't know if it's handled as expected under Corona. For now let's assume "Pause/Break" is not available.
Did I mention that Remote console rocks?
;) It is indeed very powerful; I didn't expect it to work with the simulator, but it seems like this functionality is enabled with the "-debug" option, which is a pleasant surprise. You can change variables and such and call any commands you can call in your script.
I'll check how I can redirect Corona output to ZBS Output window.
Since you can run Corona SDK on Mac, one question for you: what is the full path to "Corona Simulator" and to the "Resource" folder (where I copy mobdebug.lua)? I'll have an update later today with all small fixes I came up for this integration and want to make sure that Mac paths are correct. Thank you.
I am using osx 10.7.5
And paths on my machine are:
/Applications/CoronaSDK/Corona Simulator.app /Applications/CoronaSDK/Resource Library/
I don't know if this can help, but If you havent't seen it already, here is how Corona's own commandline debugger works: http://developer.coronalabs.com/content/corona-simulator-and-debugger-sample-debugging-session
Regards
@srdjan-m, yes, I saw the description of the command line debugger. In fact, this is the same RemDebug module that MobDebug has been based on (although CoronaLabs made some modifications to it).
/Applications/CoronaSDK/Corona Simulator.app
And what is the path to the actual executable inside the app? It's probably something like Corona Simulator.app/Contents/MacOS/Corona Simulator
.
Sorry:
/Applications/CoronaSDK/Corona Simulator.app/Contents/MacOS/Corona Simulator
@srdjan-m, added redirect of the output to the Output window. Essentially, results from all remote print
commands will be shown in the Output window (this includes results from the console too).
I also added more default paths as you suggested. The Break/Pause still doesn't work and I'm not sure how to fix it.
Could you also test on OSX when you get a chance? I'd like to make sure I got all the paths there correctly too.
Let me know if you run into any issues.
Hi Paul
It looks like ZB have some new issues. I don't know if I am doing something wrong but now Corona doesn't work with ZBS. I have to click three times in order to start the simulator. And when I starts, the project doesn't work. It looks like there is bug in my Corona code and it is stopped at the beginning. If I start the project outside ZBS - everything works fine.
Here is video snapshot of what us going on: http://dl.dropbox.com/u/657073/zbs.zip
Mac version doesn't work too. When I start the project, ZBS copies mobdebug in the correct directory but that is it. Nothing happens after it. Here is what I am getting in the Output:
Program starting as '"/Applications/CoronaSDK/Corona Simulator.app/Contents/MacOS/Corona Simulator" -debug "/Users/Prvi/Documents/Srdjan/zombie/main.lua"'. Program 'Corona Simulator' started in '/Users/Prvi/Documents/Srdjan/zombie' (pid: 351).
Paul Kulchenko wrote:
@srdjan-m https://github.com/srdjan-m, added redirect of the output to the Output window. Essentially, results from all remote |print| commands will be shown in the Output window (this includes results from the console too).
I also added more default paths as you suggested. The Break/Pause still doesn't work and I'm not sure how to fix it.
Could you also test on OSX when you get a chance? I'd like to make sure I got all the paths there correctly too.
Let me know if you run into any issues.
— Reply to this email directly or view it on GitHub https://github.com/pkulchenko/ZeroBraneStudio/issues/73#issuecomment-10174411.
@srdjan-m, you seem to be doing everything correctly, and the project also seems to be executed correctly. You need to click three times because the breakpoint is in the main code that gets executed every time it launches (and it still launches twice). Try setting a breakpoint in one of the event handlers and your application should start on the first click.
It looks like there is bug in my Corona code and it is stopped at the beginning.
Just to make sure it's not related to the "print" output being redirected, you may want to disable that functionality to see if it makes any difference. Try removing , redirect = "r"
from the following fragment in interpreters/corona.lua
:
DebuggerAttachDefault({runstart=true, startwith = file, redirect = "r"})
It is the same. The only difference is that Simulator starts after one click. I used the breakpoints on event before and now too...
Here is example how it looks.Plus, I started the project from Corona and it works (at the end of the video) http://dl.dropbox.com/u/657073/zbs1.zip
@srdjan-m, just to confirm, it was working in this particular setting yesterday, but not today. You tried with and without the redirect with the same result, right?
@srdjan-m, is there any way for me to try it locally? maybe with a fragment of your code that just loads the game?
I've tried with yesterday's version and it works. I also tried with and without redirection in today's version.
Code is little messy and it is much easier for me to send you the whole project (around 4MB) If you want, I can send you the project. Just keep it secret :-)
Most of the changes are in the debugger, so it may be difficult to see where it's breaking without your project code.
@srdjan-m, I found the problem; it was indeed in the "print" related code that was failing when it was trying to build a string to send back to the IDE when you were "print"ing things like tables. This has been fixed already and will be pushed soon. I also added a serialization of table data, so you can do print({1,2,3,"whatever"})
and should get the content of the table printed, rather than "table: ...". Give me an hour or so to wrap it up.
Great
Corona users will be happy to hear that.
@srdjan-m, okay, it took a bit longer than an hour to wrap it up, but I wanted to figure out why "Break/Pause" is not working. It turned out that it actually works, but Corona reports strange file/line information when execution is somewhere inside their control loop (=?:0) and the IDE was simply continuing as it couldn't activate this strange location.
I added a message Debugging suspended at %s:%s (couldn't activate the file).
in a case like this; it looks a bit strange as the debugging is stopped, but no green arrow is present. You can still set breakpoints, look at variables, and try to step through your code, so for all debugging purposes it's the same. If the execution gets back to your script, you will see the green arrow as you see normally.
All other things as well as remote printing (with serialization) should now work. I cut printed lines at 240 characters, but you can write your own output filter to cut them shorter or longer.
Let me know if you run into any issues.
Excellent! I just played with the new version and, so far, it works perfect! I'll test it thoroughly on both systems and will inform you if there are any issues. Table printing is great!!!
Best regards!
@srdjan-m; thank you for the feedback. I'm excited to see it is all working for you. Please let me know when you get a chance to test it on OSX.
Hi Paul
I am testing ZBS all day and it works great! Pause works without any problems. Tonight and tommorrow I'll try it on OSX too.
There is only one thing which doesnt works. For example, if I make mistake like this:
local a = b + 1
and if b is not defined, I am not getting any error in ZBS.
If I try this in Corona simulator I get the following:
Runtime error d:\documents\desktop\test\main.lua:2: attempt to perform arithmetic on g lobal 'b' (a nil value)
Another thing: ZBS editor has features you forgot to mention! Line duplication, line cutting, uppercase etc. Is there list of what else is possible to do with text?
Best regards
and if b is not defined, I am not getting any error in ZBS. If I try this in Corona simulator I get the following: Runtime error d:\documents\desktop\test\main.lua:2: attempt to perform arithmetic on g lobal 'b' (a nil value)
I see; it just stops without an error message; it's probably printed to stderr, which is not sent back to the IDE. I'll see how it may be shown (if possible).
Another thing: ZBS editor has features you forgot to mention! Line duplication, line cutting, uppercase etc. Is there list of what else is possible to do with text?
These are that I know of:
Ctrl-L/Ctrl-Y
= Cut current line
Ctrl-D
= Duplicate selection or current line
Ctrl-Shift-T
= Copy current line
Ctrl-Shift-U
= Uppercase selection
Ctrl-Backspace
= Delete to the beginning of the current word
Ctrl-Delete
= Delete to the end of the current word
Ctrl-Shift-Backspace
= Delete to the beginning of the line
Ctrl-Shift-Delete
= Delete to the end of the line
Alt-Shift-cursor
= Block selection
I'll need to add this to the documentation I'm compiling.
Any plan for Corona SDK support in the near future?