r/roguelikedev • u/Kyzrati Cogmind | mastodon.gamedev.place/@Kyzrati • May 26 '17
FAQ Fridays REVISITED #9: Debugging
FAQ Fridays REVISITED is a FAQ series running in parallel to our regular one, revisiting previous topics for new devs/projects.
Even if you already replied to the original FAQ, maybe you've learned a lot since then (take a look at your previous post, and link it, too!), or maybe you have a completely different take for a new project? However, if you did post before and are going to comment again, I ask that you add new content or thoughts to the post rather than simply linking to say nothing has changed! This is more valuable to everyone in the long run, and I will always link to the original thread anyway.
I'll be posting them all in the same order, so you can even see what's coming up next and prepare in advance if you like.
(Notice: This week normally would have been a new topic, but I'm a little busy and the number of good fresh topics is dwindling anyway, so in the near term I may just continue favoring our revisited series every week! This will also give our many newer members a chance to catch up more quickly.)
THIS WEEK: Debugging
Some developers enjoy it, some fear it, but everyone has to deal with it--making sure you're code works as intended and locating the source of the problem when it doesn't. As roguelike developers we generally have to deal with fewer bugs of the graphical kind, but where roguelikes really shine is having numerous networked mechanics, a situation that at the same time multiplies the chances of encountering baffling emergent behavior you then have to track down through a maze of numbers and references.
How do you approach debugging? How and where do you use error reporting? Do you use in-house tools? Third-party utilities? Good old print() statements? Language-specific solutions?
You could also share stories about particularly nasty bugs, general problems with testing your code, or other opinions or experiences with the debugging process.
6
u/ampersandagain lowq | no games May 26 '17 edited May 26 '17
I use printf(), and gdb if I have a segfault ;)
Although, I did write this after feeling inspired by Cogmind's episode on RLR. I've only ever used it in moderately mature projects, especially because I don't know where to put global
Logobjects.Now that I look at it, I think the use of templates was overkill. Simple methods, like logerror() or loginfo() would have sufficed, and wouldn't have required all of those enable_ifs :/
6
u/darkgnostic Scaledeep May 26 '17
Dungeons of Everchange
I mostly rely on Visual Studios's fantastic debugger. Over the years I have developed a good skill in fast finding the bugs, which helped me numerous times. There are however, two another tools I use constantly.
For Win32 application, I open one console window in parallel, and output all printfs/couts to that window. Here it is, it is mega useful in numerous scenarios, I hope some of you can find it also useful:
XCode doesn't need such approach, as it prints all those lines in built-in console window.
Third tool I use is visual graph I have developed for calling different blocks once per frame. It's more like visual performance examiner type of tool, although I used it for debugging some LOS issues mostly, for steadying numbers of calls per frame.
There is a part when I also log a lot of what is happening in game in one log file, but I didn't had any use of it yet.
I had one crash dumper, which for some reason showed me always bad lines in code, probably my setup was wrong, so I deleted it.
5
u/Zireael07 Veins of the Earth May 26 '17 edited May 26 '17
Veins of the Earth
I started with T-Engine, which simply redirected print() to log instead of the console/terminal. No debugger, and for the longest time my only recourse in debugging was print().
I discovered debuggers when I tried Lua+Love2D (and downloaded Zerobrane Studio IDE). Since then, I've been advocating language-specific IDEs regardless of whether it's Python, Lua or Java.
And a "print to log" function was usually the first thing I implemented when restarting the project (if not provided by the framework I was using). The ease of browsing through the log once the game/editor is closed is unparalleled.
Currently (slowly) rolling ahead with Java and Netbeans. Netbeans has a built-in debugger based on Visual VM. Getting it to cooperate with a gradle project required some working on my part (see this commit: https://github.com/Zireael07/veins-of-the-earth/commit/0c06a007ea9bdaf28fcba8c7328e1c09aadd2968). However once it cooperated, being able to see time spent on various functions and/or the values in memory has been an immense help.
Free Roam Roguelike Racer Prototype
This incarnation of the side project is being done in Godot.
Godot is a lovely lightweight engine with a built-in editor and debugger and profiler (well, Unity and UE4 also have built-in debuggers and profilers, but not editors).
Since the engine itself is so lightweight, I haven't had any performance trouble in the game itself with my 8 GB RAM. The editor is another story, especially when running tool scripts (Godot's answer to Unity's editor scripts) - some functions which run in 50 ms in game might take fifteen times as much (over 750 ms) in editor!
For general debugging, I use the old standby of print() - printed to console. Godot does not have a built in print to log capacity, but I have been using built-in JSON exports as a workaround. That way I could print and review e.g. all the vertices of my AI's navmesh.
EDIT: Oh, and if the game closes because of a scripting error, Godot just stops it and opens the debugger with all the pertinent info (what script where etc. - as though it was run with debugger on set to break on that line)
4
u/Benjamin-FL May 26 '17
Unnamed Project
I just recently started this project, so I haven't had to do too much debugging so far. It also helps that I'm writing this in Rust so a whole class of issues is never going to happen. That being said, my general approach so far has been mostly print statements and gdb. Gdb has support for rust name mangling, which helps in the few cases where I needed to use it.
Since I am writing my own rendering engine, most of my debugging has actually been graphics and GPU related. Debugging shader code is actually quite difficult because you don't have any sort print statements, so I have been resorting to doing
which is quite clunky. Luckily, I've worked out most of the basics from the rendering side of things so hopefully I will not have to deal with this again. I have also heard good things about RenderDoc, but have never used it.
4
u/VedVid May 26 '17
Fraternities
I'm programming in python, so I'm using PyCharm. And PyCharm has excellent debugging tools. Its debugger is very flexible - I don't need to edit my code to check different conditional scenarios - I can set specific data on every breakpoint. Also thanks to JetBrains' IDE I don't need to be affraid of these small, annoying sytax errors - most of them is reported on the fly by built-in syntax checker.
Beside tools, I'm using prints that isn't that bad as some people keep talking about. I'm programming by ading small portion of code then testing it, so maybe it's the reason why print works for me.
Recently I added partial support for logging. Built-in python's logging module is pretty neat. I didn't add logging for whole application yet - but I'm planning to do it. Curently 'debug mode' is used to track creating objects only. This is one part of Fraternities that I'm ashamed, very spaghetti, very messy, so adding logging for that part of Fraternities was necessary.
Not exactly debugging, but I started to use profiler recently. Definitely not my favorite tool in the box...
4
u/advil00 dcss devteam May 31 '17
DCSS
I'm just one among many people who do debugging on DCSS, and pretty new to the devteam, but here's some of what we do in general plus a few techniques I tend to use. It might be interesting in this sub just because dcss is fairly old, and it's a fairly big codebase with a lot of infrastructure.
General infrastructure:
A lot of players play dcss online, which gives us quite a bit of leverage for getting debugging information. If an online game crashes on one of the official servers, the crashlog is exported to a web-accessible perma-URL such as the above link. Then, a message with the failed assert is sent by a bot to the development IRC channel. You can then get the crashlog URL by querying the bot. So for example, the above linked crash showed up as:
17:14:45 <Eksell> quikTournament (L22 MiFi) ERROR in 'libutil.cc' at line 366: screen write out of bounds: (-36,4) into (43,4) (Depths:4)
Specific techniques:
I don't really have any fancy techniques to offer, but here's what I do when debugging (which is 75% of what I've contributed to dcss):
I'll use a debugger + breakpoints if I have to but most of the time I don't find it faster than output debugging. dcss is so complicated (and such a "mature" codebase) that most of the work is in coming up with a hypothesis about the problem and then testing the hypothesis, and I tend to find this easier to do with output debugging.
0
u/[deleted] May 26 '17
[deleted] — view deleted comment