FYI: debug build VC7

scriptkid

25-05-2007 10:21:40

Hi VC users,

this is just some information about my results in getting a debug build of Python-Ogre to track down a crash during application quiting, with some results. Use it to your benefits :)

I post my changes below, because i have made some other changes as well, which would make a patch file a bit messy. But i am willing to make a patch against a clean checkout, so please let me know when the steps below are not clear enough.

Step 1

In order to switch between debug- and release builds, i added a 'config' field to the PythonOgreConfig_nt.py file, like:

config = 'Debug'

And replaced each occurence of 'Release' with that config setting. For example
os.path.join ( PATH_CEGUI, 'lib/Release' )
becomes
os.path.join ( PATH_CEGUI, 'lib/%s' %config )

Step 2

The second step is to modify the Environment.py file as well, by adding a postfix variable like:

postfix = '_d'

and change all 'libs' lists by replacing for example
libs=[Config.LIB_Boost, 'OgreMain']
with
libs=[Config.LIB_Boost, 'OgreMain%s' %postfix]

I did the same for the 'externalFiles' lists, but i don't think they are used by the compiler because when writing this down i noticed an error in my file ;)

Step 3
Finally, open SConstruct (scons file) and add a '/Zi' option to the CCFLAGS. Can also be done with a same helper string as used above.

After compiling (takes a while!) and running 'python setup.py install' i manually had to copy over my DLLs to the site packages directory, but i am not sure if that's okay. Or should 'setup.py' handle those?

Running
Now when running and you get a crash or an assert, you will first see the VC message box. When you choose 'retry' you will get a windows crash dialog for Python.exe. Choosing 'find errors' (the left button) gets you into VC. This will start with the Python.exe process but on continuing it will open up an Ogre file or something. Of course you can also launch your game and attach the debugger to Python.exe and put breakpoint in all or your used C++ code. Works like a charm :)

Bye,
Patrick.