I've had some experience using PDB files in C#, but I wasn't sure if that concept would transfer to C++. Fortunately it does!
PDB (Program Database) files contain:
* public, private, and static function addresses
* Global variable names and addresses
* Parameter and local variable names and offsets where to find them on the stack
* etc
So basically, if you want to debug an application and use fairly sophisticated debug tools like breakpoints, variable watches, etc, you do not actually need the source code, you just need the PDB file that is generated when the file is compiled.
You can load the application into a new project in Visual Studio 2017 (or other IDEs for that matter), then start a new instance of the application with the debugger attached. Visual Studio will automatically search for and load the PDB file associated with the application/library. In this case, I just placed the PDB file next to the executable and Visual Studio automatically found it.
Since OP2Archive is a command line program, I needed to provide arguments before running. This worked just like when debugging normally in Visual Studio. So it was easy to give it the command CREATE test.vol abc.map.
See the image below of the application running in Visual Studio with the debugger attached.
Visual Studio even shows you the source code with line numbers and everything as you step through each function in the program.
Also, apparently since OP2Utility was statically linked, all of the information necessary to step through functions from OP2Utility called from OP2Archive were available for debugging without including a separate PDB file for OP2Utility.
The catch with PDB files is that each PDB file is unique to the compiled file and they are rather large. So, if you have a random PDB file for an application, it doesn't help unless it is the exact right one created on compilation.
For size reference, OP2Archive's release PDB is about 6,300 KB. This compressed down to about 1,400 KB with the standard ZIP algorithm. OP2Archive's debug PDB is about 14,100 KB, or over twice as large as the release PDB. OP2Archive is a small application and I could see how PDB files could quickly spiral into massive sizes for larger compiled files.
I know organizations like Microsoft will automatically create and archive PDB files for each release of their software. This way they can be debugged later as needed even without having to load and compile the source code. Probably important for widely used, operating system critical software.
Of course there is a security risk involved with storing the PDB file as someone could use it and basically just breeze through a thorough review of your source code.
I wonder how often when someone hires a company to create an application or library to fulfill some business need, they actually ask for copies of the PDB files for the final product just in case it needs debugged years later after development.
What a boon it would have been to get a hold of PDB files for Outpost 2's binaries.
I was thinking about placing the OP2Archive and OP2MapImager PDB files next to the executables when releasing them for fun. For such a non-critical application where the source code is public, it probably isn't a big deal, but it is a good habit to be in I think?
Thoughts? I'm done ramblig for now.
-Brett