1

Are there cases when a Windows executable (written in C++ with Visual Studio) can contain its full debug symbols? Or are the full set of debugging symbols contained only in its .pdb file?

Is there a way to configure building a windows application so that we can debug it without having the .pdb file?

djcouchycouch
  • 12,724
  • 13
  • 69
  • 108
  • How you configure building a Windows application depends, unsurprisingly enough, on your build tools. Are you using Microsoft C++ compilers and `link.exe`? .NET compilers such as `csc.exe`? Classic VB? Fortran? Delphi? C++ compilers from another vendor (e.g. Intel or GCC or clang)? There is no magic option recognized by every toolchain. – Ben Voigt Aug 17 '17 at 21:33
  • I've clarified how the application is written. – djcouchycouch Aug 17 '17 at 21:37
  • I guess you've already read https://learn.microsoft.com/en-us/cpp/build/reference/z7-zi-zi-debug-information-format ? – Ben Voigt Aug 17 '17 at 21:41
  • I have not actually. So I guess the answer to my question is yes. – djcouchycouch Aug 17 '17 at 21:43
  • Oh, you can get it into a obj or lib using `/Z7`, but it still won't be embedded in the exe :( – Ben Voigt Aug 17 '17 at 21:47
  • It's not something I was looking to try. I just wanted to know if it was a possibility. – djcouchycouch Aug 17 '17 at 21:47

1 Answers1

1

From the documentation for your toolchain:

The compiler's C7 Compatible (/Z7) option causes the compiler to leave the debugging information in the .obj files. You can also use the Program Database (/Zi) compiler option to store the debugging information in a PDB for the .obj file. The linker looks for the object's PDB first in the absolute path written in the .obj file, and then in the directory that contains the .obj file. You cannot specify an object's PDB file name or location to the linker.

It is not possible to create an .exe or .dll that contains debug information. Debug information is always placed in a .obj or .pdb file.

This doesn't rule out debug information placed into a section of an EXE file by other tools... but Microsoft Visual Studio's C++ tools never do.

For information on placing debug information into OBJ files (possibly contained inside LIB static libraries) instead of a PDB, read the documentation on the compiler option for Debug Information Format

Community
  • 1
  • 1
Ben Voigt
  • 277,958
  • 43
  • 419
  • 720