views:

3693

answers:

6

I've noticed that when generating a new C++ project using MS Visual Studio 2008, the Release build contains debugging symbols - specifically the following settings are enabled:

  • The C++/General/Debug Information Format is set to Program Database.
  • The Linker/Debugging/Generate Debug Info setting is set to Yes.

I have never noticed this on earlier releases of Visual Studio.

So, other than generating a larger EXE file, is there any downside to leaving these settings enabled?

+1  A: 

Well, you might deliver this debug information and someone might use it to disassemble your code. For some fearful people this alone might be a reason not to leave it this way.

Personally, I think sometimes it's helpful to have debug information available for the release version - this way it is far easier to analyse a crashdump, that will be stored by Dr. Watson in case of application crashes.
I did find some really obscure bugs this way.

Sam
+2  A: 

Having these options on do not necessarily make your executables bigger. Debug information is stored in a separate file, with the extension PDB. Having debug information available is never a bad idea, unless you're really really short on free storage space.

Perhaps that's why they're on by default: they don't harm your executables. Release builds do use optimizations such as function inlining and generating optimized code, which makes it harder to step through, while Debug builds have these options turned off.

No downside here.

Dave

Dave Van den Eynde
+17  A: 

We have turned on those settings in our commercial releases for years now with no apparent downside. The upsides are enormous,though.

We have integrated a crash dump packager that packages the dump along with some other information and emails it (with the user's consent) to a company inbox. This has helped us find problems that would have taken us forever to reproduce and find otherwise.

Although it's slightly off topic, here's a link to an excellent contribution someone made that gives you an easy way to include a crash reporter to a C++/Windows app: http://www.codeproject.com/KB/debug/crash_report.aspx

Note: It would be wise, though, not to include the PDB file with your release. That said, you must keep the PDB file that matches your released version so that you can correctly debug the problem in the future. If a PDB file is used that wasn't built with the same code that built the exe, the stack you see when you try to debug the dmp will be wrong.

Karim
A: 

The .exe will be slightly larger due to a reference to the .pdb file (i.e., an extra path). That's about it.

MSN

MSN
+1  A: 

Add the /Zi switch does make a larger .exe file in addition to the PDB. However you can seperately link with /OPT:REF to keep the .exe file size to a minimum.

In Visual Studio 2008, this setting is under "Properties->Linker->Optimisation->References".You might also consider enabling the "Enable COMDAT Folding" which will also reduce binary size.
John
+1  A: 

They're turned on by default because:

  1. If you don't create them now, you can't create them later.
  2. You need them.

Enabling debug info in Visual C++ causes a small entry to be added to the binary header, identifying the PDB for this binary. It's too small to be of any size concern, and doesn't contain any useful secrets that you might be concerned about sharing.

(The header entry is labeled RSDS: who can guess why?)

Of course, those PDBs will use more disk space on your build machine / in your backups. Deal with it. You need those PDBs when it comes time to debug something.

Jay Bazuzi