Thursday, 19 August 2010

Grass DeBugger

So I was picking up grass and the game crashes after I pick up a second item. Not in first item, but second. What is really bad is when you try to figure out the bug with GDB, which I have now renamed to Grass DeBugger. It's alright telling me that it crashes in Pick_Up_Item. So what, I know that. I really miss the way Visual C debugger works (the way that lets you actually find the fucking bug). In fact I think I have to move this project back to VC to fix the bugs. With GDB it's pretty much the same if you just go through the source code and try to find the bugs yourself.

Switching to events was a sure way to get bugs, because it can be confusing sometimes to keep track of them.

Well, after some manual debugging I found out that I was using an old object handle in pick up: when you pick up something the handle is destroyed when item is added to an existing stack. So, that one was pretty simple.

There is however a trickier bug when kicking coconuts out of a tree. Somehow the coconut can't be picked up, it's not detected by pick up routine (using Level::Find_Item_At). The strange thing is that debug list shows the coconut and you can also see the coconut (it's in the map).

Fixed that bug too. I was using == operator to find match for location and of course some of the z values were different (not always zero as I expected). Made a new routine to check only x, y -coordinates.

3 comments:

Unknown said...

There's more to GDB than "bt" -- make sure you compile your code with debug symbols on (-G) and you should be able to watch variables, set breakpoints (don't need symbols for breakpoints, really), get line numbers, and all the other stuff you're used to.

Also, graphical front-ends exist (ddd is the classic), as well as integration with IDEs. Emacs especially, but also vim, Eclipse, etc.

David said...

+1 to Ethan above.

You might also want to try valgrind, if there's a complicated memory problem.

Krice said...

I'm using -ggdb and I guess it should provide all symbols needed. I can see them as well. Maybe I'm just too stupid to use gdb with DevC++, but I can't figure it out.