]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Include/Library/DebugLib.h
Second set of changes based on a review of the code comments in the Include directory...
[mirror_edk2.git] / MdePkg / Include / Library / DebugLib.h
index 7465abb24d6edca91061913f30dbf9e224470956..9cb9027b7094eae96acde8e0b1f946bd5306bc44 100644 (file)
@@ -1,7 +1,10 @@
 /** @file\r
   Provides services to print debug and assert messages to a debug output device.\r
-\r
-Copyright (c) 2006 - 2008, Intel Corporation\r
+  \r
+  The Debug library supports debug print and asserts based on a combination of macros and code.\r
+  The debug library can be turned on and off so that the debug code does not increase the size of an image.\r
+  \r
+Copyright (c) 2006 - 2008, Intel Corporation<BR>\r
 All rights reserved. This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -66,7 +69,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #define EFI_D_ERROR     DEBUG_ERROR\r
 \r
 /**\r
-\r
   Prints a debug message to the debug output device if the specified error level is enabled.\r
 \r
   If any bit in ErrorLevel is also set in PcdDebugPrintErrorLevel, then print \r
@@ -91,7 +93,6 @@ DebugPrint (
 \r
 \r
 /**\r
-\r
   Prints an assert message containing a filename, line number, and description.  \r
   This may be followed by a breakpoint or a dead loop.\r
 \r
@@ -105,7 +106,6 @@ DebugPrint (
   processing another DebugAssert(), then DebugAssert() must return immediately.\r
 \r
   If FileName is NULL, then a <FileName> string of "(NULL) Filename" is printed.\r
-\r
   If Description is NULL, then a <Description> string of "(NULL) Description" is printed.\r
 \r
   @param  FileName     Pointer to the name of the source file that generated the assert condition.\r
@@ -123,15 +123,13 @@ DebugAssert (
 \r
 \r
 /**\r
-\r
   Fills a target buffer with PcdDebugClearMemoryValue, and returns the target buffer.\r
 \r
   This function fills Length bytes of Buffer with the value specified by \r
   PcdDebugClearMemoryValue, and returns Buffer.\r
 \r
   If Buffer is NULL, then ASSERT().\r
-\r
-  If Length is greater than (MAX_ADDRESS -Buffer + 1), then ASSERT(). \r
+  If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). \r
 \r
   @param   Buffer  Pointer to the target buffer to be filled with PcdDebugClearMemoryValue.\r
   @param   Length  Number of bytes in Buffer to fill with zeros PcdDebugClearMemoryValue. \r
@@ -148,7 +146,6 @@ DebugClearMemory (
 \r
 \r
 /**\r
-  \r
   Returns TRUE if ASSERT() macros are enabled.\r
 \r
   This function returns TRUE if the DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of \r
@@ -165,9 +162,8 @@ DebugAssertEnabled (
   );\r
 \r
 \r
-/**\r
-  \r
-  Returns TRUE if DEBUG()macros are enabled.\r
+/**  \r
+  Returns TRUE if DEBUG() macros are enabled.\r
 \r
   This function returns TRUE if the DEBUG_PROPERTY_DEBUG_PRINT_ENABLED bit of \r
   PcdDebugProperyMask is set.  Otherwise FALSE is returned.\r
@@ -183,9 +179,8 @@ DebugPrintEnabled (
   );\r
 \r
 \r
-/**\r
-  \r
-  Returns TRUE if DEBUG_CODE()macros are enabled.\r
+/**  \r
+  Returns TRUE if DEBUG_CODE() macros are enabled.\r
 \r
   This function returns TRUE if the DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of \r
   PcdDebugProperyMask is set.  Otherwise FALSE is returned.\r
@@ -201,9 +196,8 @@ DebugCodeEnabled (
   );\r
 \r
 \r
-/**\r
-  \r
-  Returns TRUE if DEBUG_CLEAR_MEMORY()macro is enabled.\r
+/**  \r
+  Returns TRUE if DEBUG_CLEAR_MEMORY() macro is enabled.\r
 \r
   This function returns TRUE if the DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED bit of \r
   PcdDebugProperyMask is set.  Otherwise FALSE is returned.\r
@@ -219,21 +213,19 @@ DebugClearMemoryEnabled (
   );\r
 \r
 \r
-/**\r
-  \r
+/**  \r
   Internal worker macro that calls DebugAssert().\r
 \r
-  This macro calls DebugAssert() passing in the filename, line number, and \r
-  expression that evailated to FALSE.\r
+  This macro calls DebugAssert(), passing in the filename, line number, and an\r
+  expression that evaluated to FALSE.\r
 \r
-  @param  Expression  Boolean expression that evailated to FALSE\r
+  @param  Expression  Boolean expression that evaluated to FALSE\r
 \r
 **/\r
 #define _ASSERT(Expression)  DebugAssert (__FILE__, __LINE__, #Expression)\r
 \r
 \r
-/**\r
-  \r
+/**  \r
   Internal worker macro that calls DebugPrint().\r
 \r
   This macro calls DebugPrint() passing in the debug error level, a format \r
@@ -246,9 +238,8 @@ DebugClearMemoryEnabled (
 #define _DEBUG(Expression)   DebugPrint Expression\r
 \r
 \r
-/**\r
-  \r
-  Macro that calls DebugAssert() if a expression evaluates to FALSE.\r
+/**  \r
+  Macro that calls DebugAssert() if an expression evaluates to FALSE.\r
 \r
   If the DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of PcdDebugProperyMask is set, \r
   then this macro evaluates the Boolean expression specified by Expression.  If \r
@@ -268,8 +259,7 @@ DebugClearMemoryEnabled (
   } while (FALSE)\r
 \r
 \r
-/**\r
-  \r
+/**  \r
   Macro that calls DebugPrint().\r
 \r
   If the DEBUG_PROPERTY_DEBUG_PRINT_ENABLED bit of PcdDebugProperyMask is set, \r
@@ -288,8 +278,7 @@ DebugClearMemoryEnabled (
   } while (FALSE)\r
 \r
 \r
-/**\r
-  \r
+/**  \r
   Macro that calls DebugAssert() if an EFI_STATUS evaluates to an error code.\r
 \r
   If the DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of PcdDebugProperyMask is set, \r
@@ -311,8 +300,7 @@ DebugClearMemoryEnabled (
   } while (FALSE)\r
 \r
 \r
-/**\r
-  \r
+/**  \r
   Macro that calls DebugAssert() if a protocol is already installed in the \r
   handle database.\r
 \r
@@ -364,8 +352,7 @@ DebugClearMemoryEnabled (
 #define DEBUG_CODE_BEGIN()  do { if (DebugCodeEnabled ()) { UINT8  __DebugCodeLocal\r
 \r
 \r
-/**\r
-  \r
+/**  \r
   Macro that marks the end of debug source code.\r
 \r
   If the DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of PcdDebugProperyMask is set, \r
@@ -377,8 +364,7 @@ DebugClearMemoryEnabled (
 #define DEBUG_CODE_END()    __DebugCodeLocal = 0; __DebugCodeLocal++; } } while (FALSE)\r
 \r
 \r
-/**\r
-  \r
+/**  \r
   Macro that declares a section of debug source code.\r
 \r
   If the DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of PcdDebugProperyMask is set, \r
@@ -392,8 +378,7 @@ DebugClearMemoryEnabled (
   DEBUG_CODE_END ()\r
 \r
 \r
-/**\r
-  \r
+/**  \r
   Macro that calls DebugClearMemory() to clear a buffer to a default value.\r
 \r
   If the DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED bit of PcdDebugProperyMask is set, \r
@@ -412,7 +397,6 @@ DebugClearMemoryEnabled (
 \r
 \r
 /**\r
-\r
   Macro that calls DebugAssert() if the containing record does not have a \r
   matching signature.  If the signatures matches, then a pointer to the data \r
   structure that contains a specified field of that data structure is returned.  \r
@@ -454,9 +438,9 @@ DebugClearMemoryEnabled (
   @param  TestSignature  The 32-bit signature value to match.\r
 \r
 **/\r
-#define CR(Record, TYPE, Field, TestSignature)                                          \\r
-  (DebugAssertEnabled () && (_CR (Record, TYPE, Field)->Signature != TestSignature)) ?  \\r
-  (TYPE *) (_ASSERT (CR has Bad Signature), Record) :                                   \\r
-  _CR (Record, TYPE, Field)\r
+#define CR(Record, TYPE, Field, TestSignature)                                                        \\r
+  (DebugAssertEnabled () && (BASE_CR (Record, TYPE, Field)->Signature != TestSignature)) ?  \\r
+  (TYPE *) (_ASSERT (CR has Bad Signature), Record) :                                                 \\r
+  BASE_CR (Record, TYPE, Field)\r
     \r
 #endif\r