Êíèãà: Microsoft Windows Embedded CE 6.0 Exam Preparation Kit

? Enable KITL and Use Debug Zones

? Enable KITL and Use Debug Zones

1. Open the OS design project created in Lab 1 in Visual Studio, right-click the OSDesign name and select Properties to edit the OS design properties, select Configuration Properties and then Build Options, and then select the Enable KITL check box for the run-time image.

2. In the OS Design property pages dialog box, also enable the Kernel Debugger feature, apply the changes, and then close the dialog box.

3. Verify that you are currently working in debug build configuration to build an image that contains the KITL and Kernel Debugger components activated in the previous steps.

4. Build the OS design by selecting Rebuild Current BSP and Subprojects under Advanced Build Commands on the Build menu (perform a Clean Sysgen if you encounter errors during subsequent steps).

5. Open the Target menu and click Connectivity Options to display the Target Device Connectivity Options dialog box. Configure the following settings, as shown in Table 4-6 and then click OK.

Table 4-6 Device connectivity settings

Configuration Parameter Setting
Download Device Emulator (DMA)
Transport Device Emulator (DMA)
Debugger KdStub

6. Add a subproject to the OS design and select the WCE Console Application template. Name the project TestDbgZones and select the option A Typical Hello World Application in the CE Subproject Wizard.

7. Add a new header file called DbgZone.h to the subproject and define the following zones:

#include <DBGAPI.H>
#define DEBUGMASK(n) (0x00000001<<n)
#define MASK_INIT    DEBUGMASK(0)
#define MASK_DEINIT  DEBUGMASK(1)
#define MASK_ON      DEBUGMASK(2)
#define MASK_ZONE3   DEBUGMASK(3)
#define MASK_ZONE4   DEBUGMASK(4)
#define MASK_ZONE5   DEBUGMASK(5)
#define MASK_ZONE6   DEBUGMASK(6)
#define MASK_ZONE7   DEBUGMASK(7)
#define MASK_ZONE8   DEBUGMASK(8)
#define MASK_ZONE9   DEBUGMASK(9)
#define MASK_ZONE10  DEBUGMASK(10)
#define MASK_ZONE11  DEBUGMASK(11)
#define MASK_ZONE12  DEBUGMASK(12)
#define MASK_FAILURE DEBUGMASK(13)
#define MASK_WARNING DEBUGMASK(14)
#define MASK_ERROR   DEBUGMASK(15)
#define ZONE_INIT    DEBUGZONE(0)
#define ZONE_DEINIT  DEBUGZONE(1)
#define ZONE_ON      DEBUGZONE(2)
#define ZONE_3       DEBUGZONE(3)
#define ZONE_4       DEBUGZONE(4)
#define ZONE_5       DEBUGZONE(5)
#define ZONE_6       DEBUGZONE(6)
#define ZONE_7       DEBUGZONE(7)
#define ZONE_8       DEBUGZONE(8)
#define ZONE_9       DEBUGZONE(9)
#define ZONE_10      DEBUGZONE(10)
#define ZONE_11      DEBUGZONE(11)
#define ZONE_12      DEBUGZONE(12)
#define ZONE_FAILURE DEBUGZONE(13)
#define ZONE_WARNING DEBUGZONE(14)
#define ZONE_ERROR   DEBUGZONE(15)

8. Add an include statement for the DbgZone.h header file to the TestDbgZones.c file:

#include "DbgZone.h"

9. Define the dpCurSettings variable for the debug zones above the _tmain function, as follows:

DBGPARAM dpCurSettings = {
 TEXT("TestDbgZone"), {
  TEXT("Init"), TEXT("Deinit"), TEXT("On"), TEXT("n/a"),
  TEXT("n/a"), TEXT("n/a"), TEXT("n/a"), TEXT("n/a"),
  TEXT("n/a"), TEXT("n/a"), TEXT("n/a"), TEXT("n/a"),
  TEXT("n/a"), TEXT("Failure"), TEXT("Warning"), TEXT("Error")
 },
 MASK_INIT | MASK_ON | MASK_ERROR
};

10. Register the debug zones of the module in the first line of the _tmain function:

DEBUGREGISTER(NULL);

11. Use the RETAILMSG and DEBUGMSG macros to display debug messages and associate them with debug zones, as follows:

DEBUGMSG(ZONE_INIT,
 (TEXT("Message : ZONE_INIT")));
RETAILMSG(ZONE_FAILURE || ZONE_WARNING,
 (TEXT("Message : ZONE_FAILURE || ZONE_WARNING")));
DEBUGMSG(ZONE_DEINIT && ZONE_ON,
 (TEXT("Message : ZONE_DEINIT && ZONE_ON")));

12. Build the application, attach to the target device, and then start the application by using the Target Control window.

13. Note that only the first debug message is displayed in the debug Output window:

4294890680 PID:3c50002 TID:3c60002 Message : ZONE_INIT

14. Open the registry editor (Regedit.exe) on your development computer to activate the remaining debug zones, by default.

15. Open the HKEY_CURRENT_USERPegasusZones key and create a REG_DWORD value called TestDbgZone (according to the name of the module defined in the dpCurSettings variable).

16. Set the value to 0xFFFF to enable all 16 named zones, which correspond to the lower 16 bits in this 32 bit DWORD value (see Figure 4-15).

17. In Visual Studio, start the application again, and notice the following output:

4294911331 PID:2270006 TID:2280006 Message : ZONE_INIT
4294911336 PID:2270006 TID:2280006 Message : ZONE_FAILURE || ZONE_WARNING
4294911336 PID:2270006 TID:2280006 Message : ZONE_DEINIT && ZONE_ON

18. Change the TestDbgZone value in the registry to enable and disable different debug zones and verify the results in the Output window of Visual Studio.


Figure 4-15 HKEY_CURRENT_USERPegasusZones: "TestDbgZone"=dword:FFFF

NOTE

Enabling and disabling debug zones in Platform Builder

You cannot control the debug zones for the TestDbgZone module in Platform Builder because the application process exits before you can open and modify the active zone for this module. You can only manage debug zones for loaded modules in Platform Builder, such as for graphical applications and DLLs.

Îãëàâëåíèå êíèãè


Ãåíåðàöèÿ: 1.125. Çàïðîñîâ Ê ÁÄ/Cache: 3 / 1
ïîäåëèòüñÿ
Ââåðõ Âíèç