r/lua•
scripttrading

What's your Lua Debugger?

Hey all, just trying to gauge the usage of Lua debuggers here. Feel free to vote below on ther Lua debugger you use the most. If your debugger is not there feel free to add it in the comments! Thanks

View Poll

Posted May 2, 2020, 7:56 AM UTC

2539
DarkWiiPlayer•

You can get a lot done with just print alone, and when that's not enough, debug can help you a lot as well :D

No need for external debuggers, really; those don't add anything other than a fancy UI that won't always be there when you need it.

13
bonfire_processor•

My experience is that most people who tell that they don’t use debuggers have not learned how to use them effectively. To be honest, using debuggers is not so easy as it looks, and you need the right strategies to be productive (just single stepping trough hundreds of statements is just the opposite).

Of course with interpreted languages that allow introspection and no edit, compile, run cycle, the productivity gain of a debugger is lower compared to e.g. C.

There are also situations where debuggers are the wrong tool (e.g. timing critical code), but this is also part of the experience.

In the case of Lua using the standard debug library is also a form of using a debugger.

5
invention64•

Timed code pains me. Once I had a bug that was fixed once I added in print statements because the code ran slower. It turned out I was using the program execution time rather than the system time so adding more statements made it active longer.

2
burrgundy1•

Yeah print gets it for me

1
BadBoy6767•

Doesn't work well when you're working with recursion.

0
DarkWiiPlayer•

Why not? Most times you can just print the arguments and you will see what iteration you're in, but you can also just set a hook that pauses every the function is called.

1
BadBoy6767•

Not that recursion, but tree visiting.

1
DarkWiiPlayer•

same; you can keep track of where you are with some simple helper variables. It's just a matter of creativity ;D

1
dan200•

No option for "I use an in-house developed lua debugger that I wish we'd release to the public"

7
scripttradingOP•

Haha! I ran out of options so that one had to go! Is that for a corporation?

1
dan200•

A medium-to-large sized game developer

4
scripttradingOP•

It's good to see that such a company invests the time into that though. Is it a visual debugger or a CLI? I'm actually developing a debugger at the moment, hence the interest

2
dan200•

Visual, very similar to what you get debugging C/C++ in Visual Studio. Good luck with your project! We could do with a good, lightweight, open source lua debugger in the public domain :)

3
david-tamar•

There's a useful Lua module for introspection called inspect. It's specializing in human-readable representation of Lua tables. I use that to understand the inner contents of tables during execution time for debugging.

4
scripttradingOP•

Yeah inspect is good actually, forgot to add that to the list!

1
NotExplosive•

I use print statements but I also have a lot of tooling I built in Löve that lets me step through each update loop one at a time so I don't print a million things per second

2
dudinax•

print statements are way more time consuming that just firing up zerobrane. You can even get zerobrane to work with remote luas. It's a huge timesaver.

2
scripttradingOP•

Ok, what's the drawback to zerobrane? Do you have any issues with it at all? Anything you'd make better if you were the developers of ZB?

2
dudinax•

It was a lot of work setting up remote debugging the first time, but I suspect that's a niche feature. That was years ago and maybe there're better guides for doing that now.

Zerobrane is a great program and I can't think of any reason to use print statements over it.

We also used to have our own in-house remote debugger, but zerobrane was far superior to that, too.

2
TankorSmash•

I just got ZeroBrane's remote debugger to work with my game in about 30 minutes, following their official guide. Basically it was setting a flag in Zerobrane's menu, adding

package.path = package.path .. ";C:\\Program Files\\ZeroBrane\\lualibs\\?\\?.lua;C:\\Program Files\\ZeroBrane\\lualibs\\?.lua"
package.cpath = package.cpath .. ";C:\\Program Files\\ZeroBrane\\bin\\clibs52\\?\\?.dll;C:\\Program Files\\ZeroBrane\\bin\\clibs52\\?.dll"
require('mobdebug').start()

to the lua file I was trying to debug, and it basically worked.

Haven't done much more with it since getting it going but it worked and I was stoked.

2
dudinax•

That's pretty slick!

1
dddbbb•

Zerobrane is a great program and I can't think of any reason to use print statements over it.

I was never able to get zerobrane to connect to my project. Are you using a C/C++ game engine with lua embedded in it? Did you just decide to use ZeroBrane, or was it already integrated into your project?

1
schmerm•

I used embedded Lua within C++ for my thesis project. Getting the sockets code working was the hardest part, as well as a remote debugging endpoint (I used mobdebug). I've since graduated, and I've transferred all my source to my supervisor's group repo:

https://github.com/JonathanScottRose/GENIE

Take a look at:

  • sockets.lua and mobdebug.lua in bin/lua
  • src/lua (a mostly unmodified Lua 5.3 distribution)
  • src/luasocket for the c/c++ part of the luasocket library
  • src/main/debugger.cpp for the c++ code that asks mobdebug to connect to a remote debugger like ZeroBrane

The flow here is that ZeroBrane listens on a TCP socket, and your application connects to it once it starts.

3
dudinax•

No. We were running our own C++ software on remote CPUs in measurement instruments. We embedded lua as a scripting language to generate user interfaces. It worked great but was a pain in the neck to debug. Remote debuggers worked in C++ but as soon as you got to a lua function it was all print statements.

Switching to Zerobrane saved us a ton of time on remote debugging. We could just step through the lua code as it ran on the instruments.

I also use Zerobrane for some personal projects, but that's straightforward local debugging.

I went out and found Zerobrane then spent a couple days figuring out how to set up lua sockets and integrate it with Zerobrane. That part was not straight forward. Unfortunately I've recently left that company and can't send you the code. I wish I still had it.

2
dddbbb•

There's also Decoda. However, like ZeroBrane, I've never got it to work.

Decoda hasn't had updates in 6 years, so maybe Unknown Worlds either stopped pushing public changes or started using ZeroBrane :D (ZeroBraneStudio had an update this month!)

2
scripttradingOP•

Good tip, I didn't know about that one, thanks!

2
massimog1•

I love democracy

1
SinisterRectus•

Does linting with luacheck count as debugging?

1
scripttradingOP•

I'd probably say not, but nonetheless, what linter are you using?

2
SmallTestAcount•

Pico-8 time

1
ndgnuh•

naughty.notify hahaha...

1
xorunet•

Multiple options, depending on the environment or project.

1
luarocks•

I use lovebird and inspect.

1
SoCalSurferDude•

Also check out this new Lua debugger for the Mako Server:
https://makoserver.net/articles/Lua-and-LSP-Debugging

1