summaryrefslogtreecommitdiff
path: root/IntelFrameworkModulePkg
diff options
context:
space:
mode:
authorBaraneedharan Anbazhagan <anbazhagan@hp.com>2015-12-07 03:06:58 +0000
committerlgao4 <lgao4@Edk2>2015-12-07 03:06:58 +0000
commit1ffe7cc56281fda7c714d32d569b533925d37ede (patch)
tree005a39be60ff0fc2d2bd8b411cb7135bbebba6c5 /IntelFrameworkModulePkg
parent39eccb9c66be7329eaf564d18f8f3cfb9add82e9 (diff)
downloadedk2-platforms-1ffe7cc56281fda7c714d32d569b533925d37ede.tar.xz
IntelFrameworkModulePkg: DebugAssert enhancement
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. In V2: Updated patch to use CopyMem instead of AsciiSPrint. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Baraneedharan Anbazhagan <anbazhagan@hp.com> Reviewed-by: Liming Gao <liming.gao@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@19129 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'IntelFrameworkModulePkg')
-rw-r--r--IntelFrameworkModulePkg/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c51
1 files changed, 36 insertions, 15 deletions
diff --git a/IntelFrameworkModulePkg/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c b/IntelFrameworkModulePkg/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c
index cfdd2f50d5..7b07916bbd 100644
--- a/IntelFrameworkModulePkg/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c
+++ b/IntelFrameworkModulePkg/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c
@@ -268,6 +268,7 @@ DebugAssert (
UINTN HeaderSize;
UINTN TotalSize;
CHAR8 *Temp;
+ UINTN ModuleNameSize;
UINTN FileNameSize;
UINTN DescriptionSize;
@@ -275,31 +276,40 @@ DebugAssert (
// Get string size
//
HeaderSize = sizeof (EFI_DEBUG_ASSERT_DATA);
+ //
+ // Compute string size of module name enclosed by []
+ //
+ ModuleNameSize = 2 + AsciiStrSize (gEfiCallerBaseName);
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)) {
- //
- // Description has enough buffer to be truncated.
- //
- DescriptionSize = sizeof (Buffer) - HeaderSize - FileNameSize;
- } else {
+ ModuleNameSize = 0;
+ if (HeaderSize + FileNameSize + DescriptionSize > sizeof (Buffer)) {
//
- // FileName is too long to be filled into buffer.
- // FileName will be truncated. Reserved one byte for Description NULL terminator.
+ // FileName + Description is too long to be filled into buffer.
//
- 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,12 +317,23 @@ DebugAssert (
AssertData->LineNumber = (UINT32)LineNumber;
TotalSize = sizeof (EFI_DEBUG_ASSERT_DATA);
+ Temp = (CHAR8 *)(AssertData + 1);
+
+ //
+ // Copy Ascii [ModuleName].
+ //
+ if (ModuleNameSize != 0) {
+ CopyMem(Temp, "[", 1);
+ CopyMem(Temp + 1, gEfiCallerBaseName, ModuleNameSize - 3);
+ CopyMem(Temp + ModuleNameSize - 2, "] ", 2);
+ }
+
//
// Copy Ascii FileName including NULL terminator.
//
- Temp = CopyMem (AssertData + 1, FileName, FileNameSize);
+ Temp = CopyMem (Temp + ModuleNameSize, FileName, FileNameSize);
Temp[FileNameSize - 1] = 0;
- TotalSize += FileNameSize;
+ TotalSize += (ModuleNameSize + FileNameSize);
//
// Copy Ascii Description include NULL terminator.