diff --git a/MdePkg/Include/Library/DebugLib.h b/MdePkg/Include/Library/DebugLib.h index 86a939c42f..d811fd3479 100644 --- a/MdePkg/Include/Library/DebugLib.h +++ b/MdePkg/Include/Library/DebugLib.h @@ -16,6 +16,9 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #ifndef __DEBUG_LIB_H__ #define __DEBUG_LIB_H__ +#include +#include + // // Declare bits for PcdDebugPropertyMask // @@ -610,6 +613,21 @@ UnitTestDebugAssert ( } \ } while (FALSE) +#define DEBUG_RAISE() \ + do { \ + if ((PcdGet8 (PcdDebugRaisePropertyMask) & DEBUG_PROPERTY_DEBUG_PRINT_ENABLED) != 0) { \ + DEBUG ((DEBUG_WARN, "DEBUG RAISE: Constraint violation in %a:%a:%u\n", __FILE__, __func__, __LINE__));\ + } \ + \ + if ((PcdGet8 (PcdDebugRaisePropertyMask) & DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED) != 0) { \ + ASSERT (FALSE); \ + } \ + \ + if ((PcdGet8 (PcdDebugRaisePropertyMask) & DEBUG_PROPERTY_ASSERT_BREAKPOINT_ENABLED) != 0) { \ + CpuBreakpoint (); \ + } \ + } while (FALSE) + /** Macro that calls DebugAssert() if the containing record does not have a matching signature. If the signatures matches, then a pointer to the data diff --git a/MdePkg/Library/BasePeCoffLib2/BasePeCoffLib2.inf b/MdePkg/Library/BasePeCoffLib2/BasePeCoffLib2.inf index 4d375e2506..f3c3951ac5 100644 --- a/MdePkg/Library/BasePeCoffLib2/BasePeCoffLib2.inf +++ b/MdePkg/Library/BasePeCoffLib2/BasePeCoffLib2.inf @@ -45,3 +45,4 @@ gEfiMdePkgTokenSpaceGuid.PcdImageLoaderDebugSupport gEfiMdePkgTokenSpaceGuid.PcdImageLoaderProhibitTe gEfiMdePkgTokenSpaceGuid.PcdImageLoaderAllowMisalignedOffset + gEfiMdePkgTokenSpaceGuid.PcdDebugRaisePropertyMask diff --git a/MdePkg/Library/BaseUefiImageLib/BaseUefiImageLibPeCoff.inf b/MdePkg/Library/BaseUefiImageLib/BaseUefiImageLibPeCoff.inf index bfe7296e0d..e3684fe922 100644 --- a/MdePkg/Library/BaseUefiImageLib/BaseUefiImageLibPeCoff.inf +++ b/MdePkg/Library/BaseUefiImageLib/BaseUefiImageLibPeCoff.inf @@ -38,3 +38,4 @@ gEfiMdePkgTokenSpaceGuid.PcdImageLoaderAlignmentPolicy gEfiMdePkgTokenSpaceGuid.PcdImageLoaderLoadHeader gEfiMdePkgTokenSpaceGuid.PcdImageLoaderProhibitTe + gEfiMdePkgTokenSpaceGuid.PcdDebugRaisePropertyMask diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec index 3a45a7e9d5..1053634aec 100644 --- a/MdePkg/MdePkg.dec +++ b/MdePkg/MdePkg.dec @@ -2346,6 +2346,13 @@ # @Expression 0x80000002 | (gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask & 0xC0) == 0 gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0|UINT8|0x00000005 + ## The mask is used to control DEBUG_RAISE() behavior.

+ # BIT0 - Enable Debug Assert.
+ # BIT1 - Enable Debug Print.
+ # BIT4 - Enable BreakPoint as ASSERT.
+ # @Prompt DEBUG_RAISE() Property. + gEfiMdePkgTokenSpaceGuid.PcdDebugRaisePropertyMask|0|UINT8|0x0000001b + ## This flag is used to control the print out Debug message.

# BIT0 - Initialization message.
# BIT1 - Warning message.