How to load symbols in Visual Studio 2012
Asked Answered
M

1

23

When I am debugging my app I see messages:

cannot find or open the PDB file

I seem to remember being able to specify the location of the PDB file while debugging the app. How can I do this? I'm using Visual Studio 2012.

Marbut answered 13/7, 2013 at 21:11 Comment(3)
OK , I figure out how : Debug - Windows - Modules and then right click on the dll to load the pdb . Problem now is that it tells me "A matching symbol was not found in this folder." Even though the pdb and dll names match .Marbut
I added the pdb files to the same directory as the dlls and then they were loaded successfully .Marbut
You should answer your question instead of commenting on it. Thanks alot.Deciare
H
19
Adding Symbols Location

Open Settings: Tools -> Options -> Debugging -> Symbols and add directory, where your .PDB files are located.

screenshot of Visual Studio Interface where this menu located

You can add custom path, like for each project, and also you can edit common path, where Visual Studio will save all .pdb cache.

Making post-build script

I made in each project post-compile event, which copy all .pdb to one folder, by this i have all in one place. But you can store it separately, which i found not so convenient, as it require each time edit list of locations.

Example of post-debug script to copy .pdb and .dll to Symbols cache location:

xcopy /Y /R "$(TargetDir)$(ProjectName).pdb" "D:\VS_CACHE\"
xcopy /Y /R "$(TargetDir)$(ProjectName).dll" "D:\VS_CACHE\"
Solving problem if symbols not found

When you in debug mode, and for some reason symbols not found, it can be because of multiple reasons:

  1. You have .pdb in Symbols cache, but it's outdated (you can get if this a case, if you put breakpoint in code and hover it)
  2. You have multiple .dll which use this part of code (you can get if this a case, if you put breakpoint in code and hover it)
  3. Symbols not loaded, in this case you can check it by going to: Debug-> Windows -> Modules and trying to load needed module.

screenshot of Visual Studio interface Modules -> Load Symbols

Making Debugging more easy:

To re-attach VS Debugger to running application, i recommend to use this free Visual Studio add-on (support VS 2015):

ReAttach: visualstudiogallery.msdn.microsoft.com/8cccc206-b9de-42ef-8f5a-160ad0f017ae

It will save you a lot of time! :)

Homeomorphism answered 22/5, 2016 at 20:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.