From 3e6fb77a99dea09ffc83cdb8916b16c4cbb80ac0 Mon Sep 17 00:00:00 2001 From: Mike Beton Date: Mon, 27 Nov 2023 21:58:01 +0000 Subject: [PATCH] MdePkg: Convert new normal debug info to separate struct --- .../DefaultExceptionHandlerUefi.c | 16 ++--- EmbeddedPkg/GdbStub/GdbStub.c | 8 +-- MdeModulePkg/Core/Dxe/DxeMain.h | 9 ++- MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c | 1 - MdeModulePkg/Core/Dxe/Image/Image.c | 2 +- MdeModulePkg/Core/Dxe/Misc/DebugImageInfo.c | 62 +++++++++---------- MdeModulePkg/Core/PiSmmCore/DebugImageInfo.c | 34 +++++----- MdeModulePkg/Core/PiSmmCore/Dispatcher.c | 2 +- MdeModulePkg/Core/PiSmmCore/PiSmmCore.c | 2 +- .../Universal/EbcDxe/EbcDebugger/EdbSymbol.c | 6 +- MdePkg/Include/Guid/DebugImageInfoTable.h | 57 ++++++++++++++--- .../DpDynamicCommand/DpUtilities.c | 10 +-- .../CpuExceptionHandlerLib/DxeException.c | 22 +++---- .../CpuExceptionHandlerLib/SmmException.c | 22 +++---- UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c | 26 ++++---- 15 files changed, 160 insertions(+), 119 deletions(-) diff --git a/ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerUefi.c b/ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerUefi.c index 69026718e4..dc049ae6b4 100644 --- a/ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerUefi.c +++ b/ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerUefi.c @@ -50,16 +50,16 @@ GetImageName ( Address = (CHAR8 *)(UINTN)FaultAddress; for (Entry = 0; Entry < DebugTableHeader->TableSize; Entry++, DebugTable++) { - if (DebugTable->NormalImage != NULL) { - if ((DebugTable->NormalImage->ImageInfoType == EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL) && - (DebugTable->NormalImage->LoadedImageProtocolInstance != NULL)) + if (DebugTable->NormalImage2 != NULL) { + if ((DebugTable->NormalImage2->ImageInfoType == EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL2) && + (DebugTable->NormalImage2->LoadedImageProtocolInstance != NULL)) { - if ((Address >= (CHAR8 *)DebugTable->NormalImage->LoadedImageProtocolInstance->ImageBase) && - (Address <= ((CHAR8 *)DebugTable->NormalImage->LoadedImageProtocolInstance->ImageBase + DebugTable->NormalImage->LoadedImageProtocolInstance->ImageSize))) + if ((Address >= (CHAR8 *)DebugTable->NormalImage2->LoadedImageProtocolInstance->ImageBase) && + (Address <= ((CHAR8 *)DebugTable->NormalImage2->LoadedImageProtocolInstance->ImageBase + DebugTable->NormalImage2->LoadedImageProtocolInstance->ImageSize))) { - *ImageBase = (UINTN)DebugTable->NormalImage->LoadedImageProtocolInstance->ImageBase; - *DebugBase = (UINTN)DebugTable->NormalImage->DebugBase; - return DebugTable->NormalImage->PdbPath; + *ImageBase = (UINTN)DebugTable->NormalImage2->LoadedImageProtocolInstance->ImageBase; + *DebugBase = (UINTN)DebugTable->NormalImage2->DebugBase; + return DebugTable->NormalImage2->PdbPath; } } } diff --git a/EmbeddedPkg/GdbStub/GdbStub.c b/EmbeddedPkg/GdbStub/GdbStub.c index 3d317cb05a..6e4f894a21 100644 --- a/EmbeddedPkg/GdbStub/GdbStub.c +++ b/EmbeddedPkg/GdbStub/GdbStub.c @@ -873,10 +873,10 @@ QxferLibrary ( if (gDebugTable != NULL) { for ( ; gEfiDebugImageTableEntry < gDebugImageTableHeader->TableSize; gEfiDebugImageTableEntry++, gDebugTable++) { - if (gDebugTable->NormalImage != NULL) { - if ((gDebugTable->NormalImage->ImageInfoType == EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL) && - (gDebugTable->NormalImage->LoadedImageProtocolInstance != NULL)) { - Pdb = gDebugTable->NormalImage->PdbPath; + if (gDebugTable->NormalImage2 != NULL) { + if ((gDebugTable->NormalImage2->ImageInfoType == EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL2) && + (gDebugTable->NormalImage2->LoadedImageProtocolInstance != NULL)) { + Pdb = gDebugTable->NormalImage2->PdbPath; if (Pdb != NULL) { Size = AsciiSPrint ( gXferLibraryBuffer, diff --git a/MdeModulePkg/Core/Dxe/DxeMain.h b/MdeModulePkg/Core/Dxe/DxeMain.h index 967b6eede6..57d6f2a5b1 100644 --- a/MdeModulePkg/Core/Dxe/DxeMain.h +++ b/MdeModulePkg/Core/Dxe/DxeMain.h @@ -2369,18 +2369,17 @@ CoreUpdateDebugTableCrc32 ( Adds a new DebugImageInfo structure to the DebugImageInfo Table. Re-Allocates the table if it's not large enough to accomidate another entry. - @param ImageInfoType type of debug image information @param LoadedImage pointer to the loaded image protocol for the image being loaded @param ImageHandle image handle for the image being loaded + @param ImageContext image context for the image being loaded **/ VOID CoreNewDebugImageInfoEntry ( - IN UINT32 ImageInfoType, - IN EFI_LOADED_IMAGE_PROTOCOL *LoadedImage, - IN EFI_HANDLE ImageHandle, - IN UEFI_IMAGE_LOADER_IMAGE_CONTEXT *ImageContext + IN EFI_LOADED_IMAGE_PROTOCOL *LoadedImage, + IN EFI_HANDLE ImageHandle, + IN CONST UEFI_IMAGE_LOADER_IMAGE_CONTEXT *ImageContext ); /** diff --git a/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c b/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c index b4562d21e3..58c36e4587 100644 --- a/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c +++ b/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c @@ -389,7 +389,6 @@ DxeMain ( // CoreInitializeDebugImageInfoTable (); CoreNewDebugImageInfoEntry ( - EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL, gDxeCoreLoadedImage, gImageHandle, &ImageContext diff --git a/MdeModulePkg/Core/Dxe/Image/Image.c b/MdeModulePkg/Core/Dxe/Image/Image.c index c3b72a80f1..8afc6a8d30 100644 --- a/MdeModulePkg/Core/Dxe/Image/Image.c +++ b/MdeModulePkg/Core/Dxe/Image/Image.c @@ -1385,7 +1385,7 @@ CoreLoadImageCommon ( // Register the image in the Debug Image Info Table if the attribute is set // if ((Attribute & EFI_LOAD_PE_IMAGE_ATTRIBUTE_DEBUG_IMAGE_INFO_TABLE_REGISTRATION) != 0) { - CoreNewDebugImageInfoEntry (EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL, &Image->Info, Image->Handle, &ImageContext); + CoreNewDebugImageInfoEntry (&Image->Info, Image->Handle, &ImageContext); } // diff --git a/MdeModulePkg/Core/Dxe/Misc/DebugImageInfo.c b/MdeModulePkg/Core/Dxe/Misc/DebugImageInfo.c index 2c898a9e58..40a96781a3 100644 --- a/MdeModulePkg/Core/Dxe/Misc/DebugImageInfo.c +++ b/MdeModulePkg/Core/Dxe/Misc/DebugImageInfo.c @@ -152,28 +152,27 @@ CoreUpdateDebugTableCrc32 ( Adds a new DebugImageInfo structure to the DebugImageInfo Table. Re-Allocates the table if it's not large enough to accomidate another entry. - @param ImageInfoType type of debug image information @param LoadedImage pointer to the loaded image protocol for the image being loaded @param ImageHandle image handle for the image being loaded + @param ImageContext image context for the image being loaded **/ VOID CoreNewDebugImageInfoEntry ( - IN UINT32 ImageInfoType, - IN EFI_LOADED_IMAGE_PROTOCOL *LoadedImage, - IN EFI_HANDLE ImageHandle, - IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *ImageContext + IN EFI_LOADED_IMAGE_PROTOCOL *LoadedImage, + IN EFI_HANDLE ImageHandle, + IN CONST UEFI_IMAGE_LOADER_IMAGE_CONTEXT *ImageContext ) { - EFI_DEBUG_IMAGE_INFO *Table; - EFI_DEBUG_IMAGE_INFO *NewTable; - UINTN Index; - UINTN TableSize; - EFI_DEBUG_IMAGE_INFO_NORMAL *NormalImage; - RETURN_STATUS Status; - CONST CHAR8 *PdbPath; - UINT32 PdbPathSize; + EFI_DEBUG_IMAGE_INFO *Table; + EFI_DEBUG_IMAGE_INFO *NewTable; + UINTN Index; + UINTN TableSize; + EFI_DEBUG_IMAGE_INFO_NORMAL2 *NormalImage2; + RETURN_STATUS Status; + CONST CHAR8 *PdbPath; + UINT32 PdbPathSize; // // Set the flag indicating that we're in the process of updating the table. @@ -187,7 +186,7 @@ CoreNewDebugImageInfoEntry ( // We still have empty entires in the Table, find the first empty entry. // Index = 0; - while (Table[Index].NormalImage != NULL) { + while (Table[Index].NormalImage2 != NULL) { Index++; } @@ -232,26 +231,27 @@ CoreNewDebugImageInfoEntry ( // // Allocate data for new entry // - NormalImage = AllocateZeroPool (sizeof (EFI_DEBUG_IMAGE_INFO_NORMAL)); - if (NormalImage != NULL) { + NormalImage2 = AllocateZeroPool (sizeof (EFI_DEBUG_IMAGE_INFO_NORMAL2)); + if (NormalImage2 != NULL) { // // Update the entry // - NormalImage->ImageInfoType = (UINT32)ImageInfoType; - NormalImage->LoadedImageProtocolInstance = LoadedImage; - NormalImage->ImageHandle = ImageHandle; + NormalImage2->ImageInfoType = EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL2; + NormalImage2->Size = sizeof (EFI_DEBUG_IMAGE_INFO_NORMAL2); + NormalImage2->LoadedImageProtocolInstance = LoadedImage; + NormalImage2->ImageHandle = ImageHandle; Status = UefiImageGetSymbolsPath (ImageContext, &PdbPath, &PdbPathSize); if (!RETURN_ERROR (Status)) { - NormalImage->PdbPath = AllocateCopyPool (PdbPathSize, PdbPath); + NormalImage2->PdbPath = AllocateCopyPool (PdbPathSize, PdbPath); } - NormalImage->DebugBase = UefiImageLoaderGetDebugAddress (ImageContext); + NormalImage2->DebugBase = UefiImageLoaderGetDebugAddress (ImageContext); // // Increase the number of EFI_DEBUG_IMAGE_INFO elements and set the mDebugInfoTable in modified status. // mDebugInfoTableHeader.UpdateStatus |= EFI_DEBUG_IMAGE_INFO_TABLE_MODIFIED; - Table[Index].NormalImage = NormalImage; + Table[Index].NormalImage2 = NormalImage2; mDebugInfoTableHeader.TableSize++; } @@ -269,33 +269,33 @@ CoreRemoveDebugImageInfoEntry ( EFI_HANDLE ImageHandle ) { - EFI_DEBUG_IMAGE_INFO *Table; - UINTN Index; - EFI_DEBUG_IMAGE_INFO_NORMAL *NormalImage; + EFI_DEBUG_IMAGE_INFO *Table; + UINTN Index; + EFI_DEBUG_IMAGE_INFO_NORMAL2 *NormalImage2; mDebugInfoTableHeader.UpdateStatus |= EFI_DEBUG_IMAGE_INFO_UPDATE_IN_PROGRESS; Table = mDebugInfoTableHeader.EfiDebugImageInfoTable; for (Index = 0; Index < mMaxTableEntries; Index++) { - if ((Table[Index].NormalImage != NULL) && (Table[Index].NormalImage->ImageHandle == ImageHandle)) { + if ((Table[Index].NormalImage2 != NULL) && (Table[Index].NormalImage2->ImageHandle == ImageHandle)) { // // Found a match. Free up the record, then NULL the pointer to indicate the slot // is free. // - NormalImage = Table[Index].NormalImage; + NormalImage2 = Table[Index].NormalImage2; // // Decrease the number of EFI_DEBUG_IMAGE_INFO elements and set the mDebugInfoTable in modified status. // mDebugInfoTableHeader.UpdateStatus |= EFI_DEBUG_IMAGE_INFO_TABLE_MODIFIED; mDebugInfoTableHeader.TableSize--; - Table[Index].NormalImage = NULL; + Table[Index].NormalImage2 = NULL; - if (NormalImage->PdbPath != NULL) { - FreePool (NormalImage->PdbPath); + if (NormalImage2->PdbPath != NULL) { + FreePool (NormalImage2->PdbPath); } - CoreFreePool (NormalImage); + CoreFreePool (NormalImage2); break; } } diff --git a/MdeModulePkg/Core/PiSmmCore/DebugImageInfo.c b/MdeModulePkg/Core/PiSmmCore/DebugImageInfo.c index 78f7cb2b88..f77225ea07 100644 --- a/MdeModulePkg/Core/PiSmmCore/DebugImageInfo.c +++ b/MdeModulePkg/Core/PiSmmCore/DebugImageInfo.c @@ -65,14 +65,14 @@ SmmNewDebugImageInfoEntry ( IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *ImageContext ) { - EFI_DEBUG_IMAGE_INFO *Table; - EFI_DEBUG_IMAGE_INFO *NewTable; - UINTN Index; - UINTN TableSize; - EFI_DEBUG_IMAGE_INFO_NORMAL *NormalImage; - RETURN_STATUS Status; - CONST CHAR8 *PdbPath; - UINT32 PdbPathSize; + EFI_DEBUG_IMAGE_INFO *Table; + EFI_DEBUG_IMAGE_INFO *NewTable; + UINTN Index; + UINTN TableSize; + EFI_DEBUG_IMAGE_INFO_NORMAL2 *NormalImage2; + RETURN_STATUS Status; + CONST CHAR8 *PdbPath; + UINT32 PdbPathSize; // // Set the flag indicating that we're in the process of updating the table. @@ -86,7 +86,7 @@ SmmNewDebugImageInfoEntry ( // We still have empty entires in the Table, find the first empty entry. // Index = 0; - while (Table[Index].NormalImage != NULL) { + while (Table[Index].NormalImage2 != NULL) { Index++; } // @@ -129,26 +129,26 @@ SmmNewDebugImageInfoEntry ( // // Allocate data for new entry // - NormalImage = AllocateZeroPool (sizeof (EFI_DEBUG_IMAGE_INFO_NORMAL)); - if (NormalImage != NULL) { + NormalImage2 = AllocateZeroPool (sizeof (EFI_DEBUG_IMAGE_INFO_NORMAL2)); + if (NormalImage2 != NULL) { // // Update the entry // - NormalImage->ImageInfoType = (UINT32) ImageInfoType; - NormalImage->LoadedImageProtocolInstance = LoadedImage; - NormalImage->ImageHandle = ImageHandle; + NormalImage2->ImageInfoType = (UINT32) ImageInfoType; + NormalImage2->LoadedImageProtocolInstance = LoadedImage; + NormalImage2->ImageHandle = ImageHandle; Status = UefiImageGetSymbolsPath (ImageContext, &PdbPath, &PdbPathSize); if (!RETURN_ERROR (Status)) { - NormalImage->PdbPath = AllocateCopyPool (PdbPathSize, PdbPath); + NormalImage2->PdbPath = AllocateCopyPool (PdbPathSize, PdbPath); } - NormalImage->DebugBase = UefiImageLoaderGetDebugAddress (ImageContext); + NormalImage2->DebugBase = UefiImageLoaderGetDebugAddress (ImageContext); // // Increase the number of EFI_DEBUG_IMAGE_INFO elements and set the mDebugInfoTable in modified status. // mDebugInfoTableHeader.UpdateStatus |= EFI_DEBUG_IMAGE_INFO_TABLE_MODIFIED; - Table[Index].NormalImage = NormalImage; + Table[Index].NormalImage2 = NormalImage2; mDebugInfoTableHeader.TableSize++; } mDebugInfoTableHeader.UpdateStatus &= ~EFI_DEBUG_IMAGE_INFO_UPDATE_IN_PROGRESS; diff --git a/MdeModulePkg/Core/PiSmmCore/Dispatcher.c b/MdeModulePkg/Core/PiSmmCore/Dispatcher.c index 8f94e59178..a59d8c3dfb 100644 --- a/MdeModulePkg/Core/PiSmmCore/Dispatcher.c +++ b/MdeModulePkg/Core/PiSmmCore/Dispatcher.c @@ -572,7 +572,7 @@ SmmLoadImage ( // Register the image in the Debug Image Info Table if the attribute is set // SmmNewDebugImageInfoEntry ( - EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL, + EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL2, &DriverEntry->SmmLoadedImage, DriverEntry->SmmImageHandle, ImageContext diff --git a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.c b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.c index be65e321e3..b9baa3ec22 100644 --- a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.c +++ b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.c @@ -859,7 +859,7 @@ SmmCoreInstallLoadedImage ( // SmmInitializeDebugImageInfoTable (); SmmNewDebugImageInfoEntry ( - EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL, + EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL2, &mSmmCoreDriverEntry->SmmLoadedImage, mSmmCoreDriverEntry->SmmImageHandle, &gSmmCorePrivate->PiSmmCoreImageContext diff --git a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbSymbol.c b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbSymbol.c index cf8ff3d371..c00cef68b1 100644 --- a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbSymbol.c +++ b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbSymbol.c @@ -949,15 +949,15 @@ EdbPatchSymbolRVA ( CandidateImageBase = NULL; ImageTable = mDebuggerPrivate.DebugImageInfoTableHeader->EfiDebugImageInfoTable; for (ImageNumber = 0; ImageNumber < mDebuggerPrivate.DebugImageInfoTableHeader->TableSize; ImageNumber++) { - if (ImageTable[ImageNumber].NormalImage == NULL) { + if (ImageTable[ImageNumber].NormalImage2 == NULL) { continue; } - ImageBase = ImageTable[ImageNumber].NormalImage->LoadedImageProtocolInstance->ImageBase; + ImageBase = ImageTable[ImageNumber].NormalImage2->LoadedImageProtocolInstance->ImageBase; // // Get PDB path // - PdbPath = ImageTable[ImageNumber].NormalImage->PdbPath; + PdbPath = ImageTable[ImageNumber].NormalImage2->PdbPath; if (PdbPath == NULL) { continue; } diff --git a/MdePkg/Include/Guid/DebugImageInfoTable.h b/MdePkg/Include/Guid/DebugImageInfoTable.h index c26ba10e26..cfc47e7694 100644 --- a/MdePkg/Include/Guid/DebugImageInfoTable.h +++ b/MdePkg/Include/Guid/DebugImageInfoTable.h @@ -25,7 +25,8 @@ #define EFI_DEBUG_IMAGE_INFO_UPDATE_IN_PROGRESS 0x01 #define EFI_DEBUG_IMAGE_INFO_TABLE_MODIFIED 0x02 -#define EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL 0x01 +#define EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL 0x01 +#define EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL2 0x02 typedef struct { UINT64 Signature; ///< A constant UINT64 that has the value EFI_SYSTEM_TABLE_SIGNATURE @@ -35,8 +36,8 @@ typedef struct { typedef struct { /// - /// Indicates the type of image info structure. For PE32 EFI images, - /// this is set to EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL. + /// When this debug image info structure is present, ImageInfoType is set + /// to EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL indicating a loaded PE32 EFI image. /// UINT32 ImageInfoType; /// @@ -47,13 +48,55 @@ typedef struct { /// Indicates the image handle of the associated image. /// EFI_HANDLE ImageHandle; - CHAR8 *PdbPath; - UINTN DebugBase; } EFI_DEBUG_IMAGE_INFO_NORMAL; +typedef struct { + /// + /// When this debug image info structure is present, ImageInfoType is + /// set to EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL2, indicating that PdbPath + /// and DebugBase fields are available for symbolication. The format + /// of the loaded image is not specified and may or may not be PE. + /// + UINT32 ImageInfoType; + /// + /// The size of the current instance of this struct, including any + /// custom extensions. + /// + UINTN Size; + /// + /// A pointer to an instance of the loaded image protocol for the associated image. + /// + EFI_LOADED_IMAGE_PROTOCOL *LoadedImageProtocolInstance; + /// + /// Indicates the image handle of the associated image. + /// + EFI_HANDLE ImageHandle; + /// + /// Symbol file path for debug symbolication. + /// + CHAR8 *PdbPath; + /// + /// Image base address for debug symbolication. + /// + UINTN DebugBase; +} EFI_DEBUG_IMAGE_INFO_NORMAL2; + typedef union { - UINT32 *ImageInfoType; - EFI_DEBUG_IMAGE_INFO_NORMAL *NormalImage; + /// + /// Indicates the type of image info structure which is present. For + /// PE32 EFI images loaded with the old image loader, this is set to + /// EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL. For all images loaded with the new + /// image loader, this is set to EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL2. + /// + UINT32 *ImageInfoType; + /// + /// Present when ImageInfoType is EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL. + /// + EFI_DEBUG_IMAGE_INFO_NORMAL *NormalImage; + /// + /// Present when ImageInfoType is EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL2. + /// + EFI_DEBUG_IMAGE_INFO_NORMAL2 *NormalImage2; } EFI_DEBUG_IMAGE_INFO; typedef struct { diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/DpUtilities.c b/ShellPkg/DynamicCommand/DpDynamicCommand/DpUtilities.c index 240093dc26..4d0079898c 100644 --- a/ShellPkg/DynamicCommand/DpDynamicCommand/DpUtilities.c +++ b/ShellPkg/DynamicCommand/DpDynamicCommand/DpUtilities.c @@ -211,11 +211,11 @@ GetImagePdb ( } for (Entry = 0; Entry < DebugTableHeader->TableSize; Entry++, DebugTable++) { - if (DebugTable->NormalImage != NULL) { - if ((DebugTable->NormalImage->ImageInfoType == EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL) && - (DebugTable->NormalImage->LoadedImageProtocolInstance != NULL)) { - if (ImageBase == DebugTable->NormalImage->LoadedImageProtocolInstance->ImageBase) { - return DebugTable->NormalImage->PdbPath; + if (DebugTable->NormalImage2 != NULL) { + if ((DebugTable->NormalImage2->ImageInfoType == EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL2) && + (DebugTable->NormalImage2->LoadedImageProtocolInstance != NULL)) { + if (ImageBase == DebugTable->NormalImage2->LoadedImageProtocolInstance->ImageBase) { + return DebugTable->NormalImage2->PdbPath; } } } diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeException.c b/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeException.c index 889eadc0a4..30731a8071 100644 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeException.c +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeException.c @@ -148,9 +148,9 @@ GetImageInfoByIp ( IN UINTN CurrentEip ) { - EFI_STATUS Status; - UINT32 Index; - CONST EFI_DEBUG_IMAGE_INFO_NORMAL *NormalImage; + EFI_STATUS Status; + UINT32 Index; + CONST EFI_DEBUG_IMAGE_INFO_NORMAL2 *NormalImage2; if (mDebugImageInfoTable == NULL) { Status = EfiGetSystemConfigurationTable ( @@ -170,19 +170,19 @@ GetImageInfoByIp ( continue; } - if (*mDebugImageInfoTable->EfiDebugImageInfoTable[Index].ImageInfoType != EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL) { + if (*mDebugImageInfoTable->EfiDebugImageInfoTable[Index].ImageInfoType != EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL2) { continue; } - NormalImage = mDebugImageInfoTable->EfiDebugImageInfoTable[Index].NormalImage; + NormalImage2 = mDebugImageInfoTable->EfiDebugImageInfoTable[Index].NormalImage2; - ASSERT (NormalImage->LoadedImageProtocolInstance != NULL); + ASSERT (NormalImage2->LoadedImageProtocolInstance != NULL); - if (CurrentEip >= (UINTN) NormalImage->LoadedImageProtocolInstance->ImageBase && - CurrentEip < (UINTN) NormalImage->LoadedImageProtocolInstance->ImageBase + NormalImage->LoadedImageProtocolInstance->ImageSize) { - *ImageBase = (UINTN) NormalImage->LoadedImageProtocolInstance->ImageBase; - *DebugBase = NormalImage->DebugBase; - *SymbolsPath = NormalImage->PdbPath; + if (CurrentEip >= (UINTN) NormalImage2->LoadedImageProtocolInstance->ImageBase && + CurrentEip < (UINTN) NormalImage2->LoadedImageProtocolInstance->ImageBase + NormalImage2->LoadedImageProtocolInstance->ImageSize) { + *ImageBase = (UINTN) NormalImage2->LoadedImageProtocolInstance->ImageBase; + *DebugBase = NormalImage2->DebugBase; + *SymbolsPath = NormalImage2->PdbPath; return TRUE; } } diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmException.c b/UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmException.c index 4b9d087438..4e02f35fa2 100644 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmException.c +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmException.c @@ -155,9 +155,9 @@ GetImageInfoByIp ( IN UINTN CurrentEip ) { - EFI_STATUS Status; - UINT32 Index; - CONST EFI_DEBUG_IMAGE_INFO_NORMAL *NormalImage; + EFI_STATUS Status; + UINT32 Index; + CONST EFI_DEBUG_IMAGE_INFO_NORMAL2 *NormalImage2; if (mDebugImageInfoTableHeader == NULL) { Status = InternalGetSystemConfigurationTable ( @@ -177,19 +177,19 @@ GetImageInfoByIp ( continue; } - if (*mDebugImageInfoTableHeader->EfiDebugImageInfoTable[Index].ImageInfoType != EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL) { + if (*mDebugImageInfoTableHeader->EfiDebugImageInfoTable[Index].ImageInfoType != EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL2) { continue; } - NormalImage = mDebugImageInfoTableHeader->EfiDebugImageInfoTable[Index].NormalImage; + NormalImage2 = mDebugImageInfoTableHeader->EfiDebugImageInfoTable[Index].NormalImage2; - ASSERT (NormalImage->LoadedImageProtocolInstance != NULL); + ASSERT (NormalImage2->LoadedImageProtocolInstance != NULL); - if (CurrentEip >= (UINTN) NormalImage->LoadedImageProtocolInstance->ImageBase && - CurrentEip < (UINTN) NormalImage->LoadedImageProtocolInstance->ImageBase + NormalImage->LoadedImageProtocolInstance->ImageSize) { - *ImageBase = (UINTN) NormalImage->LoadedImageProtocolInstance->ImageBase; - *DebugBase = NormalImage->DebugBase; - *SymbolsPath = NormalImage->PdbPath; + if (CurrentEip >= (UINTN) NormalImage2->LoadedImageProtocolInstance->ImageBase && + CurrentEip < (UINTN) NormalImage2->LoadedImageProtocolInstance->ImageBase + NormalImage2->LoadedImageProtocolInstance->ImageSize) { + *ImageBase = (UINTN) NormalImage2->LoadedImageProtocolInstance->ImageBase; + *DebugBase = NormalImage2->DebugBase; + *SymbolsPath = NormalImage2->PdbPath; return TRUE; } } diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c index c535e7098f..ddf4ec3ad0 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c @@ -196,14 +196,14 @@ SmmGetSystemConfigurationTable ( CONST EFI_DEBUG_IMAGE_INFO_TABLE_HEADER *mDebugImageInfoTableHeader = NULL; // FIXME: -CONST EFI_DEBUG_IMAGE_INFO_NORMAL * +CONST EFI_DEBUG_IMAGE_INFO_NORMAL2 * InternalLocateImage ( IN UINTN CurrentEip ) { EFI_STATUS Status; UINT32 Index; - CONST EFI_DEBUG_IMAGE_INFO_NORMAL *NormalImage; + CONST EFI_DEBUG_IMAGE_INFO_NORMAL2 *NormalImage2; if (mDebugImageInfoTableHeader == NULL) { Status = SmmGetSystemConfigurationTable ( @@ -223,17 +223,17 @@ InternalLocateImage ( continue; } - if (*mDebugImageInfoTableHeader->EfiDebugImageInfoTable[Index].ImageInfoType != EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL) { + if (*mDebugImageInfoTableHeader->EfiDebugImageInfoTable[Index].ImageInfoType != EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL2) { continue; } - NormalImage = mDebugImageInfoTableHeader->EfiDebugImageInfoTable[Index].NormalImage; + NormalImage2 = mDebugImageInfoTableHeader->EfiDebugImageInfoTable[Index].NormalImage2; - ASSERT (NormalImage->LoadedImageProtocolInstance != NULL); + ASSERT (NormalImage2->LoadedImageProtocolInstance != NULL); - if (CurrentEip >= (UINTN) NormalImage->LoadedImageProtocolInstance->ImageBase && - CurrentEip < (UINTN) NormalImage->LoadedImageProtocolInstance->ImageBase + NormalImage->LoadedImageProtocolInstance->ImageSize) { - return NormalImage; + if (CurrentEip >= (UINTN) NormalImage2->LoadedImageProtocolInstance->ImageBase && + CurrentEip < (UINTN) NormalImage2->LoadedImageProtocolInstance->ImageBase + NormalImage2->LoadedImageProtocolInstance->ImageSize) { + return NormalImage2; } } @@ -251,17 +251,17 @@ DumpModuleInfoByIp ( IN UINTN CallerIpAddress ) { - CONST EFI_DEBUG_IMAGE_INFO_NORMAL *NormalImage; + CONST EFI_DEBUG_IMAGE_INFO_NORMAL2 *NormalImage2; - NormalImage = InternalLocateImage (CallerIpAddress); + NormalImage2 = InternalLocateImage (CallerIpAddress); // // Find Image Base // - if (NormalImage != NULL) { + if (NormalImage2 != NULL) { DEBUG ((DEBUG_ERROR, "It is invoked from the instruction before IP(0x%p)", (VOID *)CallerIpAddress)); - if (NormalImage->PdbPath!= NULL) { - DEBUG ((DEBUG_ERROR, " in module (%a)\n", NormalImage->PdbPath)); + if (NormalImage2->PdbPath!= NULL) { + DEBUG ((DEBUG_ERROR, " in module (%a)\n", NormalImage2->PdbPath)); } } }