My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
Debugging  
Explains how to debug your AIModule with the VC++ debugger
Updated Apr 14, 2011 by AHein...@gmail.com

Debugging your AIModule

Debugging an AI Module for BWAPI is not as easy as debugging a regular VC++ application. When you compile an AI Module a DLL file is created which BWAPI will load into the running StarCraft process once a game is started.

For your AI Module to be debuggable you have to compile it in Debug mode. You also have to make sure that your AI Module uses the Multithreaded (Release) DLL (/MD) runtime instead of the Multithreaded Debug DLL (/MDd). If you don't errors will happen and at best BWAPI will complain about not beeing able to load your module. Also make sure [DEBUG] is not listed in your preprocessor definitions because that might give you link errors with the release runtime DLL.

Now to actually debug your DLL you have to use Debug -> Attach to Process from the VC++ main menu and find the already launched StarCraft.exe in the list of running processes. Only after you successfully attached to the running StarCraft.exe the VC++ debugger will be able to halt the game at breakpoints and point you at the location where exceptions are thrown, invalid memory accesses and crashed are produced.

Notes

  • When using BWAPI 2.6.1 Beta Package (with .sln derived from ExampleAIModule)
    • Compile your AI Module in Debug and use Multithreaded (Release) DLL runtime (/MD)
    • Make sure [DEBUG] is not in your preprocessor definitions in case you get linker errors.
    • Debug -> Attach to Process and find StarCraft.exe
  • When using BWAPI from svn
    • Basically the same applies here. The VC++ runtime used by BWAPI and your AIModule should be the same if you want to avoid running into problems.
    • If you compile BWAPI in debug (e.g. using the cmake build system) you can also use the Multithreaded Debug DLL in your AI Module (you probably have to).
Comment by karla...@gmail.com, Dec 7, 2011

Input from Express C++ 9.0 - we had to use the Multithreaded Debug DLL to get it to work - using the Release option as instructed gave us an "unable to load AI module" message ingame. We did remove the DEBUG? flag though.


Sign in to add a comment
Powered by Google Project Hosting