Löve debugging with ZeroBrane Studio

General discussion about LÖVE, Lua, game development, puns, and unicorns.
paulclinger
Party member
Posts: 221
Joined: Thu Jun 28, 2012 8:46 pm

Re: Löve debugging with ZeroBrane Studio

Post by paulclinger » Thu Jul 05, 2012 3:55 pm

bartbes wrote:It might be interesting to see if a dynamic step size could be implemented, i.e. set it to go 100 lines by default, but if it sees that there's a breakpoint coming up in 30, temporarily set it to less, so you can get there. Now, with calls and all this would be incredibly hard to get right, but even if it only works sometimes it might just be good enough for finding weak points.
It's an interesting suggestion, but it is likely to be difficult to implement (to find out when a breakpoint is "coming up") and, more importantly, any additional processing is making the execution slower yet as it happens in every debug_hook.

In terms of other speed ups, it may be possible to only run call/return hooks (and avoid using the "line" hook in this case), but it means that breakpoints will only work on a last and first line in a function (plus some other constraints), but it should run a bit faster.

paulclinger
Party member
Posts: 221
Joined: Thu Jun 28, 2012 8:46 pm

Re: Löve debugging with ZeroBrane Studio

Post by paulclinger » Thu Jul 05, 2012 4:02 pm

Lap wrote: it would also be nice to be able to take the "jump to function" drop down and optionally sort it alphabetically.
The current order has an advantage of showing the structure of the file "at a glance" and also of putting "local" functions relative to other functions where they are defined.

To make it a bit more useful, I've been thinking about making the drop down more powerful by allowing users to type text and to search for that particular fragment in a list (or a line number); maybe also allow quick navigation to show the fragment each line in the dropdown points to.

User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Löve debugging with ZeroBrane Studio

Post by bartbes » Thu Jul 05, 2012 4:43 pm

paulclinger wrote: In terms of other speed ups, it may be possible to only run call/return hooks (and avoid using the "line" hook in this case), but it means that breakpoints will only work on a last and first line in a function (plus some other constraints), but it should run a bit faster.
Not necessarily the case, if you can find which function you're in, you can do line hooks for just that function.

paulclinger
Party member
Posts: 221
Joined: Thu Jun 28, 2012 8:46 pm

Re: Löve debugging with ZeroBrane Studio

Post by paulclinger » Thu Jul 05, 2012 5:06 pm

bartbes wrote:Not necessarily the case, if you can find which function you're in, you can do line hooks for just that function.
I thought so too, but it proved to be challenging (if at all possible). Either the line hook is already installed (then it will have most or all of the processing it currently has) or it's not. If the hook is not installed, I can't install it during debugging as any changes to debug hook running *from* the debug hook are simply ignored. So, you can't install call/return hook and then have a check in that hook to add a line hook when needed. That's why I suggested adding "stop" method (or "on"/"off" methods) as I can add/remove hooks when running from the user script.

Essentially, all the work in the debugger happens inside the debug hook (there is switching between different coroutines, but from Lua's perspective it seems to be still "inside" the debug hook) and no modification to the debug hook is allowed in that context.

kclanc
Citizen
Posts: 89
Joined: Sun Jan 29, 2012 6:39 pm

Re: Löve debugging with ZeroBrane Studio

Post by kclanc » Thu Jul 05, 2012 5:10 pm

Lap wrote: I also don't know if I'll be able to tolerate the speed decrease (0.1-2% of normal speed). That's a pretty brutal slow down and I don't remember Decoda having such issues.
If you're interested in a more efficient debugger, you might want to try love studio. Love studio will not degrade performance much unless breakpoints have been set. And even when breakpoints have been set, the degradation isn't so bad.

paulclinger
Party member
Posts: 221
Joined: Thu Jun 28, 2012 8:46 pm

Re: Löve debugging with ZeroBrane Studio

Post by paulclinger » Mon Jul 09, 2012 4:44 am

Santos wrote:Congratulations! :awesome:

While admittedly I also can't imagine using anything other than Vim for now (until Light Table is released), I would guess that debugging support will be useful for a lot of people. Live coding could also be a compelling use case. Do the number sliders work with LÖVE? LICK may be of interest.
I got the live coding and the sliders working with Löve. You will need to get the current version from the repository (https://github.com/pkulchenko/ZeroBraneStudio); this functionality will be included in the next release. I'm also working on a screencast, and will post a message when it's ready.

paulclinger
Party member
Posts: 221
Joined: Thu Jun 28, 2012 8:46 pm

Re: Löve debugging with ZeroBrane Studio

Post by paulclinger » Tue Jul 31, 2012 12:45 am

Based on the earlier discussion, I've added on/off methods to the debugger to wrap a fragment you want to debug (and turn debugging off for the rest of the code). I've tested it on something complex (like zoetrope and a couple of games) and the performance is the same as with running without the debugger (as the debug hook is only on for those commands that are between require("mobdebug").on() and require("mobdebug").off() calls). The user can add a breakpoint or "break" the application to use other debugging functions.

[update] This code has been included in the latest version.
Last edited by paulclinger on Fri Sep 21, 2012 3:05 am, edited 1 time in total.

User avatar
klembot
Prole
Posts: 30
Joined: Tue Apr 24, 2012 12:41 am

Re: Löve debugging with ZeroBrane Studio

Post by klembot » Sun Aug 05, 2012 10:40 pm

Just to chime in belatedly, if you set STRICT to true in Zoetrope, it prints warnings whenever code refers to a global variable set to nil, on the theory that this is probably a mistake on the coder's part. https://bitbucket.org/klembot/zoetrope/ ... lua#cl-103 for the details.

Without trying it out yet, this project looks really cool! I could see the use case, even as someone who loves vim, that I would not mind running this in parallel just to debug problems.

paulclinger
Party member
Posts: 221
Joined: Thu Jun 28, 2012 8:46 pm

Re: Löve debugging with ZeroBrane Studio

Post by paulclinger » Wed Aug 22, 2012 12:47 am

klembot wrote:Without trying it out yet, this project looks really cool! I could see the use case, even as someone who loves vim, that I would not mind running this in parallel just to debug problems.
Thank you, klembot! As promised, I published the screencast that demonstrates live coding with Löve scripts: http://notebook.kulchenko.com/zerobrane ... -with-love.

User avatar
WarpEnterprises
Prole
Posts: 3
Joined: Fri Nov 16, 2012 5:10 pm

Re: Löve debugging with ZeroBrane Studio

Post by WarpEnterprises » Mon Jan 28, 2013 3:38 pm

Thanks very much for ZBS, I have some points I can't get to work as I would expect:

* when using Project->Start debugging, it always stops at the ...require("mobdebug").start()... line, although there is no breakpoint there.
* I can't toggle a breakpoint while love is running - is this intentionally?
* is there a keyboard shortcut for adding a selected text to the watch window?

Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests