Reputation: 12227
I have a new SDI project in VS2010 but I can't step into MFC source. I followed the steps here and it seems like the resource symbols are not loaded for some reasons but it wouldn't load on right click either as described in the most voted answer there.
When I go into debug >> Windows > Modules, that window shows the symbol status column as Cannot find or open the PDB file
. I guess that's the problem but when I right click on any one module (for example mfc100enu.dll) I get another dialog with similar message than can't find symbol file.
What could have gone wrong that it can't find symbol files and how to fix this?
The function I want to step into is LoadFrame
in below in my basic SDI application.
BOOL CMainFrame::LoadFrame(UINT nIDResource, DWORD dwDefaultStyle, CWnd* pParentWnd, CCreateContext* pContext)
{
// base class does the real work
if (!CFrameWndEx::LoadFrame(nIDResource, dwDefaultStyle, pParentWnd, pContext))
{
return FALSE;
}
...
}
Any hints how can I not load them and what might be wrong? Thanks
Update
I was able to get VS2010 to load the symbol files by going to Tools->Options->Debugging->Symbols and select checkbox "Microsoft Symbol Servers" and now Visual Studio loads PDBs automatically. However I still can't step into the function.
Upvotes: 8
Views: 8330
Reputation: 71
I created a cache dir for symbols and loaded them all. The Modules windows told me that the proper PDB loaded OK. But I still couldn not step into MFC. After playing with other solutions, like adding symbols cache and mfc lib directories to symbol locations, linking statically (which worked), it appeared that simply checking
Tools > Options > Debugging -> General -> Enable Just My Code
OFF
did the trick. I tried stepping into CWinAppEx::InitInstance and now I can.
Configuration: MSVS2022 Pro, Windows10, use MFC as a dynamic library.
Upvotes: 1
Reputation: 41
With Visual Studio 2019, I had same issue. I can't step-into MFC base classes with VC debugger. I have solved it with adding Symbol dir. to "Symbol file locations".
Tools > Options > Debugging > Symbols
Additionally, this setting can't solve MBCS - Multi-byte character set project. For multibyte project, you have to use "Microsoft Symbol Server". VS installer does not install required symbol files for you. It means you cannot debug MBCS project without public network to MS.
Check next links for more information.
https://learn.microsoft.com/ko-kr/cpp/mfc/mfc-mbcs-dll-add-on
I think VS2019 installer and installation are too complex. And MS changes it rapidly. They must not continue it before all developer leaves VS platform.
Upvotes: 4
Reputation: 81
Change your mfc library linking mode to static library. In project properties >> Configuration Properties >> General >> Use of MFC
After debugging, you can change back to what you like. Hope this help.
Upvotes: 8
Reputation: 3236
I found that adding the symbol servers didn't solve the problem for me.
What did solve the problem was adding this directory to the list of locations to look for symbols. Not sure why Visual Studio doesn't add this itself.
C:\Windows\Symbols\dll
Upvotes: 7
Reputation: 6118
You need a Visual Studio Professional or above. Then you get the sources and debug symbols for MFC. If that is given, you only need to ensure that the PDBs are located in the symbol path, which should be the case with a proper Visual Studio installation.
Upvotes: 3