How do I debug Civ 4 ???

vorius

Warlord
Joined
Sep 30, 2005
Messages
264
Location
New York
Hello,

I would like to be able to debug an error I am getting in Civ4 during a save game which is reproducible 100% of the time.

I have both Visual Studio 2005 and 2008 Pro and when the error occurs I get a prompt to debug the code. Now I'm very familiar with using the debugger to debug problems in my client applications but my source code is always available when my debugger prompts me to invoke it. However with Civ4 the only code it knows how to load is from a disassembly, not the actual source code.

Does anyone have experience in how I can utilize Visual Studio with the Civ4 SDK to properly debug the code? Specifically the CvGameCoreDLL assembly.

Any help would be greatly appreciated!
 
You need to compile a debug-able build first.
In my signature is a how to. It's for VS 2005 Express, but being familiar with the matter, you should be able to adapt it.
 
You need to compile a debug-able build first.
In my signature is a how to. It's for VS 2005 Express, but being familiar with the matter, you should be able to adapt it.

Hey, thanks for your helpful reply.

Unfortunately it seems my situation is much different from the one described in your PDF. I guess I could just download the VS 2003 express version and everything but I was really hoping I could use my current versions of VS. Wait, would it even be possible to use these latest versions with Civ4?

As far as I could get is where I try building the solution and end up with the following error:

Error 7 error C2665: 'boost::python::detail::make_getter' : none of the 3 overloads could convert all the argument types c:\Program Files\Firaxis Games\Civ4\CvGameCoreDLL\Boost-1.32.0\include\boost\python\data_members.hpp 277 CvGameCoreDLL

Has anyone got tis successfully working with VS2005 or VS2008 and can share how they did it? Or is this error something simple like my version of Python being wrong (I currently have 2.4.4)

Thanks for your help!
 
I am not aware of anyone who successfully built it on a newer compiler.
So, you can use whatever IDE Shell you want, but you must use the 2003 compiler - either from the full VS 2003 (In which case you can just use the included project file to build a solution), or from the tools linked in the Tutorial and the 2 threads i referenced there (Using the makefile workaround).
Any other compiler seem to cause a compartibility issue - even if you get them to build a DLL it wont work properly with the games exe, presumably because of incompartible memory mapping.
The two threads i referenced in the document have some discussion and notes from people who tried working at different platforms.
 
Well, I found my old copy of VS 2003 and installed it- damn never had this many version of VS on one machine- and you were right, I was able to load the existing vcproj project file and compile it right away- no errors. I was in DEBUG configuration and it generated a CvGameCoreDLL_DEBUG.dll file for me. I moved my original dll and placed this new one in it's place (removing the "_DEBUG" from it's filename) and brought in the pdb file as well.

I ran the game and it immediately starting throwing errors, starting with being unable to load boost_python_vc71-mt-gd-1_32.dll - screenshot attached

any idea what I may have did wrong or missed?
 

Attachments

  • civ4error.GIF
    civ4error.GIF
    9.6 KB · Views: 121
And then, if I take the cheaters route and throw those boost DLLs into my WINDOWS\System32 directory I get this error instead:
 

Attachments

  • civ4error2.JPG
    civ4error2.JPG
    23.7 KB · Views: 108
I debug under VS 2005 (using the 2003 compiler under the Makefile setup Refar alluded to) so some things are different for me. In my case, I can't link against boost_python_vc71-mt-gd-1_32.dll when debugging because it results in other errors; instead I use the boost_python_vc71-mt-1_32.dll in both Debug and Final_Release configurations. I also never touch the .pdb file and only move the game core DLL to the game's Assets directory.

When running a debug DLL you will often get Assertion dialogs; and they can be indicators of an impending crash. That one looks different than I'm used to seeing; mine are more "civ-like" and have different options but perhaps it's because of the different version of VS. Also that filename (dbgdel.cpp) is unfamiliar to me; is it a file from your mod? Anyhow, make sure VS is attached to the process and then try hitting "retry" and it should invoke the debugger.
 
There are 2 debug configurations defined in the project file - the "Final Debug" one seem to work for me - it will generate a correctly named (without the "_DEBUG" appendix), working and yet debugable dll.
The "Debug" configuration in the project file is apparently meant to be used with a different (Debug-able ?) version of the exe...

Similarly, the "Final Release" configuration will produce a working .dll, while the just "Release" one won't.
 
Hmm, I do not have a "Final Debug".

My only options are:

"Debug"
"Debug FxsMemory"
"Final Release"
"Release"
"Release FxsMemory"

These are from the project file:
C:\Program Files\Firaxis Games\Sid Meier's Civilization 4\CvGameCoreDLL\CvGameCoreDLL.vcproj

And Debug FxsMemory produces a DLL named CvGameCoreDLL_DEBUG_MEM.dll

I have not made any modifications whatsoever yet. I just am trying to get debugging the DLL which comes with the game before I start making any changes.
 
I debug under VS 2005 (using the 2003 compiler under the Makefile setup Refar alluded to) so some things are different for me. In my case, I can't link against boost_python_vc71-mt-gd-1_32.dll when debugging because it results in other errors; instead I use the boost_python_vc71-mt-1_32.dll in both Debug and Final_Release configurations. I also never touch the .pdb file and only move the game core DLL to the game's Assets directory.

When running a debug DLL you will often get Assertion dialogs; and they can be indicators of an impending crash. That one looks different than I'm used to seeing; mine are more "civ-like" and have different options but perhaps it's because of the different version of VS. Also that filename (dbgdel.cpp) is unfamiliar to me; is it a file from your mod? Anyhow, make sure VS is attached to the process and then try hitting "retry" and it should invoke the debugger.

Hmm, well I haven't changed anything really. All I did was after installing VS 2003 Pro I opened the project file which came with Civ4 (vanilla Civ4) and hit the Build Solution hot key. I did not touch anything with the configuration at all and I did not make any code changes. It had no errors building and nothing weird happened.
 
Asserts can be triggered by python/xml changes too and they may even be present in a fully unmodified game; they don't always indicate impending doom as some functions are more fault-tolerant than others. The different dialog appearance might be vanilla/BTS differences (I've only modded BTS) although the filename still seems weird. Did you try debugging via "Retry" (or ignoring) when the Assert came up?
 
Uh... Sorry, i wasn't aware you are working on Vanilla Civ4... It does indeed not have the configuration i refered to (nor will the Makefile in my signature work there).
I not have first hand experience compiling Vanilla SDK either.
The both threads i refered to in the / linked in the PDF do originate from Vanilla times however, so you might find some info - and maybe older Makefiles - there.
 
Back
Top Bottom