If the assert happens in a library, then it's hard to determine which module using that library is generating that assert. Use gEfiCallerBaseName in DebugAssert to display the module name.
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Baraneedharan Anbazhagan <[email protected]> --- .../PeiDxeDebugLibReportStatusCode/DebugLib.c | 58 ++++++++++++++-------- .../PeiDxeDebugLibReportStatusCode.inf | 1 + 2 files changed, 39 insertions(+), 20 deletions(-) diff --git a/IntelFrameworkModulePkg/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c b/IntelFrameworkModulePkg/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c index cfdd2f5..0435a6f 100644 --- a/IntelFrameworkModulePkg/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c +++ b/IntelFrameworkModulePkg/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c @@ -22,6 +22,7 @@ #include <Library/DebugLib.h> #include <Library/BaseLib.h> +#include <Library/PrintLib.h> #include <Library/BaseMemoryLib.h> #include <Library/ReportStatusCodeLib.h> #include <Library/PcdLib.h> @@ -268,6 +269,7 @@ DebugAssert ( UINTN HeaderSize; UINTN TotalSize; CHAR8 *Temp; + UINTN ModuleNameSize; UINTN FileNameSize; UINTN DescriptionSize; @@ -275,31 +277,37 @@ DebugAssert ( // Get string size // HeaderSize = sizeof (EFI_DEBUG_ASSERT_DATA); + ModuleNameSize = AsciiStrLen("[") + AsciiStrLen (gEfiCallerBaseName) + AsciiStrLen("] "); FileNameSize = AsciiStrSize (FileName); DescriptionSize = AsciiStrSize (Description); // // Make sure it will all fit in the passed in buffer. // - if (HeaderSize + FileNameSize + DescriptionSize > sizeof (Buffer)) { + if (HeaderSize + ModuleNameSize + FileNameSize + DescriptionSize > sizeof (Buffer)) { // - // FileName + Description is too long to be filled into buffer. + // remove module name if it's too long to be filled into buffer // - if (HeaderSize + FileNameSize < sizeof (Buffer)) { + ModuleNameSize = 0; + if (HeaderSize + FileNameSize + DescriptionSize > sizeof (Buffer)) { // - // Description has enough buffer to be truncated. + // FileName + Description is too long to be filled into buffer. // - DescriptionSize = sizeof (Buffer) - HeaderSize - FileNameSize; - } else { - // - // FileName is too long to be filled into buffer. - // FileName will be truncated. Reserved one byte for Description NULL terminator. - // - DescriptionSize = 1; - FileNameSize = sizeof (Buffer) - HeaderSize - DescriptionSize; + if (HeaderSize + FileNameSize < sizeof (Buffer)) { + // + // Description has enough buffer to be truncated. + // + DescriptionSize = sizeof (Buffer) - HeaderSize - FileNameSize; + } else { + // + // FileName is too long to be filled into buffer. + // FileName will be truncated. Reserved one byte for Description NULL terminator. + // + DescriptionSize = 1; + FileNameSize = sizeof (Buffer) - HeaderSize - DescriptionSize; + } } } - // // Fill in EFI_DEBUG_ASSERT_DATA // @@ -307,17 +315,27 @@ DebugAssert ( AssertData->LineNumber = (UINT32)LineNumber; TotalSize = sizeof (EFI_DEBUG_ASSERT_DATA); - // - // Copy Ascii FileName including NULL terminator. - // - Temp = CopyMem (AssertData + 1, FileName, FileNameSize); - Temp[FileNameSize - 1] = 0; - TotalSize += FileNameSize; + Temp = (CHAR8 *)(AssertData + 1); + if (ModuleNameSize != 0) { + // + // Copy Ascii ModuleName & FileName including NULL terminator + // + AsciiSPrint(Temp, ModuleNameSize + FileNameSize, "[%a] %a", gEfiCallerBaseName, FileName); + TotalSize += (ModuleNameSize + FileNameSize); + } else { + // + // Copy Ascii FileName including NULL terminator. + // + Temp = CopyMem (Temp, FileName, FileNameSize); + Temp[FileNameSize - 1] = 0; + TotalSize += FileNameSize; + } + // // Copy Ascii Description include NULL terminator. // - Temp = CopyMem (Temp + FileNameSize, Description, DescriptionSize); + Temp = CopyMem (Temp + ModuleNameSize + FileNameSize, Description, DescriptionSize); Temp[DescriptionSize - 1] = 0; TotalSize += DescriptionSize; diff --git a/IntelFrameworkModulePkg/Library/PeiDxeDebugLibReportStatusCode/PeiDxeDebugLibReportStatusCode.inf b/IntelFrameworkModulePkg/Library/PeiDxeDebugLibReportStatusCode/PeiDxeDebugLibReportStatusCode.inf index 5544667..50f60c7 100644 --- a/IntelFrameworkModulePkg/Library/PeiDxeDebugLibReportStatusCode/PeiDxeDebugLibReportStatusCode.inf +++ b/IntelFrameworkModulePkg/Library/PeiDxeDebugLibReportStatusCode/PeiDxeDebugLibReportStatusCode.inf @@ -43,6 +43,7 @@ BaseMemoryLib BaseLib DebugPrintErrorLevelLib + PrintLib [Pcd] gEfiMdePkgTokenSpaceGuid.PcdDebugClearMemoryValue ## SOMETIMES_CONSUMES -- 2.6.3.windows.1 _______________________________________________ edk2-devel mailing list [email protected] https://lists.01.org/mailman/listinfo/edk2-devel

