diff options
-rw-r--r-- | ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c | 3 | ||||
-rw-r--r-- | MdePkg/Include/Library/DebugLib.h | 35 |
2 files changed, 31 insertions, 7 deletions
diff --git a/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c b/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c index a39896d576..1d3ea61311 100644 --- a/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c +++ b/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c @@ -157,7 +157,6 @@ DescribeExceptionSyndrome ( DEBUG ((DEBUG_ERROR, "\n %a \n", Message));
}
-#ifndef MDEPKG_NDEBUG
STATIC
CONST CHAR8 *
BaseName (
@@ -177,8 +176,6 @@ BaseName ( return Str;
}
-#endif
-
/**
This is the default action to take on an unexpected exception
diff --git a/MdePkg/Include/Library/DebugLib.h b/MdePkg/Include/Library/DebugLib.h index 033c4e1a66..b48e08a7e4 100644 --- a/MdePkg/Include/Library/DebugLib.h +++ b/MdePkg/Include/Library/DebugLib.h @@ -8,6 +8,13 @@ of size reduction when compiler optimization is disabled. If MDEPKG_NDEBUG is
defined, then debug and assert related macros wrapped by it are the NULL implementations.
+ The implementations of the macros used when MDEPKG_NDEBUG is defined rely on the fact that
+ directly unreachable code is pruned, even with compiler optimization disabled (which has
+ been confirmed by generated code size tests on supported compilers). The advantage of
+ implementations which consume their arguments within directly unreachable code is that
+ compilers understand this, and stop warning about variables which would become unused when
+ MDEPKG_NDEBUG is defined if the macros had completely empty definitions.
+
Copyright (c) 2006 - 2020, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -403,7 +410,12 @@ UnitTestDebugAssert ( } \
} while (FALSE)
#else
-#define ASSERT(Expression)
+#define ASSERT(Expression) \
+ do { \
+ if (FALSE) { \
+ (VOID) (Expression); \
+ } \
+ } while (FALSE)
#endif
/**
@@ -426,7 +438,12 @@ UnitTestDebugAssert ( } \
} while (FALSE)
#else
-#define DEBUG(Expression)
+#define DEBUG(Expression) \
+ do { \
+ if (FALSE) { \
+ _DEBUGLIB_DEBUG (Expression); \
+ } \
+ } while (FALSE)
#endif
/**
@@ -452,7 +469,12 @@ UnitTestDebugAssert ( } \
} while (FALSE)
#else
-#define ASSERT_EFI_ERROR(StatusParameter)
+#define ASSERT_EFI_ERROR(StatusParameter) \
+ do { \
+ if (FALSE) { \
+ (VOID) (StatusParameter); \
+ } \
+ } while (FALSE)
#endif
/**
@@ -479,7 +501,12 @@ UnitTestDebugAssert ( } \
} while (FALSE)
#else
-#define ASSERT_RETURN_ERROR(StatusParameter)
+#define ASSERT_RETURN_ERROR(StatusParameter) \
+ do { \
+ if (FALSE) { \
+ (VOID) (StatusParameter); \
+ } \
+ } while (FALSE)
#endif
/**
|