debugging the whole thing
Moderators: hoijui, Moderators
debugging the whole thing
Due to KAIs current simplicity it was an easy task tracking and removing all relevant crash bugs, but i have a feeling it would be much easier to have some proper debug information!
before i start writing a complex logger class, it would be better to try it:
do i just compile the spring cvs and KAI in debug mode? how do i get useful info about a crash?
thanks!
before i start writing a complex logger class, it would be better to try it:
do i just compile the spring cvs and KAI in debug mode? how do i get useful info about a crash?
thanks!
You disable "Catch global AI exceptions" in the config app, and build your AI in debug mode (name it AIdebug.dll or something, so you can clearly see you are picking the right one from the list).
You don't need to build spring in debug mode, just the normal executable will suffice (only you will not be able to read code/variable contents from spring functions on the callstack). Spring in debug mode is so slow it really isn't usable for AI dev.
Then just hope it crashes fast enough... it sucks when you have to wait 20 min before it crashes
VS catches the exception, and shows you the exact point of crashing and allows you even to view the contents of variables.
Also, make sure you let it generate the full debug info database when compiling. This should be the default option though, when you select the "Debug" configuration.
You don't need to build spring in debug mode, just the normal executable will suffice (only you will not be able to read code/variable contents from spring functions on the callstack). Spring in debug mode is so slow it really isn't usable for AI dev.
Then just hope it crashes fast enough... it sucks when you have to wait 20 min before it crashes

VS catches the exception, and shows you the exact point of crashing and allows you even to view the contents of variables.
Also, make sure you let it generate the full debug info database when compiling. This should be the default option though, when you select the "Debug" configuration.
People that don't have a debugger can get a decent one from MS. These are very important tools that tell you what line caused the crash, the value of all the variables, and what function calls led to the code that crashed (stack traces).
http://www.microsoft.com/whdc/devtools/ ... fault.mspx
http://www.codeproject.com/debug/windbg_part1.asp
I have had pretty good success running it on spring and debugging some ai dlls. Just compile the dlls with debug symbols and tell the debugger to run spring.exe with a startup script that loads the ai (springsp works well for creating the scripts) and point the debugger to the source code. Then all you need to do is click go on the debugger.
http://www.microsoft.com/whdc/devtools/ ... fault.mspx
http://www.codeproject.com/debug/windbg_part1.asp
I have had pretty good success running it on spring and debugging some ai dlls. Just compile the dlls with debug symbols and tell the debugger to run spring.exe with a startup script that loads the ai (springsp works well for creating the scripts) and point the debugger to the source code. Then all you need to do is click go on the debugger.
Cool, this might finally let me find out the reason for the most obscure bug ive ever came across in my entire life! its been pretty easy to spot so far since im used to it but its quite stupid IMO:
this crashes:
and this doesnt! (A, B, and C are IDENTICAL to the ones used above)
its simply a random 10% chance of crash added to every codintion in an if statement (using || seems to crash it even more)...
oh well, thinking again i doubt it will help with that but should cut bugfinding time in half...
this crashes:
Code: Select all
if(A && B && C)
code
Code: Select all
if(A && C)
{
if(B)
code
}
oh well, thinking again i doubt it will help with that but should cut bugfinding time in half...
I just log everything and comment out the logs when something is working probably. My logs tend to look like this:
And so on and so forth...
There used to be more.
That way you just add more logging when you have a bug and run it again, and comment it out when you kill the bug. It's what I've been doing.
Code: Select all
Creating MetalHandler...
MetalHandler::MetalHandler(00AB19210)
MetalMap::MetalMap(00AB19210)
121 Metal Points found
Mex Radius: 50
High Metal: 1.2
Setting as OTA Map~
~
Creating Building Organizer...
BuildingOrganizer::BuildingOrganizer(00AB19210)
Found 6 Geothermals.
Setting area around to blocked....
There used to be more.
That way you just add more logging when you have a bug and run it again, and comment it out when you kill the bug. It's what I've been doing.
When I compile in debug mode and set breakpoints in VS as Zaphod taught me, nothign happens save slowing down. An exception occurs? Same results as a normal build but it's more sluggish in exiting spring, I see no change in VS at all, no extra prompts or messages or anything.
I seem tor emember a debugger error when I first tried it out though It might occur everytime btu I aint compiled in debug mdoe for so long I aint tried. It seemed more todo with a faulty debug setup than a faulty dll.
I seem tor emember a debugger error when I first tried it out though It might occur everytime btu I aint compiled in debug mdoe for so long I aint tried. It seemed more todo with a faulty debug setup than a faulty dll.
In VS, click on the left side of the code (light grey probably), you'll see a red dot, that's the breakpoint. This is where execution pauses when you run your program with the debugger attached to it.
Then setup the project so the debugger starts spring.exe. To do that, go to project properties and the debugging section of it. You need to set the command to spring.exe, and the working directory should also be correct, otherwise spring can't see the files.
Also, select the Debug configuration inside the configuration manager, or directly using the toolbar.
Just play around with it, you'll learn...
Then setup the project so the debugger starts spring.exe. To do that, go to project properties and the debugging section of it. You need to set the command to spring.exe, and the working directory should also be correct, otherwise spring can't see the files.
Also, select the Debug configuration inside the configuration manager, or directly using the toolbar.
Just play around with it, you'll learn...
Ah I just looked through VS .Net and ti said somehtign about debugging nto availabel pelase repair/reinstall so i went into the install thgina dn there was a package missing that ahd stuff like windiff and said soemhtign about debugging too so hopefulyl it's alright now.
hmm I thought there was more to what you said than just setting a breakpoint...
hmm I thought there was more to what you said than just setting a breakpoint...
awesome, it crashes every single time when i compile it in debug mode!
even better is that it never ever gives me a debug button or info!
Running it from the lobby gives a spring error, no debug button...
Running it from spring.exe right after compiling just makes it not respond (wont even start up)
what i get in VS is this:
EDIT: wont fit, basically the same access violation message repeated 100000 times
the little spring debug thingy seems pretty useless:
it crashes on frame 5 when it shouldnt. what was supposed to help me stomp bugs IS a bug...
Am i doing something terribly wrong here?
even better is that it never ever gives me a debug button or info!
Running it from the lobby gives a spring error, no debug button...
Running it from spring.exe right after compiling just makes it not respond (wont even start up)
what i get in VS is this:
EDIT: wont fit, basically the same access violation message repeated 100000 times
the little spring debug thingy seems pretty useless:
Code: Select all
- <CallStack>
<Frame FrameNumber="1" ReturnAddress="0xbf60d60" ModuleName="I:\Program Files\TASpring\aidll\globalai\KAI.dll" FunctionName="UnitTable::Init" FunctionDisplacement="0x280" Filename="i:\documents and settings\admin\my documents\visual studio 2005\taspring\testglobalai\unittable.cpp" LineNumber="229" LineDisplacement="0x24" />
<Frame FrameNumber="2" ReturnAddress="0xbf50397" ModuleName="I:\Program Files\TASpring\aidll\globalai\KAI.dll" FunctionName="CGlobalAI::InitAI" FunctionDisplacement="0x2e7" Filename="i:\documents and settings\admin\my documents\visual studio 2005\taspring\testglobalai\globalai.cpp" LineNumber="51" LineDisplacement="0xa" />
<Frame FrameNumber="3" ReturnAddress="0x482a01" />
<Frame FrameNumber="4" ReturnAddress="0x2f6c6c63" />
<Frame FrameNumber="5" ReturnAddress="0xbf0a0" />
</CallStack>
</Exception>
Am i doing something terribly wrong here?
Last edited by krogothe on 06 Jan 2006, 22:26, edited 1 time in total.