none
VS2015 + Win10 application debug problem RRS feed

  • Question

  • Hello! On my test machine I trying to debug native app. Previously, when I compiled it with __debugbreak() and run outside VS, it generated debug exception and I was able to attach debugger (VS itself, e.g.). At now, application complied in vs2015 and running on win10-64 do not generates any debug exception when runs separately, even it still compiled with __debugbreak(), DebugBreak, ... . How I may enable debug exception generation outside VS?

    SNZH

    Thursday, August 20, 2015 10:28 PM

All replies

  • Hi

    If you'll compile it as x64, it will work. If you want to continue use x86, try this:

    #include <Windows.h>
    int main()
    {
    	SetErrorMode(SEM_FAILCRITICALERRORS);
    	__debugbreak();
        return 0;
    }
    
    Alon.


    אלון פליס http://codevalue.net

    • Proposed as answer by Alon FliessMVP Thursday, August 20, 2015 11:40 PM
    Thursday, August 20, 2015 11:14 PM
  • Hi! Debug exception was not generated as in x86, as in x64.

    Tried to add SetErrorMode(SEM_FAILCRITICALERRORS) as in sample above, but also still not working.

    I see your example is for console application (main()), my is win app - starts from WinMain(). Any difference?

    Thanks!


    SNZH

    P.S. project was imported from VS2013. Any options should be changed in project settings?

    • Edited by snzh Friday, August 21, 2015 3:58 AM
    Friday, August 21, 2015 3:33 AM
  • Actually, with Win32 app (not a console) it worked for me even without setting the Error Mode.

    I have uploaded a Video demonstrating it.

     

    It might be something with the setting of your machine. Just try it on a new project, if it is still a problem, you can try to run the application with Process Monitor of SysInternals to see the Registry and file system activities while the program executes the debug break.


    אלון פליס http://codevalue.net

    Friday, August 21, 2015 8:59 PM
  • Thanks!

    I also tried the same on Win10 - just simple project created from scratch. And it not works - no debug excepion generated. The same thing on Win7 + VS2015 works perfectly (I just installed other system with clean Win7 and vs2015). So, as result:

    1. clean Win10 + vs2015 - not working

    2. clean Win7 + ws2015 - works (the same project copied from Win10 machine)

    Seems like it Windows settings problems. Tried to set Win10 in developer mode - nothing changed. Any other settings for debugger I should check?


    SNZH

    Friday, August 21, 2015 10:45 PM
  • It might be a user-mode debugger setting in the registry, or a Windows Error Report settings. Read this.

    What is the behavior of other unhandled exceptions?

    You can also try to connect a WinDbg from another machine and see if WinDbg gets the Breakpoint exception.

    Alon.


    אלון פליס http://codevalue.net

    Friday, August 21, 2015 11:59 PM
  • in registry debugger set in the same way as on Win10, as on Win7 machines:

    [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AeDebug]
    "UserDebuggerHotKey"=dword:00000000
    "Debugger"="\"C:\\Windows\\system32\\vsjitdebugger.exe\" -p %ld -e %ld"

    other exceptions also not works, e.g.:

    int*p = 0;

    *p = 5;

    does not work as well.


    SNZH

    Sunday, August 23, 2015 5:00 AM
  • I checked local security policy - they are the same on both machines, debus is enabled for administrators.

    Under VS itself I may debug my program - breakpoints, __debugbreak() working.


    SNZH

    Sunday, August 23, 2015 5:02 AM
  • I'd look with procmon for werfault.exe, vsjitdebugger.exe, aedebug ...
    Not sure about your notation -

    \"C:\\Windows\\system32\\vsjitdebugger.exe\" -p %ld -e %ld 

    gives on my vista

    57	14:05:45,9418133	WerFault.exe	1140	File System	IRP_MJ_CREATE	C:\"C:\Windows\system32\vsjitdebugger.exe\" -p 3984 -e.exe	NAME INVALID

    Besides, if you rename/remove debugger-key in registry, you get an exception dialog?

    Modifying registry incorrectly may lead to very serious problems - standard warnings apply about registry key settings.
    No warranty
    With kind regards 

    Sunday, August 23, 2015 12:18 PM
  • At moment Win7 machine also stopped to generate debug break when running app separately (in VS under debug all working). Any security policies, credentials I should check?

    On Win10 machine still not working. Once after many-many experiments JIT debug window appeared, but as soon as re-run app again - nothing happened.


    SNZH



    • Edited by snzh Thursday, August 27, 2015 8:55 PM
    Thursday, August 27, 2015 4:31 PM
  • Thanks for Alon, PA and MaybeCompletelyW's help.

    Hi snzh,

    >>when I compiled it with __debugbreak() and run outside VS, it generated debug exception and I was able to attach debugger (VS itself, e.g.).

    Could you share us a simple sample using one drive? So we could really debug this app.

    Do you mean that you run .exe outside the VS IDE which generated an exception? And then it was captured by the VS JIT debugging?

    https://msdn.microsoft.com/en-us/library/5hs4b7a6.aspx?f=255&MSPPError=-2147217396

    Best Regards,

    Jack


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, August 28, 2015 6:51 AM
    Moderator
  • Did you solve the problem?

    Any progress?


    אלון פליס http://codevalue.net

    Saturday, August 29, 2015 11:07 PM
  • Hello!

    Yes - I'm running .exe outside of VS IDE (Win10 + vs2015). Executable compiled with __debugreak(), in debug mode. As test I just created simple project from template (VS->new project->templates->Visual C++->Win32->Win32 Project, SDL disabled) and inserted few __debugbreak() calls in wWinMain() function. Test project was created instead of my original Win32 project - just to simplify all things.

    After compilation (Debug x86 or x64) and running outside VS IDE - JIT not works - no dialog to start debugging.

    The same thing on Win7+vs22015 works fine - as soon as I run app I se dialog and may start debug in VS.


    SNZH

    Sunday, August 30, 2015 7:57 AM
  • Hello!

    No any good update... Checked registry, options in VS IDE - but still not able to start debug if run app outside VS IDE. + see my post above.


    SNZH

    Sunday, August 30, 2015 7:59 AM
  • Hi SNZH,

    Thanks for your reply.

    Since you are running .exe outside of VS IDE (Win10 + vs2015) by the VS JIT debugging, so please you going to Tools->Options->Debugging-> Just-In-Time check if you enable the Just-In-Time debugging to launch the Visual Studio debugger automatically when a program, running outside Visual Studio, encounters a fatal error.

    If you have enable them and then you still get this issue, please try to repair your VS2015 and then check this issue.

    Best Regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, August 31, 2015 5:54 AM
  • Hi Tina-Shi!

    All these options were checked (on both machines - Win7 & Win10). VS2015 repair doesn't help - still not generate debug exception outside VS IDE. On Win7 machine all works ok. Problem happens only on Win10.


    SNZH


    • Edited by snzh Monday, August 31, 2015 4:12 PM
    Monday, August 31, 2015 4:10 PM
  • Hi snzh,

    Whether the user is the admin of this windows 10 machine?

    How about add a new profiler user to this windows, and then log-in and debug it with the new user?

    Please also repair the registry permissions, test it again.

    http://blogs.msdn.com/b/astebner/archive/2006/09/04/solving-setup-errors-by-using-the-subinacl-tool-to-repair-file-and-registry-permissions.aspx

    Best Regards,

    Jack


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, September 1, 2015 2:12 AM
    Moderator
  • Hello,

    Here's what I see in Windows 10:

    When an app is running as GUI app (int WinMain()) then the error reporting dialog will not be shown if an exception occurs while there is no window, for example at the start of the application.  Despite the dialog not being shown, an error report seems to be sent to Microsoft as evidenced by info in:  Control Panel -> Security and Maintenance -> Problem Reports.  I suspect that Microsoft did not want to bother the users with random error reporting dialogs popping up for windowless background processes, but this had the negative side effect of suppressing just in time debugging options.

    Here are the 2 solutions:

    1. WerSetFlags(WER_FAULT_REPORTING_ALWAYS_SHOW_UI);

    To show the WER dialog even if there is no window. I am not a sure if this flag is supported by prior versions of Windows.

    2. WerAddExcludedApplication(L"your-app.exe", FALSE);

    This is can be used by a developer to exclude an app under development from sending error reports. A different dialog will be shown as well and it will be shown even if there is no app window. This api only needs to be called once and there is WerRemoveExcludedApplication to undo this function.


    For a detailed discussion of WER, I recommend "Windows Via C/C++ by Jeffrey Richter"


    • Edited by BogdanZ Tuesday, November 29, 2016 5:37 AM
    Tuesday, November 29, 2016 5:19 AM