Debug zone debugging in WinCE

Source: Internet
Author: User

 

The Debug Zones function is supported in the development environment of WinCE, which is also called a debugging domain. It can control the printing information. After a debugging domain is opened, the printed information in this domain will be printed. If a debugging domain is closed, the printed information in this domain will be closed. The debugging domain is based on modules. That is to say, a module can be defined in a driver or application to debug the module. A debugging domain can contain a maximum of 16 fields. Generally, each module has a global variable dpCurSettings. This variable is used to describe information about the debugging domain. It consists of a module name, the name of 16 domains and a mask. Example of mask below:

Dbgparam dpcursettings =

{
Text ("pcibus "),{
TEXT ("Errors"), TEXT ("Warnings"), TEXT ("Functions"), TEXT ("Initialization "),
TEXT ("Enumeration"), TEXT ("Load Order"), TEXT ("Resource"), TEXT ("Undefined "),
TEXT ("Undefined "),
TEXT ("Undefined"), TEXT ("Undefined ")},
0x20

};

The DBGPARAM structure is defined in Dbgapi. h. Therefore, this header file must be included when dpCurSettings is defined. The structure is defined as follows:

Typedef struct _ DBGPARAM {

WCHAR lpszName [32]; // Module name

WCHAR rglpszZones [16] [32]; // name of the debugging domain

ULONG ulZoneMask; // The Mask of the debugging domain

} Dbgparam, * lpdbgparam;

 

In the preceding example, we can see that the first module is called pcibus. Then, the names of 16 domains are defined. Only seven domains are used, and the rest are defined as undefined. The last digit is the domain mask, indicating which domain is activated, and 0x20 indicates that only 6th domains are activated. From the above example, we can see that the first seven domains are meaningful and correspond to 1 to 7 in order. The following is a macro definition of DEBUG debugging for these domains:

# Define dbgzone_error 1

# Define dbgzone_warning 2

# Define dbgzone_function 3

# Define DBGZONE_INIT 4

# Define DBGZONE_ENUM 5

# Define DBGZONE_LOADORDER 6

# Define DBGZONE_RESOURCE 7

 

The macro definition corresponds to the seven fields in dpCurSettings, and then you can use these macro definitions to correspond to the corresponding debugging fields when printing information. For example:

  1. While(1)
  2. {
  3. If(DwFlag)
  4. {
  5. DEBUGMSG (DBGZONE_ERROR, (L "Error found: % d \ r \ n", NumDevKeys ));
  6. Break;
  7. }
  8. Else
  9. {
  10. DEBUGMSG (DBGZONE_WARNING, (L "Warning found \ r \ n "));
  11. }
  12. DEBUGMSG (DBGZONE_LOADORDER, (L "load in a while loop \ r \ n "));
  13. Sleep (100 );
  14. }
  15.  

From this code, we can see that if the mask in dpCurSettings is defined as 0x20, only DBGZONE_LOADORDER is printed in DEBUGMSG printing, the first two printed information in the loop will not be printed. To print all DEBUGMSG files in the above Code, you must set the following mask:

Dpcursettings. ulzonemask = dbgzone_error | dbgzone_warning | dbgzone_loadorder;

 

A debugging domain is defined in a module. If you want to use it in the system, you must register the debugging domain. The required function is debugregister (..), pass the handle of the debugging module as a parameter to it. For example:

DllMain (..)

{

Switch (op)

{

Case DLL_PROCESS_ATTACH:

DEBUGREGISTER (hPCIBUS );

Break;

....

}

}

 

After completing the above work, you can re-compile the debugging module and then run the system for debugging. One advantage of the debugging domain is that the debugging domain can be dynamically changed without terminating the system during the debugging process, so that we can analyze the problem easily. First, we can debug it based on ce debug zones in platform. Builder, select target from the menu in vs2005, and then select ce debug zones,

 

Then a debug zones window appears. After the window pops up, it may take some time to collect the modules currently supporting debug zones, such:

 

This figure is just an example. The debug module is displayed on the left. Select serial_smdk2410.dll, which is the serial port driver module of S3c2410. You can view the debugging domains and names on the right. You can select to open and close the corresponding debugging domains as needed, and click Apply and OK.

 

Of course, there are other ways to modify the debugging domain. One way is to use the Zo command in target control to modify it. Target control will be introduced later. Another way is to use the setdbgzone (...) function to modify it. Definition:

BOOL SetDbgZone (DWORDdwProcid, LPVOIDlpvMod, LPVOIDbaseptr, DWORDzone, LPDBGPARAMlpdbgTgt)

Dwprocid: Process Handle

Lpvmod: handle of the debugging Module

Baseptr: Set to null

ZONE: New debug domain mask

Lpdbgtgt: returns the new dbgparam structure.

 

The following describes the definition, use, and debugging of the debug zone. You can add a debugging domain to a module according to the preceding steps, register the debugging domain and change the debugging domain at any time after the system runs. Its fundamental goal is to help us debug modules and analyze problems. Generally, the debugging domain is only used in debug mode, but can also be used in release mode. However, in some cases, you need to modify it. First, debugmsg is used for printing in debug mode, and the retailmsg function is used for printing in release mode. Therefore, in the release mode, the print function should be changed to the retailmsg function. When registering a debugging domain, you cannot use the debugregister (...) function, but instead use the retailregisterzones (...) function.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.