6
votes

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?

Module Window

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.

4
mfc code is proprietary AFAIK, I don't think you can. - Luchian Grigore
Where do you want to step into? I just checked with VS2005 and it allows me to step into objcore.cpp which is located for me here: C:\Program Files (x86)\Microsoft Visual Studio 8\VC\atlmfc\src\mfc - marcinj
@marcin_j I updated question with the function. - zar
Also it looks like you are trying to debug MFC application that uses non debug MFC dll, it should end with d - in my case its mfc80ud.dll. Maybe thats the problem. - marcinj
@LuchianGrigore: MFC if proprietary, but the MFC sources are distributed with Visual Studio, and normally (and fortunately) you can step into MFC code. - Jabberwocky

4 Answers

6
votes

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

5
votes

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.

3
votes

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.

1
votes

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

  • C:\Program Files (x86)\Microsoft Visual Studio\2019\ (Edition)\VC\Tools\MSVC\14.27.29110\atlmfc\lib\x86
  • C:\Program Files (x86)\Microsoft Visual Studio\2019\ (Edition)\VC\Tools\MSVC\14.27.29110\atlmfc\lib\x64

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 "Microsoft Symbol Servers" option at "Symbol file locations"

Check next links for more information.

https://docs.microsoft.com/ko-kr/cpp/mfc/mfc-mbcs-dll-add-on

https://support.smartbear.com/testcomplete/docs/app-testing/desktop/visual-c/preparing/mfc-debug-info.html#WindowsSymbolCache

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.