none
Enable JIT debugging RRS feed

  • Question

  • Hello,

    I am running an obfuscated executable, which is proving a nightmare to debug.
    Anyway, it would be helpful if JIT debugging would work as intended, or if my brain would at least work as intended.

    I have enabled JIT debugging through VS (tools>options etc) which is running it admin mode.
    I have also added the line   <system.windows.forms jitDebugging="true"/> in the <configuration> section of my app.config file.

    Both these solutions still pop up the standard unhandled exception dialog that gives me the stack trace and how to enable JIT debugging.

    I have run the application as admin and still get the same result.

    I have added the   <system.windows.forms jitDebugging="true"/> line to machine.config and the build does not work "configuration system failed to initialize."

    Any thoughts?

    Thanks!
    Thursday, November 26, 2009 2:53 AM

Answers

  • Hi,

    When your app shows you ane exception how do you run it? From VS or as executable. If thru VS there are an option to specify which exceptions should be handled - click "Debug" menu and select "Exceptions...".

    In general the following keys in registry will show message box which will ask you to debug or just close app for any executable(executed not from VS).

    On an x86 computer, the postmortem settings are stored in the \\HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\AeDebug key.

    On an Intel Itanium computer, there are two registry keys used for postmortem debugging:

    1. A failing 64-bit application will be debugged according to the settings stored in the \\HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\AeDebug key.
    2. A failing 32-bit application will be debugged according to the settings stored in the \\HKEY_LOCAL_MACHINE\Software\Wow6432Node\Microsoft\Windows NT\CurrentVersion\AeDebug key. However, if the Debugger value in this key specifies an application in the %windir%\system32 directory, Windows will look in %windir%\syswow64 instead.
    Debugger
    This REG_SZ value specifies the debugger that will handle postmortem debugging. The full path to the debugger must be listed, unless the debugger is located in a directory that is in the default path.
    Auto
    This REG_SZ value is always either 0 or 1. If Auto is set to 0, a message box will be displayed prior to postmortem debugging.

     

    When an unhandled application error occurs, Windows checks to see if the Debugger and Auto registry values exist.

    If the Auto value is 0, a message box will appear.
    If the Auto value equals 1 or does not exist, no message box appears. The debugger referred to in the Debugger value is automatically started.

    e.g on my dev box i have the following in registry \\HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\AeDebug (OS: windows7 x64)
    key: "Debugger" value: "C:\Windows\system32\VSJitDebugger.exe" -p %ld -e %ld 
    Where:  -p %ld specifies the process ID that will be debugged, -e %ld provides the event that caused the exception
    key: "Auto" Value: 0
    So this will automatially show me message to start debugger or not.

    Hope this will help you.


    Regards
    • Edited by democls Thursday, November 26, 2009 11:05 AM Add one more note
    • Marked as answer by eryang Wednesday, December 2, 2009 5:57 AM
    Thursday, November 26, 2009 10:23 AM
  • Simply because this is handled exception :). You running winforms app, correct? So it will be handled by form as result you'll see friendly message box.
    One point - is there are any problem to repro this issue using call stack? Just place break point where you think it required and go... in case if you have sources and this is not production. Or you looking for some advanced debugging topics?
    Regards
    • Marked as answer by eryang Wednesday, December 2, 2009 5:57 AM
    Thursday, November 26, 2009 8:30 PM

All replies

  • Hi,

    When your app shows you ane exception how do you run it? From VS or as executable. If thru VS there are an option to specify which exceptions should be handled - click "Debug" menu and select "Exceptions...".

    In general the following keys in registry will show message box which will ask you to debug or just close app for any executable(executed not from VS).

    On an x86 computer, the postmortem settings are stored in the \\HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\AeDebug key.

    On an Intel Itanium computer, there are two registry keys used for postmortem debugging:

    1. A failing 64-bit application will be debugged according to the settings stored in the \\HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\AeDebug key.
    2. A failing 32-bit application will be debugged according to the settings stored in the \\HKEY_LOCAL_MACHINE\Software\Wow6432Node\Microsoft\Windows NT\CurrentVersion\AeDebug key. However, if the Debugger value in this key specifies an application in the %windir%\system32 directory, Windows will look in %windir%\syswow64 instead.
    Debugger
    This REG_SZ value specifies the debugger that will handle postmortem debugging. The full path to the debugger must be listed, unless the debugger is located in a directory that is in the default path.
    Auto
    This REG_SZ value is always either 0 or 1. If Auto is set to 0, a message box will be displayed prior to postmortem debugging.

     

    When an unhandled application error occurs, Windows checks to see if the Debugger and Auto registry values exist.

    If the Auto value is 0, a message box will appear.
    If the Auto value equals 1 or does not exist, no message box appears. The debugger referred to in the Debugger value is automatically started.

    e.g on my dev box i have the following in registry \\HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\AeDebug (OS: windows7 x64)
    key: "Debugger" value: "C:\Windows\system32\VSJitDebugger.exe" -p %ld -e %ld 
    Where:  -p %ld specifies the process ID that will be debugged, -e %ld provides the event that caused the exception
    key: "Auto" Value: 0
    So this will automatially show me message to start debugger or not.

    Hope this will help you.


    Regards
    • Edited by democls Thursday, November 26, 2009 11:05 AM Add one more note
    • Marked as answer by eryang Wednesday, December 2, 2009 5:57 AM
    Thursday, November 26, 2009 10:23 AM
  • Hi,

    Thanks for that. I am not terribly experienced jumping into the registry, but here goes.

    32-bit, Vista

    My \\HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\AeDebug

    I have
    Key: "Default" Type: "REG_SZ" Data: "(value not set)"
    Key: "Debugger" Type: "REG_SZ" Data: "C:\Windows\system32\VSJitDebugger.exe" -p %ld -e %ld"
    Also a UserDebuggerHotKey
    There is no Auto key. I added one and set the value to 0 (also tried 1). Same result with the executable popping the standard unhandled exception box.

    Within \\HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\AeDebug there is also another folder called "AutoExclusionList" that has
    Key: "(Default)" Type: "REG_SZ" Data:
    Key: "DWM.exe" Type: "REG_DWORD" Data: 0x00000001 (1)

    Anything jump out at you?
    Thursday, November 26, 2009 8:15 PM
  • Simply because this is handled exception :). You running winforms app, correct? So it will be handled by form as result you'll see friendly message box.
    One point - is there are any problem to repro this issue using call stack? Just place break point where you think it required and go... in case if you have sources and this is not production. Or you looking for some advanced debugging topics?
    Regards
    • Marked as answer by eryang Wednesday, December 2, 2009 5:57 AM
    Thursday, November 26, 2009 8:30 PM