Compartilhar via


Registering Debug Zones

Windows Mobile SupportedWindows Embedded CE Supported

9/8/2008

Registro zona depuração envolve a configuração inicial depuração zonas na Registro e registrar zonas com macros registro.

Para obter mais informações sobre configuração depuração zonas, consulte Setting Initial Debug Zones.

Registrando zonas com macros de registro

Após declarar a estrutura Setting Debug Zone Parameters, chamar o apropriado macro registro para registrar a estrutura com a depuração subsistema.

DEBUGREGISTER Registra as zonas depuração nas configurações de depuração, e RETAILREGISTERZONES Registradores zonas depuração nas configurações de versão.

É a sintaxe para macros de registro

DEBUGREGISTER(hMod | NULL). 
RETAILREGISTERZONES(hMod | NULL). 

Se você estiver depuração um arquivo .dll, chamar a macro registro com o nome de módulo.

Se você estiver depuração um arquivo .exe, chamar a macro registro com NULL.

Para obter mais informações, consulte Controlling Debug Message Output With Macros.

Example

No seguinte exemplo de código, cabeçalho arquivo do aplicativo inclui um ifdef-pessoa-endif bloco condicional para definir para as configurações tanto de versão e de depuração. Esse bloco associa as zonas depuração definido anteriormente seus correspondente nomes macro para ser usado com o DEBUGMSG macro condicional em codificar de origem.

#ifdef DEBUG
// These macros are used as the first arg to DEBUGMSG.
  #define ZONE_INIT       DEBUGZONE(ZONEID_INIT)
  #define ZONE_SECOND     DEBUGZONE(ZONEID_SECOND)
  #define ZONE_EXCEPT     DEBUGZONE(ZONEID_EXCEPT)
  .
  #define ZONE_ERROR      DEBUGZONE(ZONEID_ERROR)
#else
  // For release configurations, these conditionals are always 0.
  #define ZONE_INIT       0
  #define ZONE_SECOND     0
  #define ZONE_EXCEPT     0
  .
  #define ZONE_ERROR      0

#endif
//
// The following code example shows how to register the DBGPARAM structure 
// and define the DEBUGMSG and RETAILMSG macros:
//
// First, register with the debug subsystem.  For a process, the 
// parameter is NULL.  For a DLL, the parameter is hModule.
DEBUGREGISTER(NULL);

// This message shows up in debug configurations only, if ZONE_INIT is turned on.
DEBUGMSG (ZONE_INIT, (TEXT("DBGSAMP1 starting 1\n")));

// This message shows up in both debug and release configurations.
RETAILMSG(1, (TEXT("DBGSAMP1 starting 2\n")));

O seguinte exemplo de código mostra outro exemplo de usar zonas depuração.

// Declare a DBGPARAM structure and give names to all used zones.
DBGPARAM dpCurSettings = { L"foodll", {
  L"Info",      L"Validate",    L"bar",      L"random",
  L"Undefined",  L"Undefined",  L"Undefined",  L"Undefined",
  L"Undefined",  L"Undefined",  L"Undefined",  L"Undefined",
  L"Undefined",  L"Undefined",  L"Undefined",  L"Undefined" },
  0x00000000 };

// Associate bits with a zone. These should correlate 
// to the order of the text strings (zone names) above.
#define ZONE_INFO    DEBUGZONE(0)
#define ZONE_VALIDATE  DEBUGZONE(1)
#define ZONE_BAR      DEBUGZONE(2)
#define ZONE_RANDOM    DEBUGZONE(3)

// Register : Assume that this is a DLL.
// A process would do the same in its libmain.
BOOL DllEntry (HANDLE hinstDLL, DWORD fdwReason, LPVOID lpv) {
  if ( fdwReason == DLL_PROCESS_ATTACH ) {
    DEBUGREGISTER(hinstDLL);
  }
...
}

// Use the defined zone in debug messages.
DEBUGMSG (ZONE_INFO, (TEXT("This is a sample message.")));

// or use a zone as a Boolean operator to turn execution of some code on and off.
if (ZONE_VALIDATE) {
  // validate data ...

See Also

Concepts

Application Debugging with the Kernel Debugger