3

I know, roughly, that when statically linking to a .lib from an .exe the code is placed in the .exe (missing some detail of course).

But when getting a stack trace from something like WinDbg, do i need to have a pdb for both the exe AND the lib, or will the pdb for the exe contain the information from the pdb for the lib (in the same way the exe contains the lib)?

I'm asking because in Debug building with MSVC (using CMake) I get pdbs for my .libs, .ddls, .exes but in release I can only get ones for the .dlls and .exes

Cinder Biscuits
  • 4,880
  • 31
  • 51
Cascades
  • 627
  • 7
  • 18
  • If the lib files are statically linked then you will probably want the PDB files. If they are just for the linker and DLL's, then they are pointless and will never be generated, these LIB's are just `ar` archives storing all of the exported function names. – vandench Jan 23 '19 at 14:15
  • EXE's is enough, the pdb entries for the static library are merged into it. As long as you don't use the /DEBUG:FASTLINK linker option. – Hans Passant Jan 23 '19 at 17:15

2 Answers2

1

Check this answer. There are compile options.

If you use /ZI or /Zi (C/C++ -> General -> Debug Information Format), then the vc$(PlatformToolsetVersion).pdb is created, which contains the debug info for all of the .obj files created. If alternately you use /Z7, the debug info will be embedded into the .obj file, and then embedded into the .lib. This is probably the easiest way to distribute the debug info for a static library.

Michael Chourdakis
  • 10,345
  • 3
  • 42
  • 78
1

My company builds releases with debug info enabled,
But embedding the debug info (with /Z7) was not an option for us,
because we don't want to make Reverse-engineering simple.

Hence, we tested manually, like:

  • We created a very small App.
  • Then, built it once as is, to generate App's *.pdb file.
  • And built it another time, but with linking to a huge static library, to generate App's *.pdb again.
  • Where said static library had it's own *.pdb file.
  • At last, we compared the size of *.pdb files.

Conclusion:

The size of the said App's *.pdb file became huge,
meaning, the static library's *.pdb file was embedded.

Either that, or MSVC has huge bugs ;-)

One could go even further, and add an intentional crash to said static-library, to see if *.dmp file's stack-trace can really be converted to file-path and line-number, but above was enough evidence for us.

Top-Master
  • 7,611
  • 5
  • 39
  • 71