D:/WDK/work/SerialBus/driver/debug.h File Reference

Driver Debug file. More...


Defines

#define DriverDbgPrint(_level_, _module_, _format_)
 Print message to Debuger.
#define DriverDbgEnterFunc(_module_)
 Print name of function.
#define DriverDbgLeaveFunc(_module_)
 Print name of function.
#define DriverDbgLeaveFuncWithStatus(_module_, _status_)
 Print name of function and leave status.
#define DriverDbgPrintIrpName(_module_, _Irp_)
 Print Irp name.
#define DriverDbgPrintIrp(_module_, _Irp_)
 Print Irp details.
#define DriverDbgError(_format_)
 Print Debug error message.
#define DriverDbgWarn(_format_)
 Print Debug warining message.
#define DriverDbgInfo(_format_)
 Print Debug info message.
#define DriverDbgTrace(_module_, _format_)
 Print Debug trace message.
#define DriverInfo()
 Print Driver information.
#define DriverDbg(_format_)
 Print debug message.

Functions

VOID DriverDbgDumpData (PCHAR Buffer, ULONG BufferSize)
 Send data dump to kernel debuger.
VOID DriverDbgTest (VOID)
 Internal function that tests DriverDbg module.
VOID DriverDbgSetDebugMask (ULONG NewDebugMask)
 Set Debug Mask.

Variables

ULONG DebugMask
 Debug mask.


Detailed Description

Driver Debug file.


Define Documentation

#define DriverDbg ( _format_   ) 

Value:

do { \
      DbgPrint("[%s]: ", (DRIVER_NAME)); \
      DbgPrint _format_; \
  }while(0)
Print debug message.

This macro print driver name and debug message.

Parameters:
_format_ format of message eg. ("something %d\n", data)

#define DriverDbgEnterFunc ( _module_   ) 

Value:

do { \
      DriverDbgPrint(DBGLVLTRACE, \
                  (_module_), \
                  ( "[%s]: %s begin\n", (DRIVER_NAME), (__FUNCTION__) ) ); \
  } while(0)
Print name of function.

You can use this macro in begining of all function. With a correct DebugMask you will have trace of all called fuctions. Useful with DriverDbgLeaveFunc and DriverDbgLeaveFuncWithStatus.

Parameters:
_module_ debug module
Returns:
VOID
See also:
DebugMask, DriverDbgPrint, DriverDbgSetDebugMask, DriverDbgLeaveFunc, DriverDbgLeaveFuncWithStatus

#define DriverDbgError ( _format_   ) 

Value:

do { \
      DriverDbgPrint(DBGLVLERROR, \
                     DBGALLMODULES, \
                    ("[%s] file: %s, line: %d error -> ", (DRIVER_NAME), (__FILE__), (__LINE__)));\
      DriverDbgPrint(DBGLVLERROR, DBGALLMODULES, _format_); \
  }while(0)
Print Debug error message.

This macro print error message, when DebugMask is set to DBGLVLERROR, in all modules.

Parameters:
_format_ message format eg. ("some data %d\n", data)
See also:
DebugMask, DriverDbgSetDebugMask

#define DriverDbgInfo ( _format_   ) 

Value:

do { \
      DriverDbgPrint(DBGLVLINFO, \
                     DBGALLMODULES, \
                     ("[%s] ", (DRIVER_NAME))); \
      DriverDbgPrint(DBGLVLINFO, \
                     DBGALLMODULES, \
                     (_format_)); \
  }while(0)
Print Debug info message.

This macro print info message, when DebugMask is set to DBGLVLINFO, in all modules.

/param _format_ message format eg. ("some data %d\n", data) /see DebugMask, DriverDbgSetDebugMask

#define DriverDbgLeaveFunc ( _module_   ) 

Value:

do { \
      DriverDbgPrint(DBGLVLTRACE, \
                  (_module_), \
                  ( "[%s]: %s end\n\n", (DRIVER_NAME), (__FUNCTION__) ) ); \
  } while(0)
Print name of function.

This macro is useful with DriverDbgEnterFunc

Parameters:
_module_ debug module
See also:
DriverDbgEnterFunc, DriverDbgLeaveFuncWithStatus, DebugMask, DriverDbgPrint, DriverDbgSetDebugMask

#define DriverDbgLeaveFuncWithStatus ( _module_,
_status_   ) 

Value:

do { \
      DriverDbgPrint(DBGLVLTRACE, \
                     (_module_), \
                     ("[%s]: %s end (%s)\n\n", (DRIVER_NAME), \
                                                          (__FUNCTION__), \
                                                          OsrNTStatusToString( (_status_) )));\
  }while(0)
Print name of function and leave status.

This macro is useful with DriverDbgEnterFunc

Parameters:
_module_ debug module
_status_ leave status (NTSTATUS)
See also:
DriverDbgEnterFunc, DriverDbgLeaveFunc, DebugMask

#define DriverDbgPrint ( _level_,
_module_,
_format_   ) 

Value:

do { \
      if( ( (_level_) <= (DebugMask & 0xFFFF) )  && ( (_module_) & DebugMask ) ) \
      { \
          DbgPrint _format_; \
      } \
  } while(0)
Print message to Debuger.

This fuction check level, module with DebugMask value, and next send message to Debuger.

Parameters:
_level_ debug level, can be DBGLVLERROR, DBGLVLWARN, DBGLVLINFO, DBGLVLTRACE This value is compared with DebugMask
_module_ debug module, can be DBGMSKMAIN, DBGMSKPNP, DBGMSKPOWER ...
_format_ format of message that we want send to Debuger eg. ("%d some problems", DebugMask)
Returns:
VOID
See also:
DebugMask

#define DriverDbgPrintIrp ( _module_,
_Irp_   ) 

Value:

do { \
      PIO_STACK_LOCATION _pIoStack_ = (_Irp_)->Tail.Overlay.CurrentStackLocation; \
      DriverDbgPrint(DBGLVLTRACE, (_module_), ("    StackCount=%d\n    CurrentLocation=%d\n", \
                                                (_Irp_)->StackCount, \
                                                (_Irp_)->CurrentLocation)); \
      DriverDbgPrint(DBGLVLTRACE, (_module_), ("    DeviceObject: 0x%X\n    FileObject: 0x%X\n", \
                                                (_pIoStack_)->DeviceObject, \
                                                (_pIoStack_)->FileObject)); \
  } while(0)
Print Irp details.

This macro prints Irp details, like StackCount, CurrentLocation, address of DeviceObject and FileObject connected with this IRP.

Parameters:
_module_ debug module
_Irp_ pointer to IRP that we want inspect
See also:
DriverDbgPrintIrpName

#define DriverDbgPrintIrpName ( _module_,
_Irp_   ) 

Value:

do { \
      PIO_STACK_LOCATION _pIoStack_ = (_Irp_)->Tail.Overlay.CurrentStackLocation; \
      DriverDbgPrint(DBGLVLTRACE, (_module_), ("[%s]: Major: %s, Minor: %s\n", \
                                               (DRIVER_NAME), \
                                               (IrpNames[(_pIoStack_)->MajorFunction]), \
                                                                                           ( ((_pIoStack_)->MajorFunction == IRP_MJ_PNP) ? PnpMinorFuncNames[(_pIoStack_)->MinorFunction] : 0))); \
  } while(0)
Print Irp name.

This macro prints Irp name, Major and Minor Function.

Parameters:
_module_ debug module
_Irp_ pointer to IRP that we want inspect
See also:
DriverDbgPrintIrp, DebugMask, DriverDbgPrint

#define DriverDbgTrace ( _module_,
_format_   ) 

Value:

do { \
      DriverDbgPrint(DBGLVLTRACE, (_module_), ("[%s]: ", (DRIVER_NAME))); \
      DriverDbgPrint(DBGLVLTRACE, (_module_), (_format_)); \
  }while(0)
Print Debug trace message.

This macro print trace message, when DebugMask is set to DBGLVLTRACE, in all modules.

Parameters:
_module_ debug module
_format_ message format eg. ("some data %d\n", data)
See also:
DebugMask, DriverDbgSetDebugMask

#define DriverDbgWarn ( _format_   ) 

Value:

do { \
      DriverDbgPrint(DBGLVLWARN, \
                     DBGALLMODULES, \
                     ("[%s] file: %s, line: %d warning -> ", (DRIVER_NAME), (__FILE__), (__LINE__))); \
      DriverDbgPrint(DBGLVLERROR, DBGALLMODULES, (_format_)); \
  }while(0)
Print Debug warining message.

This macro print warning message, when DebugMask is set to DBGLVLWARN, in all modules.

Parameters:
_format_ message format eg. ("some data %d\n", data)
See also:
DebugMask, DriverDbgSetDebugMask

 
#define DriverInfo (  ) 

Value:

do { \
    DbgPrint("\n[%s], date: %s, time: %s\n", (DRIVER_NAME), (__DATE__), (__TIME__)); \
  }while(0)
Print Driver information.

This macro print driver specyfic information like driver name, compliation date and compilation time.


Function Documentation

VOID DriverDbgDumpData ( PCHAR  Buffer,
ULONG  BufferSize 
)

Send data dump to kernel debuger.

This function sends data dump to kernel debuger or DbgView programm. Dump data as hexadecimal and ASCII values. Use this function only for buffers that you allocated.

Parameters:
Buffer is a pointer to user buffer
BufferSize is a size of user buffer in Bytes
Returns:
VOID
See also:

VOID DriverDbgSetDebugMask ( ULONG  NewDebugMask  ) 

Set Debug Mask.

This function sets debug mask.

Parameters:
NewDebugMask new DebugMask value
Returns:
VOID
See also:
DebugMask

VOID DriverDbgTest ( VOID   ) 

Internal function that tests DriverDbg module.

This function is useful to tests DriverDbg module. Check correct behavior of DriverDbg implementation.

Returns:
VOID


Variable Documentation

ULONG DebugMask

Debug mask.

DebugMask: 0xdmmmllll
d - device: FDO | PDO
m - module
l - debug level


Generated on Fri Aug 31 13:22:34 2007 for Driver Debug by  doxygen 1.5.3