KdStub<\/td> <\/tr> <\/table>
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.<\/p>
7. Add a new header file called DbgZone.h to the subproject and define the following zones:<\/p>
#include <\/code> <\/p>
#define DEBUGMASK(n) (0x00000001<<\/code> <\/p>
#define MASK_INIT DEBUGMASK(0)<\/code> <\/p>
#define MASK_DEINIT DEBUGMASK(1)<\/code> <\/p>
#define MASK_ON DEBUGMASK(2)<\/code> <\/p>
#define MASK_ZONE3 DEBUGMASK(3)<\/code> <\/p>
#define MASK_ZONE4 DEBUGMASK(4)<\/code> <\/p>
#define MASK_ZONE5 DEBUGMASK(5)<\/code> <\/p>
#define MASK_ZONE6 DEBUGMASK(6)<\/code> <\/p>
#define MASK_ZONE7 DEBUGMASK(7)<\/code> <\/p>
#define MASK_ZONE8 DEBUGMASK(8)<\/code> <\/p>
#define MASK_ZONE9 DEBUGMASK(9)<\/code> <\/p>
#define MASK_ZONE10 DEBUGMASK(10)<\/code> <\/p>
#define MASK_ZONE11 DEBUGMASK(11)<\/code> <\/p>
#define MASK_ZONE12 DEBUGMASK(12)<\/code> <\/p>
#define MASK_FAILURE DEBUGMASK(13)<\/code> <\/p>
#define MASK_WARNING DEBUGMASK(14)<\/code> <\/p>
#define MASK_ERROR DEBUGMASK(15)<\/code> <\/p>
#define ZONE_INIT DEBUGZONE(0)<\/code> <\/p>
#define ZONE_DEINIT DEBUGZONE(1)<\/code> <\/p>
#define ZONE_ON DEBUGZONE(2)<\/code> <\/p>
#define ZONE_3 DEBUGZONE(3)<\/code> <\/p>
#define ZONE_4 DEBUGZONE(4)<\/code> <\/p>
#define ZONE_5 DEBUGZONE(5)<\/code> <\/p>
#define ZONE_6 DEBUGZONE(6)<\/code> <\/p>
#define ZONE_7 DEBUGZONE(7)<\/code> <\/p>
#define ZONE_8 DEBUGZONE(8)<\/code> <\/p>
#define ZONE_9 DEBUGZONE(9)<\/code> <\/p>
#define ZONE_10 DEBUGZONE(10)<\/code> <\/p>
#define ZONE_11 DEBUGZONE(11)<\/code> <\/p>
#define ZONE_12 DEBUGZONE(12)<\/code> <\/p>
#define ZONE_FAILURE DEBUGZONE(13)<\/code> <\/p>
#define ZONE_WARNING DEBUGZONE(14)<\/code> <\/p>
#define ZONE_ERROR DEBUGZONE(15)<\/code> <\/p>
8. Add an include statement for the DbgZone.h header file to the TestDbgZones.c file:<\/p>
#include "DbgZone.h"<\/code> <\/p>
9. Define the dpCurSettings variable for the debug zones above the _tmain function, as follows:<\/p>
DBGPARAM dpCurSettings = {<\/code> <\/p>
TEXT("TestDbgZone"), {<\/code> <\/p>
TEXT("Init"), TEXT("Deinit"), TEXT("On"), TEXT("n/a"),<\/code> <\/p>
TEXT("n/a"), TEXT("n/a"), TEXT("n/a"), TEXT("n/a"),<\/code> <\/p>
TEXT("n/a"), TEXT("n/a"), TEXT("n/a"), TEXT("n/a"),<\/code> <\/p>
TEXT("n/a"), TEXT("Failure"), TEXT("Warning"), TEXT("Error")<\/code> <\/p>
},<\/code> <\/p>
MASK_INIT | MASK_ON | MASK_ERROR<\/code> <\/p>
};<\/code> <\/p>
10. Register the debug zones of the module in the first line of the _tmain function:<\/p>
DEBUGREGISTER(NULL);<\/code> <\/p>
11. Use the RETAILMSG and DEBUGMSG macros to display debug messages and associate them with debug zones, as follows:<\/p>
DEBUGMSG(ZONE_INIT,<\/code> <\/p>
(TEXT("Message : ZONE_INIT")));<\/code> <\/p>
RETAILMSG(ZONE_FAILURE || ZONE_WARNING,<\/code> <\/p>
(TEXT("Message : ZONE_FAILURE || ZONE_WARNING")));<\/code> <\/p>
DEBUGMSG(ZONE_DEINIT && ZONE_ON,<\/code> <\/p>
(TEXT("Message : ZONE_DEINIT && ZONE_ON")));<\/code> <\/p>
12. Build the application, attach to the target device, and then start the application by using the Target Control window.<\/p>
13. Note that only the first debug message is displayed in the debug Output window:<\/p>
4294890680 PID:3c50002 TID:3c60002 Message : ZONE_INIT<\/code> <\/p>
14. Open the registry editor (Regedit.exe) on your development computer to activate the remaining debug zones, by default.<\/p>
15. Open the HKEY_CURRENT_USER\Pegasus\Zones key and create a REG_DWORD value called TestDbgZone (according to the name of the module defined in the dpCurSettings variable).<\/p>
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).<\/p>
17. In Visual Studio, start the application again, and notice the following output:<\/p>
4294911331 PID:2270006 TID:2280006 Message : ZONE_INIT<\/code> <\/p>
4294911336 PID:2270006 TID:2280006 Message : ZONE_FAILURE || ZONE_WARNING<\/code> <\/p>
4294911336 PID:2270006 TID:2280006 Message : ZONE_DEINIT && ZONE_ON<\/code> <\/p>
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.<\/p> NOTE<\/div>
Enabling and disabling debug zones in Platform Builder<\/div>
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.<\/p> <\/cite>
|