Let’s say we have installed Visual Studio 2015 and have started an MFC application in DEBUG mode. Now, attempting to step into an MFC Framework function, e.g. CWinApp::InitInstance, the debugger simply steps over.
Having a look into Output window, we may discover a message like this: “…’C:\Windows\System32\mfc140ud.dll’. Cannot find or open the PDB file”. That’s clear, the necessary PDB file is missing. What can we do? We can buy one from Microsoft or get a free copy from Torrents site. 🙂 Well, don’t need to do that, I was just joking. We can easily get it from Microsoft Symbol Servers, using Visual Studio. Here are the steps:
Changing Debugging/Symbols options in Visual Studio
- Open the Options dialog (choose Tools/Options… menu item).
- Expand the tree from the left pane to Debugging/Symbols.
- Under Symbol file (.pdb) locations, check Microsoft Symbol Servers. In this moment a message box appears; it suggest that we can choose to get only the debugging symbols for modules which we want, e.g. mfc140ud.dll…
- …so let’s check Only specified modules, then click on Specify modules link and add mfc140ud.dll to the list.
- Type or browse for a folder for caching the symbols, e.g. C:\Symbols . Here is how the debugging symbols options finally looks.
- Hit OK to close the Options dialog.
- The same steps can be applied for Visual Studio 2013, except that it needs the symbols for mfc120ud.dll.
- First time the PDB file is needed it may take a pretty long time for downloading. However, next times it is taken from the cache folder, so symbol loading time becomes irrelevant.
- If have Visual Studio 2015 with at least Update 1, still may not step into the MFC code, even the symbols has been successfully loaded. For this issue see the next topic.
Changing Linker/Debugging project properties
The Update 1 for Visual Studio 2015 comes with /DEBUG:FASTLINK liker option. That’s pretty cool for improving link times but unfortunately, if it’s set, it makes not possible stepping into the MFC Framework code, although the necessary symbols has been loaded. So let’s change it, following these steps:
- Open the project’s Property Pages.
- Choose Debug configuration and All Platforms.
- Expand the tree from left pane to Configuration Properties/Linker/Debugging.
- Change Generate Debug Info option from Optimize for faster linking, (/DEBUG:FASTLINK) to Optimize for debugging (/DEBUG).
- Hit OK to close project’s Property Pages.
- The above option can also be changed for all projects in the Property Manager window.
Resources and related articles
- MSDN: Specify Symbol (.pdb) and Source Files in the Visual Studio Debugger
- Visual C++ Team Blog: /Debug:FASTLINK for VS2015 Update 1