Tutorial Step 4: Debugging the OS on the Emulator Using the Kernel Debugger

Now that you have downloaded and booted the OS image in the Emulator, you can debug the OS. By default, Platform Builder automatically starts the kernel debugger when the OS boots and displays the Debug toolbar in the IDE.

To debug the platform, you first need to halt the running OS, because breakpoints cannot be set while the OS is still running. You then use the kernel debugger to debug your custom OS.

To debug the OS on the Emulator using the kernel debugger

  1. In the IDE, from the Debug menu, choose Break.

    This halts the running OS on the Emulator, which does not respond to user input while in this state.

  2. From the File menu, choose Open.

  3. Browse to %_WINCEROOT%\Platform\Emulator\Drivers\Kbdmouse\Emulkbms, select ps2mouse.cpp, and then choose Open.

    You have opened the Ps2mouse.cpp file, which contains source code for the mouse driver.

  4. From the Edit menu, choose Find.

  5. In the Find what box, type _move, and then choose Find Next.

    You have jumped to a section of code in the Ps2mouse.cpp file that handles a mouse move event.

  6. Press the F9 key to set a breakpoint in the source code at the mouse move event.

    The red dot in the margin shows that the breakpoint has been set.

  7. From the Debug menu, choose Go.

  8. From the Windows taskbar, choose MYPLAT~1 - Emulator for Windows CE to display the MYPLAT~1 - Emulator for Windows CE window.

  9. Move the cursor over the MYPLAT~1 - Emulator for Windows CE window.

    The breakpoint activates. Switch to the IDE window. A yellow instruction point, or current instruction arrow, on the breakpoint symbol appears in the source code.

  10. From the Edit menu of the IDE, choose Breakpoints.

  11. To remove the breakpoint that you set, choose Remove All, and then choose OK.

  12. From the Debug menu, choose Go.

    You have successfully halted the OS, set and activated a breakpoint in one of the drivers, and then removed the breakpoint. Follow the remaining steps to stop debugging the OS.

  13. From the Debug menu, choose Stop Debugging.

    A dialog box appears, asking whether you want to stop debugging now without disabling the target-side kernel debugger component KdStub.

  14. For the purposes of this tutorial, choose Yes.

    Control returns to the IDE.

  15. From the Target menu, choose Disconnect, and then choose OK.

  16. In the window for the Emulator, from the Emulator menu, choose Shut Down.

  17. In the Shut Down dialog box, select Turn off Emulator, and then choose OK to shut down the Emulator.

After you have finished debugging, you are ready to localize your OS image.

See Also

Tutorial Step 5: Localizing the OS Image for the Emulator | Tutorial Step 3: Setting Up a Connection to the Emulator and Downloading the OS Image | Tutorial: Using Platform Builder with the Emulator | Platform Builder Tutorials | Platform Debugging

 Last updated on Wednesday, April 14, 2004

© 1992-2003 Microsoft Corporation. All rights reserved.