Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debugging a release version of a DLL (with PDB file)

Tags:

If I have a DLL (that was built in release-mode) and the corresponding PDB file, is it possible to debug (step-into) classes/methods contained in that DLL?

If so, what are the required steps/configuration (e.g. where to put the PDB file)?

Edit:

If have the PDB file in the same place as the DLL (in the bin/debug directory of a simple console test application). I can see that the symbols for the DLL are loaded (in the Output window and also in the Modules window), but still I cannot step into the methods of that DLL.

Could this be the result of compiler optimizations (as described by Michael in his answer)?

like image 620
M4N Avatar asked Apr 20 '09 20:04

M4N


People also ask

How do I use PDB files for debugging?

The easiest way to use the PDB file is to let Visual Studio do the heavy lifting - either launch your program with Visual Studio's "Debug" command (F5 by default), or run the program and use the "Attach to Process" item in Visual Studio's Debug menu.

How do I debug DLL files?

Debug from the DLL project Set breakpoints in the DLL project. Right-click the DLL project and choose Set as Startup Project. Make sure the Solutions Configuration field is set to Debug. Press F5, click the green Start arrow, or select Debug > Start Debugging.


2 Answers

The pdb is usually (for me at least) detected if it is next to the dll (like with the intellisense xml files).

Alternatively; you'll need a break point after the module has loaded...

At the break-point, bring up the "Modules" window (Ctrl+D,M - or Debug->Windows->Modules). Right click on your dll "Load symbols from", "Symbol path", etc.

like image 85
Marc Gravell Avatar answered Dec 08 '22 20:12

Marc Gravell


Yes, you can debug release code with a PDB. There are some pitfalls however with debugging optimized code, more info here and here.

Your PDB just needs to be in a place that the debugger can find it - for local debugging same directory as the dll is usually easiest. Otherwise, put it in some place that the debugger can find it, and point the debugger to that place with the symbol path.

like image 26
Michael Avatar answered Dec 08 '22 21:12

Michael