Debugging an Application

Like Visual C++, the toolkit provides an integrated debugger to help locate bugs in a Windows CE executable application, DLL, or Active X control. The debugger interface provides special menus, windows, dialog boxes, and spreadsheet fields to help you locate errors in the code and in application components.

You can debug an application in either an emulated or a remote Windows CE environment. Because you do not need to download your application to debug it in emulation, it usually is more efficient to conduct your initial debugging in emulation. Also, because the toolkit does not need to communicate with the device during emulation, a debugging session generally runs faster in emulation than it does on a remote device.

Under emulation, the Windows CE debugging process is similar to the Visual C++ debugging process. However, one key difference exists between the two debugging processes: Windows CE, unlike Visual C++, copies the application to the object store during the build process and executes the application in a simulated Windows CE environment on your desktop.

After you test the application in emulation, you can debug the application on a remote device. The remote debugging model varies, depending on the connection between the remote device and the desktop computer. The toolkit builds all binaries on the desktop computer and then downloads the binaries to the remote device.

    To prepare to debug an application on a remote device

  1. Verify that the remote device is properly connected to the desktop computer.
  2. Choose either Set Active Configuration or Configurations on the Build menu, and then select the Debug option for your target platform. If your workspace contains both EXE and DLL projects, select EXE as the active project when debugging.

    – Or –

    Use the Configuration toolbar to select the debug option for your target platform. For information on using the Configuration toolbar, see Customizing an Application for a Specific Platform.

  3. Choose Update Remote Output File on the Build menu to load your application onto the remote device.
  4. Choose Rebuild All on the Visual Studio Build menu. The toolkit automatically downloads your application to the device.

    To debug on a remote device

  1. Choose Start Debug on the Build menu.
  2. Choose Step Into if you want the debugger to stop at the WinMain entry point. Use this option if you have not set a breakpoint in your executable file.

    – Or –

    Choose Go if you want the debugger to stop only at soft or hard breakpoints.

    The toolkit loads the debug system onto the remote device, and the debugger runs until it hits a breakpoint, at which point the integrated debugger can control the debug session.

  3. Perform any necessary debugging procedures, such as stepping into a function.

Windows CE does not enable the debugger to end a process in certain states. For example, for single-threaded applications Windows CE can not suspend a thread engaged in a system call. If you select Break on the Debug menu and the process is in one of these states, an error message box appears. You can always safely end a debugging session by selecting Stop Debugging from the Debug menu.

You can enable and disable breakpoints while the debugger is running. The procedure is the same if you set the breakpoints before debugging. Use the hand icon to set or remove a breakpoint where the cursor is positioned or select Breakpoints on the Edit menu, and specify the line number, function name, or condition.

When you debug an MFC application, the toolkit asks for the location of Mfcce20d.dll. Select Browse and point the debugger to the Mfcce20d.dll file on the desktop computer. Point the debugger at the same version of Mfcce20d.dll that the toolkit downloaded to the device. You then will be able to debug the MFC application.