none
Debug MFC CSpinButtonCtrl functions

    Question

  • This is for VS 2017 Community Update 15.5.2 under Windows 7 Pro SP1

    I have MFC Dialog-based App using CSpinButtonCtrl class. Symbols for MFC are downloaded. 'Just My Code' in debug settings is unchecked.

    As it is known, most member functions of CSpinButtonCtrl are just call SendMessage Windows functions. In debug session F11 just goes over say, SetBuddy(), to the next code line.  But it is obvious that some code is executing.

    Is there some C++ code, or it is only assembler instructions? And if the C++ code exist, how to see in debugger? 

    Monday, January 1, 2018 12:53 AM

Answers

  • 1.There is no difference between check/uncheck 'Require source files...'

    2.The path to cache is C:\Users\Owner\AppData\Local\Temp\SymbolCache

    3. I did as you  recommended, hit the button 'Load all symbols', changed the 'Linker\Debug' to Debug Full and rebuild the solution. Now I can step inside MFC functions.

    Thank you for your help.

    • Marked as answer by Geoyar Thursday, January 4, 2018 10:37 PM
    Thursday, January 4, 2018 10:37 PM

All replies

  • Hi Geoyar,

    To really repro this issue, would you please provide a simple sample using one drive(please move any personal information in your sample)? So we could setup the same Environment as yours and download your sample, debug it in our side. 

    Please also share the screen shot about the result/steps in your side.

    Sincerely,

    Jack


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, January 1, 2018 2:56 AM
    Moderator
  • Are you configured as in symbols - Visual C++ 2010 cannot Step Into MFC source - Stack Overflow? Since you are using VS 2017 and that was written for VS 2010 some of it will be different and I hope you can figure out what is different.

    There are very many other threads that might be relevant; you can search for them if necessary.



    Sam Hobbs
    SimpleSamples.Info

    Monday, January 1, 2018 10:05 AM
  • Thanks for reply.

    I do not exactly understand what do you need. I can send you a zip of whole simple project, MFC Dialog-based, that has CSpinButtonCtrl functions SetRange and SetPos in OnInitDialog. I also can send you  .sln and project files.

    You also can start your own MFC Dialog-based project with the CSpinButtonCtrl control in the dialog box and try to get inside SetRange or SetPos or any other spin control function and tell me what symbols I need to download and what options in Tools\Options\Debugging  check/unchech if you will succeed.My sample project is generated by VS 2017 Community the standard way, nothing special.

    I think itiis is a general question that does with settings in Tools\Options\Degugging and sympols of MFC pdb file, not with something special in my project.

    Monday, January 1, 2018 11:29 PM
  • Thank you for replay.

    This is VS 2017 MFC project, not VS 2010, and yes, I cannot Step Into MFC source, this time for CSpinButtonCtrl. I can open CSpinButtonCtrl class declaration (.h file) but cannot step into its functions when debugging.

    Monday, January 1, 2018 11:39 PM
  • It has been a while since I have done much with MFC. Oh, well a few months ago I needed to write a MFC program to do something that does not work with .Net. So I ended up making major improvements in my Creating an MFC Application Without the AppWizard article.

    Today I generated a MFC dialog-based application. For some reason I had to add 3 MFC #includes and I sure don't understand why because I changed nothing in the generated project yet I had to add the #includes.

    When I got the application built I placed breakpoints on CDialog::OnInitDialog(); and on m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);

    When I did a "Step Into (F11)" on each of those it took me to the MFC code. I don't remember doing anything special for MFC debugging. So I assume the problem is unique to you. Do you have the problem if you create a new project?



    Sam Hobbs
    SimpleSamples.Info


    Tuesday, January 2, 2018 2:38 AM
  • Thanks for replay.

    First of all, in VS 2017 in project templates for Visual C++ there is MFC app template, and Windows template. I used MFC app template.

    No additional MFC headers were needed.

    And in debug, I was not able to step into CDialog::OnInitDialg() function.

    Would so kind to say what Debugging options were set on Tools\Options\Debugging? Because O think the problem is ther.

    Tuesday, January 2, 2018 3:03 AM
  • For MFC applications you should use the MFC Applications template as in the following.

    Don't use the "Windows Desktop" templates for MFC applications unless you know what you are doing and know you need to use the Windows Desktop templates.

    The following are my debug options; there are so many that I am showing two windows of them.

    If that does not solve the problem then please tell me if you have the problem if you create a new project.



    Sam Hobbs
    SimpleSamples.Info

    Tuesday, January 2, 2018 3:21 AM
  • Tuesday, January 2, 2018 7:32 PM
  • Yes, the source code for MFC is installed.

    For example, I found the function CDialog::DoModal source code, but could not step into this function in InitInstance.

    Should I explicitly set the source directories for MFC code?

    In my project VC directories there is no explicit mention of MFC and other standard VC++ source code.

    The project uses MFC in forme DLL.

    Wednesday, January 3, 2018 3:28 AM
  • Thank for replay.

    I did exactly how you said.

    I check my VC++ directories and found MFC source files. So it is either VS cannot find these directories or some in debugging settings does not allow it to display MFC cpp files.

    Wednesday, January 3, 2018 3:48 AM
  • You already verified, loaded symbol file (Debug->Windows->Modules ) has a file-size, which would indicate it is a 'private' one (lineinfo included) e.g. current mfc140ud.i386.pdb is ~ 36,3 MB?

    Also would make sure, Project 'Property Pages' 'Source Directories' point to the correct paths:

      
    Eg. on my box $(VC_SourcePath) expands to (in fact it's a semicolon-delimited list): 
    C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.12.25827\atlmfc\src\mfc
    C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.12.25827\atlmfc\src\mfcm
    C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.12.25827\atlmfc\src\atl
    C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.12.25827\crt\src
    C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\VS\src
    C:\Program Files (x86)\Windows Kits\10\Source\10.0.16299.0\ucrt

    With kind regards
    Wednesday, January 3, 2018 7:13 PM
  • Thank you very much for your replay.

    First of all, I have started bare-boned dialog-based MFC application under VS 13 Ultimate, VS 15 Community and VS 17 Community 15.5.2.

    Under VS 13 I was able to step into CDilogEx::OnInitDialog. Under both Community editions  I had no luck.

    More to it: if I have imported the project from VS 13 into VS 15, it worked as it did in VS 13, allowed the entry into OnInitDialog. Import into VS17 with converting to platform v. 141 did not allowed  this step into.

    Now there are the project setting (project properties) in VS 2017 Community 15.5.2:

    VC++ source directories: $(VC_SourcePath)

    VC_SourcePath includes first three directories  like in yours VC_SourcePath: src\mfc, src\mfcm, and src\atl.

    All these directories contain valid files (read-only) , and I can open them in VS 2017 Editor, The only thing is they do not allow breakpoints.

    In general settings I have Platform toolset VS 2017(v.141).

    In Tools\Options\Debugging 'Just my code is unchecked.

    Debugging genetal settings are the same as in VS 13.

    What is interesting, I am able to step into C++ containers, e.g vectors, but not into MFC.

    Were you able to step into MFC function in your app in VS2017 Community?

    I do not see what is wrong in my debug settings.


    • Edited by Geoyar Thursday, January 4, 2018 3:41 AM
    Thursday, January 4, 2018 3:36 AM
  • What is interesting, I am able to step into C++ containers, e.g vectors, but not into MFC.

    Nearly all of the C++ standard classes that we #include are compiled along with the source code. The pre-processor would combine all that source code so it would all be the same when the compiler gets all of it.



    Sam Hobbs
    SimpleSamples.Info


    Thursday, January 4, 2018 4:06 AM
  • Were you able to step into MFC function in your app in VS2017 Community? 

    Cannot complain.

    Though very sporadically, e.g. when changing 'Windows SDK version' and 'Linker->Debugging->Generate Debug Info' is set to, lets say,
    'Generate Debug Information (/Debug)'
    stepping into fails.
    A mere 'Rebuild Solution' or changing value to 'Generate Debug Information optimized for sharing and publishing (/DEBUG:FULL)' will do the trick. It's a little bit mysterious.

    Also:
    Is there any difference, when you uncheck 'Require source files to exactly match the original version' in debugging-options?
    Can you rename respective pdb in your local symbol cache to trigger a new download from ms-symbol-server?
    Can you post path of loaded mfc pdb?

    With kind regards

    Thursday, January 4, 2018 11:09 AM
  • 1.There is no difference between check/uncheck 'Require source files...'

    2.The path to cache is C:\Users\Owner\AppData\Local\Temp\SymbolCache

    3. I did as you  recommended, hit the button 'Load all symbols', changed the 'Linker\Debug' to Debug Full and rebuild the solution. Now I can step inside MFC functions.

    Thank you for your help.

    • Marked as answer by Geoyar Thursday, January 4, 2018 10:37 PM
    Thursday, January 4, 2018 10:37 PM
  • In addition to my replay I want to say that upon start or restart of IDE  my app it again refuses to go inside MFC functions. Only rebuilding the project returns it the ability to go inside MFC functions. Upon rebuilding there are no new download of pdb files. The Linker is set to Debug Full.
    Friday, January 5, 2018 2:05 AM