I am wondering what methods people are using for guaranteeing that the source code they are looking at matches the binary they are debugging. I am a single developer managing a fairly large code set and I find that when debugging an application I always want to know for certain that the binary that generated an error exactly matches the code I am looking at. I built a simple application to compare the binaries and wondering if others are using this approach, or use other methods like versioning, etc..
doesn't Visual Studio does this for you?
Whenever you try to load the symbols/source for a binary, VS checks whether the pdb file (which it needs if you want to debug source code and not just assembly) matches the binary. Not sure about the exact mechanism, but it works pretty: VS refuses to load if the pdb does not match and in the same way refuses to set breakpoints in source if the source does not match the binary.
edit: also see Options->Debugging->General: there's an option Require source file to exactly match the original version. When checked, VS will issue a warning when stepping into a source file that does not match the binary exactly.
edit in response to comment: although I don't see a good reason to have ten executables, here's how I do the versioning in my projects; it could be used to do what you ask for.
the AssemblyInfo for each project only contains description, company, ..., and a commented out section containing for example
//VERSION_MAJOR 2
//VERSION_MAJOR 1
(these files are also checked into svn btw)
furthermore there's an AssemblyVersion.cs in each project, containing again some commented out code
//VERSION_BUILD 1223
//VERSION_QFE 10
and also the actual version numbers eg
[assembly: AssemblyFileVersion ( "2.1.1223.10" )]
(these files are not checked into svn, but i have a simple script to generate them after a fresh checkout)
all my projects import a base project with common properties, amongst which a prebuild event that invokes an executable which does the interesting work: it can read and write the VERSION_XXX numbers as well as the AssemblyFileVersion string. The prebuild looks like
<Exec Command="versioner -d$(ProjectDir) -f$(ProjectDir)Properties\AssemblyInfo.cs
" />it reads AssemblyInfo.cs to fetch the main version numbers, reads the AssemblyVersion.cs for the other numbers, sets BUILD to the current svn revision of the main project directory, increments the QFE number and writes back to AssemblyVersion.cs. Incrementing a number is the key to achieving what you'd like: no single build will have the same version, unless you overflow the QFE number.
For C++ I use
#define VERSION_MAJOR 2
etc, which are passed into a resource file that populates a VERSIONINFO section with the numbers.
So in your case, when debugging, you'd look at the version file and compare the number with the binary's version. Apart from that, you'd also have to check that the last modified date of each single source file is not newer than the last modified date of the version file, else you're still not sure.