debug.h

来自「WinCE 3.0 BSP, 包含Inter SA1110, Intel_815」· C头文件 代码 · 共 120 行

H
120
字号
//
// Permedia3 Sample Display Driver
// debug.h
//
// Copyright (c) 2000 Microsoft Corporation. All rights reserved.
//
// This file includes the various conditionally compiled debug code. All of
// the debug calls are actually macros that resolve to functions in debug
// builds and to nothing in retail builds.

#pragma once

#ifdef DEBUG

// It's a debug build. Therefore, expand the macros to function calls and
// provide prototypes for those functions.

#define Enter(fn)                 ( EnterFunction( (fn) ) )
#define Exit(fn)                  ( ExitFunction( (fn) ) )
#define Assert(cond)              ( AssertFunction( (cond), __FILE__, __LINE__ ) )
#define AssertReadPtr(ptr, size)  ( AssertReadPtrFunction( (ptr), (size), __FILE__, __LINE__ ) )
#define AssertWritePtr(ptr, size) ( AssertWritePtrFunction( (ptr), (size), __FILE__, __LINE__ ) )
#define AssertVideoPtr(ptr)       ( AssertVideoPtrFunction( (ptr), __FILE__, __LINE__ ) )
#define DumpRegisters(start, end) ( DumpRegistersFunction( (start), (end) ) )
#define DumpRdRegisters()         ( DumpRdRegistersFunction() )

// These debug assist functions have variable parameter lists: which doesn't
// translate well to a macro. So, simply replace the macro with the actual
// function name.

#define Error                     ErrorFunction
#define Message                   MessageFunction

// Prototypes

extern void
MessageFunction(
  LPWSTR Format,
  ...
  );

extern void
ErrorFunction(
  LPWSTR Format,
  ...
  );

extern void
AssertFunction(
  BOOL   Condition,
  LPSTR  FileName,
  UINT   Line
  );

extern void
AssertReadPtrFunction(
  LPVOID Pointer,
  ULONG  SizeofPointer,
  LPSTR  FileName,
  UINT   Line
  );

extern void
AssertWritePtrFunction(
  LPVOID Pointer,
  ULONG  SizeofPointer,
  LPSTR  FileName,
  UINT   Line
  );

extern void
AssertVideoPtrFunction(
  LPVOID Pointer,
  LPSTR  FileName,
  UINT   Line
  );

extern void
EnterFunction(
  LPWSTR FunctionName
  );

extern void
ExitFunction(
  LPWSTR FunctionName
  );

extern void
DumpRegistersFunction(
  ULONG StartIndex,
  ULONG EndIndex
  );

extern void
DumpRdRegistersFunction();

#else

// We are in a retail build: simply define the debug macros to nothing.

#define Enter(fn)
#define Exit(fn)
#define Assert(cond)
#define AssertReadPtr(ptr, size)
#define AssertWritePtr(ptr, size)
#define AssertVideoPtr(ptr)
#define DumpRegisters(start, end)
#define DumpRdRegisters()

// These debug assist functions have variable parameter lists: which doesn't
// translate well to a macro. So, we'll just list no parameters, and turn off
// the annoying compiler warning telling us the number of parameters do not
// match.

#pragma warning (disable : 4002)
#define Error()
#define Message()

#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?