MdePkg: Defined DEBUG_RAISE() to facilitate fuzzing.

This commit is contained in:
Mikhail Krichanov 2023-12-15 17:09:27 +03:00
parent fe0b6465de
commit b29d2e0c4a
4 changed files with 27 additions and 0 deletions

View File

@ -16,6 +16,9 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#ifndef __DEBUG_LIB_H__
#define __DEBUG_LIB_H__
#include <Library/BaseLib.h>
#include <Library/PcdLib.h>
//
// 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

View File

@ -45,3 +45,4 @@
gEfiMdePkgTokenSpaceGuid.PcdImageLoaderDebugSupport
gEfiMdePkgTokenSpaceGuid.PcdImageLoaderProhibitTe
gEfiMdePkgTokenSpaceGuid.PcdImageLoaderAllowMisalignedOffset
gEfiMdePkgTokenSpaceGuid.PcdDebugRaisePropertyMask

View File

@ -38,3 +38,4 @@
gEfiMdePkgTokenSpaceGuid.PcdImageLoaderAlignmentPolicy
gEfiMdePkgTokenSpaceGuid.PcdImageLoaderLoadHeader
gEfiMdePkgTokenSpaceGuid.PcdImageLoaderProhibitTe
gEfiMdePkgTokenSpaceGuid.PcdDebugRaisePropertyMask

View File

@ -2346,6 +2346,13 @@
# @Expression 0x80000002 | (gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask & 0xC0) == 0
gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0|UINT8|0x00000005
## The mask is used to control DEBUG_RAISE() behavior.<BR><BR>
# BIT0 - Enable Debug Assert.<BR>
# BIT1 - Enable Debug Print.<BR>
# BIT4 - Enable BreakPoint as ASSERT.<BR>
# @Prompt DEBUG_RAISE() Property.
gEfiMdePkgTokenSpaceGuid.PcdDebugRaisePropertyMask|0|UINT8|0x0000001b
## This flag is used to control the print out Debug message.<BR><BR>
# BIT0 - Initialization message.<BR>
# BIT1 - Warning message.<BR>