Suppressing Exception Notifications while Debugging (Windows CE 5.0)

Send Feedback

To make your code run smoothly past a known exception process, such as when stress testing, you can suppress exception notifications while debugging.

Under normal circumstances, the OS notifies the kernel debugger when an exception is raised, either by hardware or by a call to RaiseException. By default, the kernel debugger suspends the entire system when this occurs, even if the exception would be handled, such as via a try-except statement.

You can prevent the system from notifying the kernel debugger about these handled exceptions on a per-thread basis. This is useful under circumstances such as stress testing, because you can make your code run smoothly past a known exception process.

To control how what the system does when an exception that is going to be handled occurs, set flags in the thread local storage slot dedicated to the kernel, TLSSLOT_KERNEL.

For more information about thread local storage, see Storing Thread-specific Data with Thread Local Storage.

You can set the following fault filtering flags:

  • TLSKERN_NOFAULT notifies the kernel not to call the debugger in the event of a fault.
  • TLSKERN_NOFAULTMSG prevents an exception message from being displayed in the debug output.

The following example code shows how you can use fault filtering to affect debugger behavior.

#define DISABLEFAULTS()   (UTlsPtr () [TLSSLOT_KERNEL] |= (TLSKERN_NOFAULTMSG | TLSKERN_NOFAULT))
#define ENABLEFAULTS()     (UTlsPtr () [TLSSLOT_KERNEL] &= ~(TLSKERN_NOFAULTMSG | TLSKERN_NOFAULT))

DISABLEFAULTS();
        __try
        {
          // Code that can generate an exception, but
          // You do not want the debugger notified
           bDataOut = *((BYTE *)pAddr);
        }
        __except (EXCEPTION_EXECUTE_HANDLER)
       {
           // Code to handle the exception...
           ++ dwExceptionCount;
        }
      // Re-enable hitting exceptions in the debugger
       ENABLEFAULTS();

See Also

Exception-Handler Syntax

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.