After trying to debug some crashes, I decided to implement for CvGameCoreDLL a debugging feature that I'm accustomed to use: memory dumps.
A memory dump (also called minidump) is a snapshot of the memory state of a program, including only the information required to get a stacktrace. With this modification to CvGameCoreDLL, a memory dump file is created after a crash next to Civ4BeyondSword.exe. This file can be used by a developer to debug a crash that happened for someone else, as long as that person sends the developer the dmp file. To debug the crash, you only need to place the dmp file next to the executable (in our case Civ4BeyondSword.exe).
If our application (CvGameCoreDLL) has been compiled with enough debug information to generate a pdb file (/Zi in CFLAGS and /DEBUG in LDFLAGS) and that file can be found in the same folder where the original dll was compiled, opening the dmp file will start Visual Studio which will be able to start debugging in the same state in which the user initially had the crash.
As mentioned, for this to be useful, you need to compile a release version that generates debug symbols (or distribute a debug build). As far as I know, since the options explained above only affect the generation of the pdb file (they also add the path to the pdb file to CvGameCoreDLL), adding them to releases shouldn't have an impact in performance, but this claim is completely untested
The Express edition of Visual Studio 2010 can't open dmp files. You can use the Express edition of Visual Studio 2008, though.
It can be found here: http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=14597
This small modcomp only contains two hunks of changes to CvGlobals.cpp, clearly labelled with "MINIDUMP_MOD". I'm uploading that file with my changes to this thread.
A memory dump (also called minidump) is a snapshot of the memory state of a program, including only the information required to get a stacktrace. With this modification to CvGameCoreDLL, a memory dump file is created after a crash next to Civ4BeyondSword.exe. This file can be used by a developer to debug a crash that happened for someone else, as long as that person sends the developer the dmp file. To debug the crash, you only need to place the dmp file next to the executable (in our case Civ4BeyondSword.exe).
If our application (CvGameCoreDLL) has been compiled with enough debug information to generate a pdb file (/Zi in CFLAGS and /DEBUG in LDFLAGS) and that file can be found in the same folder where the original dll was compiled, opening the dmp file will start Visual Studio which will be able to start debugging in the same state in which the user initially had the crash.
As mentioned, for this to be useful, you need to compile a release version that generates debug symbols (or distribute a debug build). As far as I know, since the options explained above only affect the generation of the pdb file (they also add the path to the pdb file to CvGameCoreDLL), adding them to releases shouldn't have an impact in performance, but this claim is completely untested
The Express edition of Visual Studio 2010 can't open dmp files. You can use the Express edition of Visual Studio 2008, though.
It can be found here: http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=14597
This small modcomp only contains two hunks of changes to CvGlobals.cpp, clearly labelled with "MINIDUMP_MOD". I'm uploading that file with my changes to this thread.