Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / How do I debug?

Author
Message
ET3D
10
Years of Service
User Offline
Joined: 2nd Jul 2013
Location:
Posted: 12th Jul 2013 23:56
I'm using the AppGameKit trial with Tier 1. I've been able to write some simple code and display some stuff, but when I tried a bit more logic I have a bug somewhere which causes wrong indices, and this causes the program to stop with an error message and then exit.

How do I debug this? What debug strategies do experienced AppGameKit users use? I tried printing stuff, but that does usually work well, for example not showing a thing when the error happens (maybe I should sync after the print?).
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 13th Jul 2013 00:06
First, we look very closely at the code and see if we made any obvious mistakes (wrong variable usage for instance).

Then, it varies based on your own experience and skills.

If you can't find anything obvious, posting the error message and the code (if it isn't too long) here and almost any of us are more than happy to try and help you find the problem.

What is the error message? This might be a very simple fix.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
The Zoq2
14
Years of Service
User Offline
Joined: 4th Nov 2009
Location: Linköping, Sweden
Posted: 13th Jul 2013 00:43
Quote: "maybe I should sync after the print"


That is required to update the view.

Personaly, I usualy got along fine with just print back when I was using T1, but I know that a lot of people are saving debug data to files to check for errors. Usually print will be enough when you know where the error occurs, but if you have a broader view to look thru or want to know what happens before the error, debug files could be usefull. Keep in mind that you need to call closeFile() before the changes appear. That means that you will have to call that before the crash.

Good luck
easter bunny
11
Years of Service
User Offline
Joined: 20th Nov 2012
Playing: Dota 2
Posted: 13th Jul 2013 03:58
Here's how I debug tier1,
if I'm not sure exactly where the code is crashing, but it's down to a few lines (20-50) I do it like this:


then when it crashes, it'll be saying "what about here???", so I know it's between that and "maybe here".

the sync() is necessary in t1 btw

Naphier
13
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 13th Jul 2013 06:45
I debug to a log like mad. A basic function for this is:

function WriteDebug(sText$ , iAppend)
fileID = OpenToWrite("debug.txt" , iAppend)
WriteLine(fileID , sText$)
CloseFile(fileID)
endfunction

Set sText$ to what string to log and set iAppend = 0 to overwrite the entire file or set it to 1 to add a new line to the file.
My normal version of this function also has timestamps which is often very helpful, but I'm writing this from my tablet so you're getting the abridged version.
I also often use this method to create a CSV file that I can open in OpenOfficeCalc. I typically set the first line of the file to be the column headers for the CSV spreadsheet.
I also use Notepad++ for viewing the logs because I can leave the log open and N++ just asks if I want to reload it when it has been updated.
This method also can enable you to see how far the program executed.

easter bunny
11
Years of Service
User Offline
Joined: 20th Nov 2012
Playing: Dota 2
Posted: 13th Jul 2013 09:04
just to let you know, when AppGameKit saves/writes to files, it uses a virtual directory @ documents/AGK/[projectname]/media

Digital Awakening
AGK Developer
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 13th Jul 2013 16:26
To debug global variables for running code (which is where most my bugs are right now) I put some print statements at the end of my loop, before i sync. I rarely have crashes that I can't solve with the error message provided by AGK. But when I do I use something similar to Naphier's function to create a log .txt file and read it in notepad. For collision bugs I have used white sprites to indicate touched tiles etc. I have at times used the message() command as well. Remming out parts of your code to locate bugs is also very useful.

So far I have not needed a debugger or break points. Those can be nice but quite often they are slow and they also interrupt the gameflow.

ET3D
10
Years of Service
User Offline
Joined: 2nd Jul 2013
Location:
Posted: 13th Jul 2013 19:21
Thanks a lot for the responses. Sync helped in this case, and I'm glad Digital Awakening mentioned message(). It's something I was looking for.

I do think that debugger support is very helpful, and I'll be waiting for its implementation in AGK2, but for now at least I know better how to use the tools that exist.
The Daddy
15
Years of Service
User Offline
Joined: 13th Jan 2009
Location: Essex
Posted: 16th Jul 2013 00:04
Find a bug. Get rid of bug.

www.bitmanip.com
All the juicy you could ever dream of!

Login to post a reply

Server time is: 2024-05-04 01:55:40
Your offset time is: 2024-05-04 01:55:40