MdePkg/UefiImageLib: Introduce DebugAddress

Signed-off-by: Marvin Häuser <mhaeuser@posteo.de>
This commit is contained in:
Mikhail Krichanov 2023-12-15 16:34:17 +03:00
parent 04eca169da
commit 0661940f75
37 changed files with 299 additions and 183 deletions

View File

@ -84,19 +84,19 @@ UefiImageLoaderRelocateImageExtraAction (
#ifdef __CC_ARM #ifdef __CC_ARM
#if (__ARMCC_VERSION < 500000) #if (__ARMCC_VERSION < 500000)
// Print out the command for the RVD debugger to load symbols for this image // Print out the command for the RVD debugger to load symbols for this image
DEBUG ((DEBUG_LOAD | DEBUG_INFO, "load /a /ni /np %a &0x%p\n", DeCygwinPathIfNeeded (PdbPath, Temp, sizeof (Temp)), UefiImageLoaderGetImageAddress (ImageContext))); DEBUG ((DEBUG_LOAD | DEBUG_INFO, "load /a /ni /np %a &0x%p\n", DeCygwinPathIfNeeded (PdbPath, Temp, sizeof (Temp)), UefiImageLoaderGetDebugAddress (ImageContext)));
#else #else
// Print out the command for the DS-5 to load symbols for this image // Print out the command for the DS-5 to load symbols for this image
DEBUG ((DEBUG_LOAD | DEBUG_INFO, "add-symbol-file %a -o 0x%p\n", DeCygwinPathIfNeeded (PdbPath, Temp, sizeof (Temp)), UefiImageLoaderGetImageAddress (ImageContext))); DEBUG ((DEBUG_LOAD | DEBUG_INFO, "add-symbol-file %a -o 0x%p\n", DeCygwinPathIfNeeded (PdbPath, Temp, sizeof (Temp)), UefiImageLoaderGetDebugAddress (ImageContext)));
#endif #endif
#elif __GNUC__ #elif __GNUC__
// This may not work correctly if you generate PE/COFF directly as then the Offset would not be required // This may not work correctly if you generate PE/COFF directly as then the Offset would not be required
DEBUG ((DEBUG_LOAD | DEBUG_INFO, "add-symbol-file %a -o 0x%p\n", DeCygwinPathIfNeeded (PdbPath, Temp, sizeof (Temp)), UefiImageLoaderGetImageAddress (ImageContext))); DEBUG ((DEBUG_LOAD | DEBUG_INFO, "add-symbol-file %a -o 0x%p\n", DeCygwinPathIfNeeded (PdbPath, Temp, sizeof (Temp)), UefiImageLoaderGetDebugAddress (ImageContext)));
#else #else
DEBUG ((DEBUG_LOAD | DEBUG_INFO, "Loading driver at 0x%11p EntryPoint=0x%11p\n", (VOID *)(UINTN)UefiImageLoaderGetImageAddress (ImageContext), FUNCTION_ENTRY_POINT (UefiImageLoaderGetImageEntryPoint (ImageContext)))); DEBUG ((DEBUG_LOAD | DEBUG_INFO, "Loading driver at 0x%11p DebugBase=0x%11p EntryPoint=0x%11p\n", (VOID *)(UINTN)UefiImageLoaderGetImageAddress (ImageContext), (VOID *)(UINTN)UefiImageLoaderGetDebugAddress (ImageContext), FUNCTION_ENTRY_POINT (UefiImageLoaderGetImageEntryPoint (ImageContext))));
#endif #endif
} else { } else {
DEBUG ((DEBUG_LOAD | DEBUG_INFO, "Loading driver at 0x%11p EntryPoint=0x%11p\n", (VOID *)(UINTN)UefiImageLoaderGetImageAddress (ImageContext), FUNCTION_ENTRY_POINT (UefiImageLoaderGetImageEntryPoint (ImageContext)))); DEBUG ((DEBUG_LOAD | DEBUG_INFO, "Loading driver at 0x%11p DebugBase=0x%11p EntryPoint=0x%11p\n", (VOID *)(UINTN)UefiImageLoaderGetImageAddress (ImageContext), (VOID *)(UINTN)UefiImageLoaderGetDebugAddress (ImageContext), FUNCTION_ENTRY_POINT (UefiImageLoaderGetImageEntryPoint (ImageContext))));
} }
} }
@ -131,11 +131,11 @@ UefiImageLoaderUnloadImageExtraAction (
DEBUG ((DEBUG_LOAD | DEBUG_INFO, "unload symbols_only %a\n", DeCygwinPathIfNeeded (PdbPath, Temp, sizeof (Temp)))); DEBUG ((DEBUG_LOAD | DEBUG_INFO, "unload symbols_only %a\n", DeCygwinPathIfNeeded (PdbPath, Temp, sizeof (Temp))));
#elif __GNUC__ #elif __GNUC__
// This may not work correctly if you generate PE/COFF directly as then the Offset would not be required // This may not work correctly if you generate PE/COFF directly as then the Offset would not be required
DEBUG ((DEBUG_LOAD | DEBUG_INFO, "remove-symbol-file %a 0x%08x\n", DeCygwinPathIfNeeded (PdbPath, Temp, sizeof (Temp)), (UINTN)UefiImageLoaderGetImageAddress (ImageContext))); DEBUG ((DEBUG_LOAD | DEBUG_INFO, "remove-symbol-file %a 0x%08x\n", DeCygwinPathIfNeeded (PdbPath, Temp, sizeof (Temp)), (UINTN)UefiImageLoaderGetDebugAddress (ImageContext)));
#else #else
DEBUG ((DEBUG_LOAD | DEBUG_INFO, "Unloading %a\n", PdbPath)); DEBUG ((DEBUG_LOAD | DEBUG_INFO, "Unloading %a\n", PdbPath));
#endif #endif
} else { } else {
DEBUG ((DEBUG_LOAD | DEBUG_INFO, "Unloading driver at 0x%11p\n", (VOID *)(UINTN)UefiImageLoaderGetImageAddress (ImageContext))); DEBUG ((DEBUG_LOAD | DEBUG_INFO, "Unloading driver at 0x%11p DebugBase=0x%11p\n", (VOID *)(UINTN)UefiImageLoaderGetImageAddress (ImageContext), (VOID *)(UINTN)UefiImageLoaderGetDebugAddress (ImageContext)));
} }
} }

View File

@ -39,7 +39,8 @@ STATIC BOOLEAN mRecursiveException;
CONST CHAR8 * CONST CHAR8 *
GetImageName ( GetImageName (
IN UINTN FaultAddress, IN UINTN FaultAddress,
OUT UINTN *ImageBase OUT UINTN *ImageBase,
OUT UINTN *DebugBase
); );
STATIC STATIC
@ -212,18 +213,20 @@ DefaultExceptionHandler (
DEBUG_CODE_BEGIN (); DEBUG_CODE_BEGIN ();
CONST CHAR8 *Pdb, *PrevPdb; CONST CHAR8 *Pdb, *PrevPdb;
UINTN ImageBase; UINTN ImageBase;
UINTN DebugBase;
UINT64 *Fp; UINT64 *Fp;
UINT64 RootFp[2]; UINT64 RootFp[2];
UINTN Idx; UINTN Idx;
PrevPdb = Pdb = GetImageName (SystemContext.SystemContextAArch64->ELR, &ImageBase); PrevPdb = Pdb = GetImageName (SystemContext.SystemContextAArch64->ELR, &ImageBase, &DebugBase);
if (Pdb != NULL) { if (Pdb != NULL) {
DEBUG (( DEBUG ((
DEBUG_ERROR, DEBUG_ERROR,
"PC 0x%012lx (0x%012lx+0x%08x) [ 0] %a\n", "PC 0x%012lx (0x%012lx+0x%08x) (DebugBase=%012lx) [ 0] %a\n",
SystemContext.SystemContextAArch64->ELR, SystemContext.SystemContextAArch64->ELR,
ImageBase, ImageBase,
SystemContext.SystemContextAArch64->ELR - ImageBase, SystemContext.SystemContextAArch64->ELR - ImageBase,
DebugBase,
BaseName (Pdb) BaseName (Pdb)
)); ));
} else { } else {
@ -241,7 +244,7 @@ DefaultExceptionHandler (
} }
for (Fp = RootFp; Fp[0] != 0; Fp = (UINT64 *)Fp[0]) { for (Fp = RootFp; Fp[0] != 0; Fp = (UINT64 *)Fp[0]) {
Pdb = GetImageName (Fp[1], &ImageBase); Pdb = GetImageName (Fp[1], &ImageBase, &DebugBase);
if (Pdb != NULL) { if (Pdb != NULL) {
if (Pdb != PrevPdb) { if (Pdb != PrevPdb) {
Idx++; Idx++;
@ -250,10 +253,11 @@ DefaultExceptionHandler (
DEBUG (( DEBUG ((
DEBUG_ERROR, DEBUG_ERROR,
"PC 0x%012lx (0x%012lx+0x%08x) [% 2d] %a\n", "PC 0x%012lx (0x%012lx+0x%08x) (DebugBase=0x%012lx) [% 2d] %a\n",
Fp[1], Fp[1],
ImageBase, ImageBase,
Fp[1] - ImageBase, Fp[1] - ImageBase,
DebugBase,
Idx, Idx,
BaseName (Pdb) BaseName (Pdb)
)); ));
@ -262,14 +266,14 @@ DefaultExceptionHandler (
} }
} }
PrevPdb = Pdb = GetImageName (SystemContext.SystemContextAArch64->ELR, &ImageBase); PrevPdb = Pdb = GetImageName (SystemContext.SystemContextAArch64->ELR, &ImageBase, &DebugBase);
if (Pdb != NULL) { if (Pdb != NULL) {
DEBUG ((DEBUG_ERROR, "\n[ 0] %a\n", Pdb)); DEBUG ((DEBUG_ERROR, "\n[ 0] %a\n", Pdb));
} }
Idx = 0; Idx = 0;
for (Fp = RootFp; Fp[0] != 0; Fp = (UINT64 *)Fp[0]) { for (Fp = RootFp; Fp[0] != 0; Fp = (UINT64 *)Fp[0]) {
Pdb = GetImageName (Fp[1], &ImageBase); Pdb = GetImageName (Fp[1], &ImageBase, &DebugBase);
if ((Pdb != NULL) && (Pdb != PrevPdb)) { if ((Pdb != NULL) && (Pdb != PrevPdb)) {
DEBUG ((DEBUG_ERROR, "[% 2d] %a\n", ++Idx, Pdb)); DEBUG ((DEBUG_ERROR, "[% 2d] %a\n", ++Idx, Pdb));
PrevPdb = Pdb; PrevPdb = Pdb;

View File

@ -56,7 +56,8 @@ STATIC CONST CPSR_CHAR mCpsrChar[] = {
CONST CHAR8 * CONST CHAR8 *
GetImageName ( GetImageName (
IN UINTN FaultAddress, IN UINTN FaultAddress,
OUT UINTN *ImageBase OUT UINTN *ImageBase,
OUT UINTN *DebugBase
); );
/** /**
@ -229,6 +230,7 @@ DefaultExceptionHandler (
DEBUG_CODE_BEGIN (); DEBUG_CODE_BEGIN ();
CONST CHAR8 *Pdb; CONST CHAR8 *Pdb;
UINT32 ImageBase; UINT32 ImageBase;
UINT32 DebugBase;
UINT32 Offset; UINT32 Offset;
CHAR8 CpsrStr[CPSR_STRING_SIZE]; // char per bit. Lower 5-bits are mode CHAR8 CpsrStr[CPSR_STRING_SIZE]; // char per bit. Lower 5-bits are mode
// that is a 3 char string // that is a 3 char string
@ -239,7 +241,7 @@ DefaultExceptionHandler (
CpsrString (SystemContext.SystemContextArm->CPSR, CpsrStr); CpsrString (SystemContext.SystemContextArm->CPSR, CpsrStr);
DEBUG ((DEBUG_ERROR, "%a\n", CpsrStr)); DEBUG ((DEBUG_ERROR, "%a\n", CpsrStr));
Pdb = GetImageName (SystemContext.SystemContextArm->PC, &ImageBase); Pdb = GetImageName (SystemContext.SystemContextArm->PC, &ImageBase, &DebugBase);
Offset = SystemContext.SystemContextArm->PC - ImageBase; Offset = SystemContext.SystemContextArm->PC - ImageBase;
if (Pdb != NULL) { if (Pdb != NULL) {
DEBUG ((DEBUG_ERROR, "%a\n", Pdb)); DEBUG ((DEBUG_ERROR, "%a\n", Pdb));
@ -254,7 +256,7 @@ DefaultExceptionHandler (
// //
// FIXME: Used to have (ELF or Mach-O offset) 0x%x // FIXME: Used to have (ELF or Mach-O offset) 0x%x
// Substitute with .text address (better + may be needed for GDB symbols?) // Substitute with .text address (better + may be needed for GDB symbols?)
DEBUG ((EFI_D_ERROR, "loaded at 0x%08x (PE/COFF offset) 0x%x", ImageBase, Offset)); DEBUG ((EFI_D_ERROR, "loaded at 0x%08x (DebugBase=0x%08x) (PE/COFF offset) 0x%x", ImageBase, DebugBase, Offset));
// If we come from an image it is safe to show the instruction. We know it should not fault // If we come from an image it is safe to show the instruction. We know it should not fault
DisAsm = (UINT8 *)(UINTN)SystemContext.SystemContextArm->PC; DisAsm = (UINT8 *)(UINTN)SystemContext.SystemContextArm->PC;

View File

@ -19,6 +19,7 @@
@param FaultAddress Address to find PE/COFF image for. @param FaultAddress Address to find PE/COFF image for.
@param ImageBase Return load address of found image @param ImageBase Return load address of found image
@param ImageBase Return debug address of found image
@retval NULL FaultAddress not in a loaded PE/COFF image. @retval NULL FaultAddress not in a loaded PE/COFF image.
@retval Path and file name of PE/COFF image. @retval Path and file name of PE/COFF image.
@ -27,7 +28,8 @@
CONST CHAR8 * CONST CHAR8 *
GetImageName ( GetImageName (
IN UINTN FaultAddress, IN UINTN FaultAddress,
OUT UINTN *ImageBase OUT UINTN *ImageBase,
OUT UINTN *DebugBase
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
@ -48,15 +50,16 @@ GetImageName (
Address = (CHAR8 *)(UINTN)FaultAddress; Address = (CHAR8 *)(UINTN)FaultAddress;
for (Entry = 0; Entry < DebugTableHeader->TableSize; Entry++, DebugTable++) { for (Entry = 0; Entry < DebugTableHeader->TableSize; Entry++, DebugTable++) {
if (DebugTable->NormalImage != NULL) { if (DebugTable->NormalImage2 != NULL) {
if ((DebugTable->NormalImage->ImageInfoType == EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL) && if ((DebugTable->NormalImage2->ImageInfoType == EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL2) &&
(DebugTable->NormalImage->LoadedImageProtocolInstance != NULL)) (DebugTable->NormalImage2->LoadedImageProtocolInstance != NULL))
{ {
if ((Address >= (CHAR8 *)DebugTable->NormalImage->LoadedImageProtocolInstance->ImageBase) && if ((Address >= (CHAR8 *)DebugTable->NormalImage2->LoadedImageProtocolInstance->ImageBase) &&
(Address <= ((CHAR8 *)DebugTable->NormalImage->LoadedImageProtocolInstance->ImageBase + DebugTable->NormalImage->LoadedImageProtocolInstance->ImageSize))) (Address <= ((CHAR8 *)DebugTable->NormalImage2->LoadedImageProtocolInstance->ImageBase + DebugTable->NormalImage2->LoadedImageProtocolInstance->ImageSize)))
{ {
*ImageBase = (UINTN)DebugTable->NormalImage->LoadedImageProtocolInstance->ImageBase; *ImageBase = (UINTN)DebugTable->NormalImage2->LoadedImageProtocolInstance->ImageBase;
return DebugTable->NormalImage->PdbPath; *DebugBase = (UINTN)DebugTable->NormalImage2->DebugBase;
return DebugTable->NormalImage2->PdbPath;
} }
} }
} }

View File

@ -32,12 +32,12 @@ typedef struct {
EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY Nb10; EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY Nb10;
} image_tool_debug_dir_t; } image_tool_debug_dir_t;
#define SIZE_OF_DATA_DIRECRORY \ #define SIZE_OF_DATA_DIRECTORY \
EFI_IMAGE_NUMBER_OF_DIRECTORY_ENTRIES * sizeof (EFI_IMAGE_DATA_DIRECTORY) EFI_IMAGE_NUMBER_OF_DIRECTORY_ENTRIES * sizeof (EFI_IMAGE_DATA_DIRECTORY)
#define SIZE_OF_OPTIONAL_HEADER \ #define SIZE_OF_OPTIONAL_HEADER \
sizeof (EFI_IMAGE_NT_HEADERS) - sizeof (EFI_IMAGE_NT_HEADERS_COMMON_HDR) \ sizeof (EFI_IMAGE_NT_HEADERS) - sizeof (EFI_IMAGE_NT_HEADERS_COMMON_HDR) \
+ SIZE_OF_DATA_DIRECRORY + SIZE_OF_DATA_DIRECTORY
static static
bool bool
@ -581,7 +581,7 @@ ToolImageEmitPeFile (
return false; return false;
} }
SectionHeadersOffset = sizeof (*PeHdr) + SIZE_OF_DATA_DIRECRORY; SectionHeadersOffset = sizeof (*PeHdr) + SIZE_OF_DATA_DIRECTORY;
SectionHeadersSize = NumSections * sizeof (EFI_IMAGE_SECTION_HEADER); SectionHeadersSize = NumSections * sizeof (EFI_IMAGE_SECTION_HEADER);
SizeOfPeHeaders = SectionHeadersOffset + SectionHeadersSize; SizeOfPeHeaders = SectionHeadersOffset + SectionHeadersSize;
SizeOfHeaders = sizeof (mDosHdr) + SizeOfPeHeaders; SizeOfHeaders = sizeof (mDosHdr) + SizeOfPeHeaders;

View File

@ -873,10 +873,10 @@ QxferLibrary (
if (gDebugTable != NULL) { if (gDebugTable != NULL) {
for ( ; gEfiDebugImageTableEntry < gDebugImageTableHeader->TableSize; gEfiDebugImageTableEntry++, gDebugTable++) { for ( ; gEfiDebugImageTableEntry < gDebugImageTableHeader->TableSize; gEfiDebugImageTableEntry++, gDebugTable++) {
if (gDebugTable->NormalImage != NULL) { if (gDebugTable->NormalImage2 != NULL) {
if ((gDebugTable->NormalImage->ImageInfoType == EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL) && if ((gDebugTable->NormalImage2->ImageInfoType == EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL2) &&
(gDebugTable->NormalImage->LoadedImageProtocolInstance != NULL)) { (gDebugTable->NormalImage2->LoadedImageProtocolInstance != NULL)) {
Pdb = gDebugTable->NormalImage->PdbPath; Pdb = gDebugTable->NormalImage2->PdbPath;
if (Pdb != NULL) { if (Pdb != NULL) {
Size = AsciiSPrint ( Size = AsciiSPrint (
gXferLibraryBuffer, gXferLibraryBuffer,

View File

@ -892,15 +892,17 @@ PrintLoadAddress (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
fprintf ( fprintf (
stderr, stderr,
"0x%08lx Loading NO DEBUG with entry point 0x%08lx\n", "0x%08lx (0x%08lx) Loading NO DEBUG with entry point 0x%08lx\n",
(unsigned long) UefiImageLoaderGetImageAddress (ImageContext), (unsigned long) UefiImageLoaderGetImageAddress (ImageContext),
(unsigned long) UefiImageLoaderGetDebugAddress (ImageContext),
(unsigned long) UefiImageLoaderGetImageEntryPoint (ImageContext) (unsigned long) UefiImageLoaderGetImageEntryPoint (ImageContext)
); );
} else { } else {
fprintf ( fprintf (
stderr, stderr,
"0x%08lx Loading %s with entry point 0x%08lx\n", "0x%08lx (0x%08lx) Loading %s with entry point 0x%08lx\n",
(unsigned long) UefiImageLoaderGetImageAddress (ImageContext), (unsigned long) UefiImageLoaderGetImageAddress (ImageContext),
(unsigned long) UefiImageLoaderGetDebugAddress (ImageContext),
PdbPath, PdbPath,
(unsigned long) UefiImageLoaderGetImageEntryPoint (ImageContext) (unsigned long) UefiImageLoaderGetImageEntryPoint (ImageContext)
); );
@ -952,7 +954,7 @@ GdbScriptAddImage (
if (FeaturePcdGet (PcdEmulatorLazyLoadSymbols)) { if (FeaturePcdGet (PcdEmulatorLazyLoadSymbols)) {
GdbTempFile = fopen (gGdbWorkingFileName, "a"); GdbTempFile = fopen (gGdbWorkingFileName, "a");
if (GdbTempFile != NULL) { if (GdbTempFile != NULL) {
long unsigned int SymbolsAddr = (long unsigned int)UefiImageLoaderGetImageAddress (ImageContext); long unsigned int SymbolsAddr = (long unsigned int)UefiImageLoaderGetDebugAddress (ImageContext);
mScriptSymbolChangesCount++; mScriptSymbolChangesCount++;
fprintf ( fprintf (
GdbTempFile, GdbTempFile,
@ -963,7 +965,7 @@ GdbScriptAddImage (
); );
fclose (GdbTempFile); fclose (GdbTempFile);
// This is for the lldb breakpoint only // This is for the lldb breakpoint only
SecGdbScriptBreak (PdbPath, PdbPathSize, (long unsigned int)UefiImageLoaderGetImageAddress (ImageContext), 1); SecGdbScriptBreak (PdbPath, PdbPathSize, (long unsigned int)UefiImageLoaderGetDebugAddress (ImageContext), 1);
} else { } else {
ASSERT (FALSE); ASSERT (FALSE);
} }
@ -974,7 +976,7 @@ GdbScriptAddImage (
GdbTempFile, GdbTempFile,
"add-symbol-file %s -o 0x%08lx\n", "add-symbol-file %s -o 0x%08lx\n",
PdbPath, PdbPath,
(long unsigned int)UefiImageLoaderGetImageAddress (ImageContext) (long unsigned int)UefiImageLoaderGetDebugAddress (ImageContext)
); );
fclose (GdbTempFile); fclose (GdbTempFile);
@ -984,7 +986,7 @@ GdbScriptAddImage (
// Also used for the lldb breakpoint script. The lldb breakpoint script does // Also used for the lldb breakpoint script. The lldb breakpoint script does
// not use the file, it uses the arguments. // not use the file, it uses the arguments.
// //
SecGdbScriptBreak (PdbPath, PdbPathSize, (long unsigned int)UefiImageLoaderGetImageAddress (ImageContext), 1); SecGdbScriptBreak (PdbPath, PdbPathSize, (long unsigned int)UefiImageLoaderGetDebugAddress (ImageContext), 1);
} else { } else {
ASSERT (FALSE); ASSERT (FALSE);
} }

View File

@ -452,6 +452,7 @@ DumpMemoryProfileDriverInfo (
} }
Print (L" ImageBase - 0x%016lx\n", DriverInfo->ImageBase); Print (L" ImageBase - 0x%016lx\n", DriverInfo->ImageBase);
Print (L" DebugBase - 0x%016lx\n", DriverInfo->DebugBase);
Print (L" ImageSize - 0x%016lx\n", DriverInfo->ImageSize); Print (L" ImageSize - 0x%016lx\n", DriverInfo->ImageSize);
Print (L" EntryPoint - 0x%016lx\n", DriverInfo->EntryPoint); Print (L" EntryPoint - 0x%016lx\n", DriverInfo->EntryPoint);
Print (L" ImageSubsystem - 0x%04x (%a)\n", DriverInfo->ImageSubsystem, mSubsystemString[(DriverInfo->ImageSubsystem < sizeof (mSubsystemString)/sizeof (mSubsystemString[0])) ? DriverInfo->ImageSubsystem : 0]); Print (L" ImageSubsystem - 0x%04x (%a)\n", DriverInfo->ImageSubsystem, mSubsystemString[(DriverInfo->ImageSubsystem < sizeof (mSubsystemString)/sizeof (mSubsystemString[0])) ? DriverInfo->ImageSubsystem : 0]);
@ -947,7 +948,11 @@ DumpContextSummaryData (
} }
if (DriverInfo->PdbStringOffset != 0) { if (DriverInfo->PdbStringOffset != 0) {
Print (L" (Pdb - %a)\n", (CHAR8 *)((UINTN)DriverInfo + DriverInfo->PdbStringOffset)); Print (
L" (DebugBase - 0x%016lx, Pdb - %a)\n",
(UINT64)DriverInfo->DebugBase,
(CHAR8 *)((UINTN)DriverInfo + DriverInfo->PdbStringOffset)
);
} else { } else {
Print (L"\n"); Print (L"\n");
} }

View File

@ -2367,20 +2367,19 @@ CoreUpdateDebugTableCrc32 (
/** /**
Adds a new DebugImageInfo structure to the DebugImageInfo Table. Re-Allocates Adds a new DebugImageInfo structure to the DebugImageInfo Table. Re-Allocates
the table if it's not large enough to accomidate another entry. the table if it's not large enough to accommodate another entry.
@param ImageInfoType type of debug image information
@param LoadedImage pointer to the loaded image protocol for the image being @param LoadedImage pointer to the loaded image protocol for the image being
loaded loaded
@param ImageHandle image handle for the image being loaded @param ImageHandle image handle for the image being loaded
@param ImageContext image context for the image being loaded
**/ **/
VOID VOID
CoreNewDebugImageInfoEntry ( CoreNewDebugImageInfoEntry (
IN UINT32 ImageInfoType, IN EFI_LOADED_IMAGE_PROTOCOL *LoadedImage,
IN EFI_LOADED_IMAGE_PROTOCOL *LoadedImage, IN EFI_HANDLE ImageHandle,
IN EFI_HANDLE ImageHandle, IN CONST UEFI_IMAGE_LOADER_IMAGE_CONTEXT *ImageContext
IN UEFI_IMAGE_LOADER_IMAGE_CONTEXT *ImageContext
); );
/** /**

View File

@ -388,7 +388,6 @@ DxeMain (
// //
CoreInitializeDebugImageInfoTable (); CoreInitializeDebugImageInfoTable ();
CoreNewDebugImageInfoEntry ( CoreNewDebugImageInfoEntry (
EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL,
gDxeCoreLoadedImage, gDxeCoreLoadedImage,
gImageHandle, gImageHandle,
&ImageContext &ImageContext

View File

@ -1343,7 +1343,7 @@ CoreLoadImageCommon (
// Register the image in the Debug Image Info Table if the attribute is set // 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) { 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);
} }
// //

View File

@ -315,6 +315,7 @@ BuildDriverInfo (
} }
DriverInfo->ImageBase = UefiImageLoaderGetImageAddress (ImageContext); DriverInfo->ImageBase = UefiImageLoaderGetImageAddress (ImageContext);
DriverInfo->DebugBase = UefiImageLoaderGetDebugAddress (ImageContext);
DriverInfo->ImageSize = UefiImageGetImageSize (ImageContext); DriverInfo->ImageSize = UefiImageGetImageSize (ImageContext);
DriverInfo->EntryPoint = UefiImageLoaderGetImageEntryPoint (ImageContext); DriverInfo->EntryPoint = UefiImageLoaderGetImageEntryPoint (ImageContext);
DriverInfo->ImageSubsystem = UefiImageGetSubsystem (ImageContext); DriverInfo->ImageSubsystem = UefiImageGetSubsystem (ImageContext);

View File

@ -150,30 +150,29 @@ CoreUpdateDebugTableCrc32 (
/** /**
Adds a new DebugImageInfo structure to the DebugImageInfo Table. Re-Allocates Adds a new DebugImageInfo structure to the DebugImageInfo Table. Re-Allocates
the table if it's not large enough to accomidate another entry. the table if it's not large enough to accommodate another entry.
@param ImageInfoType type of debug image information
@param LoadedImage pointer to the loaded image protocol for the image being @param LoadedImage pointer to the loaded image protocol for the image being
loaded loaded
@param ImageHandle image handle for the image being loaded @param ImageHandle image handle for the image being loaded
@param ImageContext image context for the image being loaded
**/ **/
VOID VOID
CoreNewDebugImageInfoEntry ( CoreNewDebugImageInfoEntry (
IN UINT32 ImageInfoType, IN EFI_LOADED_IMAGE_PROTOCOL *LoadedImage,
IN EFI_LOADED_IMAGE_PROTOCOL *LoadedImage, IN EFI_HANDLE ImageHandle,
IN EFI_HANDLE ImageHandle, IN CONST UEFI_IMAGE_LOADER_IMAGE_CONTEXT *ImageContext
IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *ImageContext
) )
{ {
EFI_DEBUG_IMAGE_INFO *Table; EFI_DEBUG_IMAGE_INFO *Table;
EFI_DEBUG_IMAGE_INFO *NewTable; EFI_DEBUG_IMAGE_INFO *NewTable;
UINTN Index; UINTN Index;
UINTN TableSize; UINTN TableSize;
EFI_DEBUG_IMAGE_INFO_NORMAL *NormalImage; EFI_DEBUG_IMAGE_INFO_NORMAL2 *NormalImage2;
RETURN_STATUS Status; RETURN_STATUS Status;
CONST CHAR8 *PdbPath; CONST CHAR8 *PdbPath;
UINT32 PdbPathSize; UINT32 PdbPathSize;
// //
// Set the flag indicating that we're in the process of updating the table. // 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. // We still have empty entires in the Table, find the first empty entry.
// //
Index = 0; Index = 0;
while (Table[Index].NormalImage != NULL) { while (Table[Index].NormalImage2 != NULL) {
Index++; Index++;
} }
@ -232,24 +231,26 @@ CoreNewDebugImageInfoEntry (
// //
// Allocate data for new entry // Allocate data for new entry
// //
NormalImage = AllocateZeroPool (sizeof (EFI_DEBUG_IMAGE_INFO_NORMAL)); NormalImage2 = AllocateZeroPool (sizeof (EFI_DEBUG_IMAGE_INFO_NORMAL2));
if (NormalImage != NULL) { if (NormalImage2 != NULL) {
// //
// Update the entry // Update the entry
// //
NormalImage->ImageInfoType = (UINT32)ImageInfoType; NormalImage2->ImageInfoType = EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL2;
NormalImage->LoadedImageProtocolInstance = LoadedImage; NormalImage2->LoadedImageProtocolInstance = LoadedImage;
NormalImage->ImageHandle = ImageHandle; NormalImage2->ImageHandle = ImageHandle;
Status = UefiImageGetSymbolsPath (ImageContext, &PdbPath, &PdbPathSize); Status = UefiImageGetSymbolsPath (ImageContext, &PdbPath, &PdbPathSize);
if (!RETURN_ERROR (Status)) { if (!RETURN_ERROR (Status)) {
NormalImage->PdbPath = AllocateCopyPool (PdbPathSize, PdbPath); NormalImage2->PdbPath = AllocateCopyPool (PdbPathSize, PdbPath);
} }
NormalImage2->DebugBase = UefiImageLoaderGetDebugAddress (ImageContext);
// //
// Increase the number of EFI_DEBUG_IMAGE_INFO elements and set the mDebugInfoTable in modified status. // Increase the number of EFI_DEBUG_IMAGE_INFO elements and set the mDebugInfoTable in modified status.
// //
mDebugInfoTableHeader.UpdateStatus |= EFI_DEBUG_IMAGE_INFO_TABLE_MODIFIED; mDebugInfoTableHeader.UpdateStatus |= EFI_DEBUG_IMAGE_INFO_TABLE_MODIFIED;
Table[Index].NormalImage = NormalImage; Table[Index].NormalImage2 = NormalImage2;
mDebugInfoTableHeader.TableSize++; mDebugInfoTableHeader.TableSize++;
} }
@ -267,34 +268,42 @@ CoreRemoveDebugImageInfoEntry (
EFI_HANDLE ImageHandle EFI_HANDLE ImageHandle
) )
{ {
EFI_DEBUG_IMAGE_INFO *Table; EFI_DEBUG_IMAGE_INFO *Table;
UINTN Index; UINTN Index;
EFI_DEBUG_IMAGE_INFO_NORMAL *NormalImage; EFI_DEBUG_IMAGE_INFO_NORMAL2 *NormalImage2;
mDebugInfoTableHeader.UpdateStatus |= EFI_DEBUG_IMAGE_INFO_UPDATE_IN_PROGRESS; mDebugInfoTableHeader.UpdateStatus |= EFI_DEBUG_IMAGE_INFO_UPDATE_IN_PROGRESS;
Table = mDebugInfoTableHeader.EfiDebugImageInfoTable; Table = mDebugInfoTableHeader.EfiDebugImageInfoTable;
for (Index = 0; Index < mMaxTableEntries; Index++) { for (Index = 0; Index < mMaxTableEntries; Index++) {
if ((Table[Index].NormalImage != NULL) && (Table[Index].NormalImage->ImageHandle == ImageHandle)) { if (Table[Index].NormalImage2 != NULL) {
// if (*Table[Index].ImageInfoType != EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL2)
// Found a match. Free up the record, then NULL the pointer to indicate the slot {
// is free. ASSERT (FALSE);
// continue;
NormalImage = Table[Index].NormalImage;
//
// 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;
if (NormalImage->PdbPath != NULL) {
FreePool (NormalImage->PdbPath);
} }
CoreFreePool (NormalImage); if (Table[Index].NormalImage2->ImageHandle == ImageHandle) {
break; //
// Found a match. Free up the record, then NULL the pointer to indicate the slot
// is free.
//
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].NormalImage2 = NULL;
if (NormalImage2->PdbPath != NULL) {
FreePool (NormalImage2->PdbPath);
}
CoreFreePool (NormalImage2);
break;
}
} }
} }

View File

@ -158,7 +158,8 @@ LoadAndRelocateUefiImage (
IN VOID *Pe32Data, IN VOID *Pe32Data,
IN UINT32 Pe32DataSize, IN UINT32 Pe32DataSize,
OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *ImageContext, OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *ImageContext,
OUT EFI_PHYSICAL_ADDRESS *ImageAddress OUT EFI_PHYSICAL_ADDRESS *ImageAddress,
OUT UINTN *DebugBase
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
@ -339,6 +340,7 @@ LoadAndRelocateUefiImage (
} }
*ImageAddress = UefiImageLoaderGetImageAddress (ImageContext); *ImageAddress = UefiImageLoaderGetImageAddress (ImageContext);
*DebugBase = UefiImageLoaderGetDebugAddress (ImageContext);
return ReturnStatus; return ReturnStatus;
} }
@ -457,6 +459,7 @@ PeiLoadImageLoadImage (
VOID *Pe32Data; VOID *Pe32Data;
UINT32 Pe32DataSize; UINT32 Pe32DataSize;
EFI_PHYSICAL_ADDRESS ImageAddress; EFI_PHYSICAL_ADDRESS ImageAddress;
UINTN DebugBase;
UEFI_IMAGE_LOADER_IMAGE_CONTEXT ImageContext; UEFI_IMAGE_LOADER_IMAGE_CONTEXT ImageContext;
*EntryPoint = 0; *EntryPoint = 0;
@ -491,7 +494,8 @@ PeiLoadImageLoadImage (
Pe32Data, Pe32Data,
Pe32DataSize, Pe32DataSize,
&ImageContext, &ImageContext,
&ImageAddress &ImageAddress,
&DebugBase
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
@ -521,12 +525,12 @@ PeiLoadImageLoadImage (
// Print debug message: Loading PEIM at 0x12345678 EntryPoint=0x12345688 Driver.efi // Print debug message: Loading PEIM at 0x12345678 EntryPoint=0x12345688 Driver.efi
// //
if (Machine != EFI_IMAGE_MACHINE_IA64) { if (Machine != EFI_IMAGE_MACHINE_IA64) {
DEBUG ((DEBUG_INFO | DEBUG_LOAD, "Loading PEIM at 0x%11p EntryPoint=0x%11p ", (VOID *)(UINTN)ImageAddress, (VOID *)(UINTN)*EntryPoint)); DEBUG ((DEBUG_INFO | DEBUG_LOAD, "Loading PEIM at 0x%11p DebugBase=0x%11p EntryPoint=0x%11p ", (VOID *)(UINTN)ImageAddress, (VOID *)(UINTN)DebugBase, (VOID *)(UINTN)*EntryPoint));
} else { } else {
// //
// For IPF Image, the real entry point should be print. // For IPF Image, the real entry point should be print.
// //
DEBUG ((DEBUG_INFO | DEBUG_LOAD, "Loading PEIM at 0x%11p EntryPoint=0x%11p ", (VOID *)(UINTN)ImageAddress, (VOID *)(UINTN)(*(UINT64 *)(UINTN)*EntryPoint))); DEBUG ((DEBUG_INFO | DEBUG_LOAD, "Loading PEIM at 0x%11p DebugBase=0x%11p EntryPoint=0x%11p ", (VOID *)(UINTN)ImageAddress, (VOID *)(UINTN)DebugBase, (VOID *)(UINTN)(*(UINT64 *)(UINTN)*EntryPoint)));
} }
// //

View File

@ -49,30 +49,29 @@ SmmInitializeDebugImageInfoTable (
/** /**
Adds a new DebugImageInfo structure to the DebugImageInfo Table. Re-Allocates Adds a new DebugImageInfo structure to the DebugImageInfo Table. Re-Allocates
the table if it's not large enough to accomidate another entry. the table if it's not large enough to accommodate another entry.
@param ImageInfoType type of debug image information
@param LoadedImage pointer to the loaded image protocol for the image being @param LoadedImage pointer to the loaded image protocol for the image being
loaded loaded
@param ImageHandle image handle for the image being loaded @param ImageHandle image handle for the image being loaded
@param ImageContext image context for the image being loaded
**/ **/
VOID VOID
SmmNewDebugImageInfoEntry ( SmmNewDebugImageInfoEntry (
IN UINT32 ImageInfoType, IN EFI_LOADED_IMAGE_PROTOCOL *LoadedImage,
IN EFI_LOADED_IMAGE_PROTOCOL *LoadedImage, IN EFI_HANDLE ImageHandle,
IN EFI_HANDLE ImageHandle, IN CONST UEFI_IMAGE_LOADER_IMAGE_CONTEXT *ImageContext
IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *ImageContext
) )
{ {
EFI_DEBUG_IMAGE_INFO *Table; EFI_DEBUG_IMAGE_INFO *Table;
EFI_DEBUG_IMAGE_INFO *NewTable; EFI_DEBUG_IMAGE_INFO *NewTable;
UINTN Index; UINTN Index;
UINTN TableSize; UINTN TableSize;
EFI_DEBUG_IMAGE_INFO_NORMAL *NormalImage; EFI_DEBUG_IMAGE_INFO_NORMAL2 *NormalImage2;
RETURN_STATUS Status; RETURN_STATUS Status;
CONST CHAR8 *PdbPath; CONST CHAR8 *PdbPath;
UINT32 PdbPathSize; UINT32 PdbPathSize;
// //
// Set the flag indicating that we're in the process of updating the table. // Set the flag indicating that we're in the process of updating the table.
@ -86,7 +85,7 @@ SmmNewDebugImageInfoEntry (
// We still have empty entires in the Table, find the first empty entry. // We still have empty entires in the Table, find the first empty entry.
// //
Index = 0; Index = 0;
while (Table[Index].NormalImage != NULL) { while (Table[Index].NormalImage2 != NULL) {
Index++; Index++;
} }
// //
@ -129,24 +128,26 @@ SmmNewDebugImageInfoEntry (
// //
// Allocate data for new entry // Allocate data for new entry
// //
NormalImage = AllocateZeroPool (sizeof (EFI_DEBUG_IMAGE_INFO_NORMAL)); NormalImage2 = AllocateZeroPool (sizeof (EFI_DEBUG_IMAGE_INFO_NORMAL2));
if (NormalImage != NULL) { if (NormalImage2 != NULL) {
// //
// Update the entry // Update the entry
// //
NormalImage->ImageInfoType = (UINT32) ImageInfoType; NormalImage2->ImageInfoType = EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL2;
NormalImage->LoadedImageProtocolInstance = LoadedImage; NormalImage2->LoadedImageProtocolInstance = LoadedImage;
NormalImage->ImageHandle = ImageHandle; NormalImage2->ImageHandle = ImageHandle;
Status = UefiImageGetSymbolsPath (ImageContext, &PdbPath, &PdbPathSize); Status = UefiImageGetSymbolsPath (ImageContext, &PdbPath, &PdbPathSize);
if (!RETURN_ERROR (Status)) { if (!RETURN_ERROR (Status)) {
NormalImage->PdbPath = AllocateCopyPool (PdbPathSize, PdbPath); NormalImage2->PdbPath = AllocateCopyPool (PdbPathSize, PdbPath);
} }
NormalImage2->DebugBase = UefiImageLoaderGetDebugAddress (ImageContext);
// //
// Increase the number of EFI_DEBUG_IMAGE_INFO elements and set the mDebugInfoTable in modified status. // Increase the number of EFI_DEBUG_IMAGE_INFO elements and set the mDebugInfoTable in modified status.
// //
mDebugInfoTableHeader.UpdateStatus |= EFI_DEBUG_IMAGE_INFO_TABLE_MODIFIED; mDebugInfoTableHeader.UpdateStatus |= EFI_DEBUG_IMAGE_INFO_TABLE_MODIFIED;
Table[Index].NormalImage = NormalImage; Table[Index].NormalImage2 = NormalImage2;
mDebugInfoTableHeader.TableSize++; mDebugInfoTableHeader.TableSize++;
} }
mDebugInfoTableHeader.UpdateStatus &= ~EFI_DEBUG_IMAGE_INFO_UPDATE_IN_PROGRESS; mDebugInfoTableHeader.UpdateStatus &= ~EFI_DEBUG_IMAGE_INFO_UPDATE_IN_PROGRESS;

View File

@ -571,7 +571,6 @@ SmmLoadImage (
// Register the image in the Debug Image Info Table if the attribute is set // Register the image in the Debug Image Info Table if the attribute is set
// //
SmmNewDebugImageInfoEntry ( SmmNewDebugImageInfoEntry (
EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL,
&DriverEntry->SmmLoadedImage, &DriverEntry->SmmLoadedImage,
DriverEntry->SmmImageHandle, DriverEntry->SmmImageHandle,
ImageContext ImageContext

View File

@ -876,7 +876,6 @@ SmmCoreInstallLoadedImage (
// //
SmmInitializeDebugImageInfoTable (); SmmInitializeDebugImageInfoTable ();
SmmNewDebugImageInfoEntry ( SmmNewDebugImageInfoEntry (
EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL,
&mSmmCoreDriverEntry->SmmLoadedImage, &mSmmCoreDriverEntry->SmmLoadedImage,
mSmmCoreDriverEntry->SmmImageHandle, mSmmCoreDriverEntry->SmmImageHandle,
&gSmmCorePrivate->PiSmmCoreImageContext &gSmmCorePrivate->PiSmmCoreImageContext

View File

@ -1374,20 +1374,19 @@ SmmInitializeDebugImageInfoTable (
/** /**
Adds a new DebugImageInfo structure to the DebugImageInfo Table. Re-Allocates Adds a new DebugImageInfo structure to the DebugImageInfo Table. Re-Allocates
the table if it's not large enough to accomidate another entry. the table if it's not large enough to accommodate another entry.
@param ImageInfoType type of debug image information
@param LoadedImage pointer to the loaded image protocol for the image being @param LoadedImage pointer to the loaded image protocol for the image being
loaded loaded
@param ImageHandle image handle for the image being loaded @param ImageHandle image handle for the image being loaded
@param ImageContext image context for the image being loaded
**/ **/
VOID VOID
SmmNewDebugImageInfoEntry ( SmmNewDebugImageInfoEntry (
IN UINT32 ImageInfoType, IN EFI_LOADED_IMAGE_PROTOCOL *LoadedImage,
IN EFI_LOADED_IMAGE_PROTOCOL *LoadedImage, IN EFI_HANDLE ImageHandle,
IN EFI_HANDLE ImageHandle, IN CONST UEFI_IMAGE_LOADER_IMAGE_CONTEXT *ImageContext
IN UEFI_IMAGE_LOADER_IMAGE_CONTEXT *ImageContext
); );
/** /**

View File

@ -984,6 +984,7 @@ ExecuteSmmCoreFromSmram (
UINTN PageCount; UINTN PageCount;
EFI_IMAGE_ENTRY_POINT EntryPoint; EFI_IMAGE_ENTRY_POINT EntryPoint;
EFI_PHYSICAL_ADDRESS LoadAddress; EFI_PHYSICAL_ADDRESS LoadAddress;
UINTN DebugBase;
// //
// Search all Firmware Volumes for a PE/COFF image in a file of type SMM_CORE // Search all Firmware Volumes for a PE/COFF image in a file of type SMM_CORE
@ -1106,6 +1107,7 @@ ExecuteSmmCoreFromSmram (
Status = UefiImageLoadImageForExecution (&gSmmCorePrivate->PiSmmCoreImageContext, (VOID *)(UINTN)LoadAddress, DestinationSize, NULL, 0); Status = UefiImageLoadImageForExecution (&gSmmCorePrivate->PiSmmCoreImageContext, (VOID *)(UINTN)LoadAddress, DestinationSize, NULL, 0);
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
LoadAddress = UefiImageLoaderGetImageAddress (&gSmmCorePrivate->PiSmmCoreImageContext); LoadAddress = UefiImageLoaderGetImageAddress (&gSmmCorePrivate->PiSmmCoreImageContext);
DebugBase = UefiImageLoaderGetDebugAddress (&gSmmCorePrivate->PiSmmCoreImageContext);
// //
// Print debug message showing SMM Core entry point address. // Print debug message showing SMM Core entry point address.
// //
@ -1113,6 +1115,7 @@ ExecuteSmmCoreFromSmram (
gSmmCorePrivate->PiSmmCoreImageBase = LoadAddress; gSmmCorePrivate->PiSmmCoreImageBase = LoadAddress;
DEBUG ((DEBUG_INFO, "PiSmmCoreImageBase - 0x%016lx\n", gSmmCorePrivate->PiSmmCoreImageBase)); DEBUG ((DEBUG_INFO, "PiSmmCoreImageBase - 0x%016lx\n", gSmmCorePrivate->PiSmmCoreImageBase));
DEBUG ((DEBUG_INFO, "PiSmmCoreDebugBase - 0x%016lx\n", DebugBase));
DEBUG ((DEBUG_INFO, "PiSmmCoreImageSize - 0x%016lx\n", UefiImageGetImageSize (&gSmmCorePrivate->PiSmmCoreImageContext))); DEBUG ((DEBUG_INFO, "PiSmmCoreImageSize - 0x%016lx\n", UefiImageGetImageSize (&gSmmCorePrivate->PiSmmCoreImageContext)));
// //

View File

@ -267,7 +267,6 @@ BuildDriverInfo (
IN MEMORY_PROFILE_CONTEXT_DATA *ContextData, IN MEMORY_PROFILE_CONTEXT_DATA *ContextData,
IN EFI_GUID *FileName, IN EFI_GUID *FileName,
IN UEFI_IMAGE_LOADER_IMAGE_CONTEXT *ImageContext, IN UEFI_IMAGE_LOADER_IMAGE_CONTEXT *ImageContext,
IN EFI_PHYSICAL_ADDRESS LoadAddress,
IN EFI_FV_FILETYPE FileType IN EFI_FV_FILETYPE FileType
) )
{ {
@ -313,7 +312,8 @@ BuildDriverInfo (
CopyMem (&DriverInfo->FileName, FileName, sizeof (EFI_GUID)); CopyMem (&DriverInfo->FileName, FileName, sizeof (EFI_GUID));
} }
DriverInfo->ImageBase = LoadAddress; DriverInfo->ImageBase = UefiImageLoaderGetImageAddress (ImageContext);
DriverInfo->DebugBase = UefiImageLoaderGetDebugAddress (ImageContext);
DriverInfo->ImageSize = UefiImageGetImageSize (ImageContext); DriverInfo->ImageSize = UefiImageGetImageSize (ImageContext);
DriverInfo->EntryPoint = UefiImageLoaderGetImageEntryPoint (ImageContext); DriverInfo->EntryPoint = UefiImageLoaderGetImageEntryPoint (ImageContext);
DriverInfo->ImageSubsystem = UefiImageGetSubsystem (ImageContext); DriverInfo->ImageSubsystem = UefiImageGetSubsystem (ImageContext);
@ -505,7 +505,6 @@ RegisterSmmCore (
ContextData, ContextData,
&gEfiCallerIdGuid, &gEfiCallerIdGuid,
&gSmmCorePrivate->PiSmmCoreImageContext, &gSmmCorePrivate->PiSmmCoreImageContext,
gSmmCorePrivate->PiSmmCoreImageBase,
EFI_FV_FILETYPE_SMM_CORE EFI_FV_FILETYPE_SMM_CORE
); );
if (DriverInfoData == NULL) { if (DriverInfoData == NULL) {
@ -668,7 +667,6 @@ RegisterSmramProfileImage (
ContextData, ContextData,
FileName, FileName,
ImageContext, ImageContext,
UefiImageLoaderGetImageAddress (ImageContext),
EFI_FV_FILETYPE_SMM EFI_FV_FILETYPE_SMM
); );
if (DriverInfoData == NULL) { if (DriverInfoData == NULL) {

View File

@ -58,6 +58,8 @@ typedef struct {
UINT64 PeakUsageByType[EfiMaxMemoryType + 2]; UINT64 PeakUsageByType[EfiMaxMemoryType + 2];
UINT16 PdbStringOffset; UINT16 PdbStringOffset;
UINT8 Reserved2[6]; UINT8 Reserved2[6];
// FIXME: Changes struct layout.
UINT64 DebugBase;
// CHAR8 PdbString[]; // CHAR8 PdbString[];
} MEMORY_PROFILE_DRIVER_INFO; } MEMORY_PROFILE_DRIVER_INFO;

View File

@ -949,15 +949,15 @@ EdbPatchSymbolRVA (
CandidateImageBase = NULL; CandidateImageBase = NULL;
ImageTable = mDebuggerPrivate.DebugImageInfoTableHeader->EfiDebugImageInfoTable; ImageTable = mDebuggerPrivate.DebugImageInfoTableHeader->EfiDebugImageInfoTable;
for (ImageNumber = 0; ImageNumber < mDebuggerPrivate.DebugImageInfoTableHeader->TableSize; ImageNumber++) { for (ImageNumber = 0; ImageNumber < mDebuggerPrivate.DebugImageInfoTableHeader->TableSize; ImageNumber++) {
if (ImageTable[ImageNumber].NormalImage == NULL) { if (ImageTable[ImageNumber].NormalImage2 == NULL) {
continue; continue;
} }
ImageBase = ImageTable[ImageNumber].NormalImage->LoadedImageProtocolInstance->ImageBase; ImageBase = ImageTable[ImageNumber].NormalImage2->LoadedImageProtocolInstance->ImageBase;
// //
// Get PDB path // Get PDB path
// //
PdbPath = ImageTable[ImageNumber].NormalImage->PdbPath; PdbPath = ImageTable[ImageNumber].NormalImage2->PdbPath;
if (PdbPath == NULL) { if (PdbPath == NULL) {
continue; continue;
} }

View File

@ -25,7 +25,8 @@
#define EFI_DEBUG_IMAGE_INFO_UPDATE_IN_PROGRESS 0x01 #define EFI_DEBUG_IMAGE_INFO_UPDATE_IN_PROGRESS 0x01
#define EFI_DEBUG_IMAGE_INFO_TABLE_MODIFIED 0x02 #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 { typedef struct {
UINT64 Signature; ///< A constant UINT64 that has the value EFI_SYSTEM_TABLE_SIGNATURE UINT64 Signature; ///< A constant UINT64 that has the value EFI_SYSTEM_TABLE_SIGNATURE
@ -35,8 +36,8 @@ typedef struct {
typedef struct { typedef struct {
/// ///
/// Indicates the type of image info structure. For PE32 EFI images, /// When this debug image info structure is present, ImageInfoType is set
/// this is set to EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL. /// to EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL indicating a loaded PE32 EFI image.
/// ///
UINT32 ImageInfoType; UINT32 ImageInfoType;
/// ///
@ -47,12 +48,50 @@ typedef struct {
/// Indicates the image handle of the associated image. /// Indicates the image handle of the associated image.
/// ///
EFI_HANDLE ImageHandle; EFI_HANDLE ImageHandle;
CHAR8 *PdbPath;
} EFI_DEBUG_IMAGE_INFO_NORMAL; } 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;
///
/// 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 { 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; } EFI_DEBUG_IMAGE_INFO;
typedef struct { typedef struct {

View File

@ -234,7 +234,7 @@ typedef struct {
UINT64 SizeOfHeapCommit; UINT64 SizeOfHeapCommit;
UINT32 LoaderFlags; UINT32 LoaderFlags;
UINT32 NumberOfRvaAndSizes; UINT32 NumberOfRvaAndSizes;
EFI_IMAGE_DATA_DIRECTORY DataDirectory[EFI_IMAGE_NUMBER_OF_DIRECTORY_ENTRIES]; EFI_IMAGE_DATA_DIRECTORY DataDirectory[EFI_IMAGE_NUMBER_OF_DIRECTORY_ENTRIES];
} EFI_IMAGE_OPTIONAL_HEADER64; } EFI_IMAGE_OPTIONAL_HEADER64;

View File

@ -650,4 +650,9 @@ UefiImageDebugPrintImageRecord (
IN CONST UEFI_IMAGE_RECORD *ImageRecord IN CONST UEFI_IMAGE_RECORD *ImageRecord
); );
UINTN
UefiImageLoaderGetDebugAddress (
IN CONST UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context
);
#endif // UEFI_IMAGE_LIB_H_ #endif // UEFI_IMAGE_LIB_H_

View File

@ -236,6 +236,14 @@ UefiImageLoaderGetImageAddressPe (
return PeCoffLoaderGetImageAddress (&Context->Ctx.Pe); return PeCoffLoaderGetImageAddress (&Context->Ctx.Pe);
} }
UINTN
UefiImageLoaderGetDebugAddressPe (
IN CONST UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context
)
{
return PeCoffLoaderGetImageAddress (&Context->Ctx.Pe);
}
/** /**
Retrieves the memory protection attributes corresponding to PE/COFF Image Retrieves the memory protection attributes corresponding to PE/COFF Image
section permissions. section permissions.
@ -750,6 +758,7 @@ GLOBAL_REMOVE_IF_UNREFERENCED CONST UEFI_IMAGE_FORMAT_SUPPORT mPeSupport = {
UefiImageGetBaseAddressPe, UefiImageGetBaseAddressPe,
UefiImageGetRelocsStrippedPe, UefiImageGetRelocsStrippedPe,
UefiImageLoaderGetImageAddressPe, UefiImageLoaderGetImageAddressPe,
UefiImageLoaderGetDebugAddressPe,
UefiImageLoaderGetImageRecordPe, UefiImageLoaderGetImageRecordPe,
UefiImageDebugLocateImagePe, UefiImageDebugLocateImagePe,
UefiImageGetFixedAddressPe, UefiImageGetFixedAddressPe,

View File

@ -176,6 +176,12 @@ UINTN
IN CONST UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context IN CONST UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context
); );
typedef
UINTN
(*UEFI_IMAGE_LOADER_GET_DEBUG_ADDRESS) (
IN CONST UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context
);
typedef typedef
UEFI_IMAGE_RECORD * UEFI_IMAGE_RECORD *
(*UEFI_IMAGE_LOADER_GET_IMAGE_RECORD) ( (*UEFI_IMAGE_LOADER_GET_IMAGE_RECORD) (
@ -226,6 +232,7 @@ typedef struct {
UEFI_IMAGE_GET_BASE_ADDRESS GetBaseAddress; UEFI_IMAGE_GET_BASE_ADDRESS GetBaseAddress;
UEFI_IMAGE_GET_RELOCS_STRIPPED GetRelocsStripped; UEFI_IMAGE_GET_RELOCS_STRIPPED GetRelocsStripped;
UEFI_IMAGE_LOADER_GET_IMAGE_ADDRESS LoaderGetImageAddress; UEFI_IMAGE_LOADER_GET_IMAGE_ADDRESS LoaderGetImageAddress;
UEFI_IMAGE_LOADER_GET_DEBUG_ADDRESS LoaderGetDebugAddress;
UEFI_IMAGE_LOADER_GET_IMAGE_RECORD LoaderGetImageRecord; UEFI_IMAGE_LOADER_GET_IMAGE_RECORD LoaderGetImageRecord;
UEFI_IMAGE_DEBUG_LOCATE_IMAGE DebugLocateImage; UEFI_IMAGE_DEBUG_LOCATE_IMAGE DebugLocateImage;
UEFI_IMAGE_GET_FIXED_ADDRESS GetFixedAddress; UEFI_IMAGE_GET_FIXED_ADDRESS GetFixedAddress;

View File

@ -565,6 +565,23 @@ UefiImageLoaderGetImageAddress (
return Result; return Result;
} }
UINTN
UefiImageLoaderGetDebugAddress (
IN CONST UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context
)
{
UINTN Result;
UEFI_IMAGE_EXEC (
Result,
Context->FormatIndex,
LoaderGetDebugAddress,
Context
);
return Result;
}
UEFI_IMAGE_RECORD * UEFI_IMAGE_RECORD *
UefiImageLoaderGetImageRecord ( UefiImageLoaderGetImageRecord (
IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context IN OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context

View File

@ -211,11 +211,11 @@ GetImagePdb (
} }
for (Entry = 0; Entry < DebugTableHeader->TableSize; Entry++, DebugTable++) { for (Entry = 0; Entry < DebugTableHeader->TableSize; Entry++, DebugTable++) {
if (DebugTable->NormalImage != NULL) { if (DebugTable->NormalImage2 != NULL) {
if ((DebugTable->NormalImage->ImageInfoType == EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL) && if ((DebugTable->NormalImage2->ImageInfoType == EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL2) &&
(DebugTable->NormalImage->LoadedImageProtocolInstance != NULL)) { (DebugTable->NormalImage2->LoadedImageProtocolInstance != NULL)) {
if (ImageBase == DebugTable->NormalImage->LoadedImageProtocolInstance->ImageBase) { if (ImageBase == DebugTable->NormalImage2->LoadedImageProtocolInstance->ImageBase) {
return DebugTable->NormalImage->PdbPath; return DebugTable->NormalImage2->PdbPath;
} }
} }
} }

View File

@ -66,7 +66,7 @@ UefiImageLoaderExtraActionCommon (
RETURN_STATUS Status; RETURN_STATUS Status;
CONST CHAR8 *PdbPath; CONST CHAR8 *PdbPath;
UINT32 PdbPathSize; UINT32 PdbPathSize;
EFI_PHYSICAL_ADDRESS ImageBase; EFI_PHYSICAL_ADDRESS DebugBase;
ASSERT (ImageContext != NULL); ASSERT (ImageContext != NULL);
@ -111,7 +111,7 @@ UefiImageLoaderExtraActionCommon (
} }
} }
ImageBase = UefiImageLoaderGetImageAddress (ImageContext); DebugBase = UefiImageLoaderGetDebugAddress (ImageContext);
// //
// Save Debug Register State // Save Debug Register State
@ -126,7 +126,7 @@ UefiImageLoaderExtraActionCommon (
// //
// DR0 = Signature // DR0 = Signature
// DR1 = The address of the Null-terminated ASCII string for the PE/COFF image's PDB file name // DR1 = The address of the Null-terminated ASCII string for the PE/COFF image's PDB file name
// DR2 = The pointer to the ImageBase address // DR2 = The pointer to the DebugBase address
// DR3 = IO_PORT_BREAKPOINT_ADDRESS // DR3 = IO_PORT_BREAKPOINT_ADDRESS
// DR7 = Disables all HW breakpoints except for DR3 I/O port access of length 1 byte // DR7 = Disables all HW breakpoints except for DR3 I/O port access of length 1 byte
// CR4 = Make sure DE(BIT3) is set // CR4 = Make sure DE(BIT3) is set
@ -134,7 +134,7 @@ UefiImageLoaderExtraActionCommon (
AsmWriteDr7 (BIT10); AsmWriteDr7 (BIT10);
AsmWriteDr0 (Signature); AsmWriteDr0 (Signature);
AsmWriteDr1 ((UINTN)PdbPath); AsmWriteDr1 ((UINTN)PdbPath);
AsmWriteDr2 ((UINTN)&ImageBase); AsmWriteDr2 ((UINTN)&DebugBase);
AsmWriteDr3 (IO_PORT_BREAKPOINT_ADDRESS); AsmWriteDr3 (IO_PORT_BREAKPOINT_ADDRESS);
if (LoadImageMethod == DEBUG_LOAD_IMAGE_METHOD_IO_HW_BREAKPOINT) { if (LoadImageMethod == DEBUG_LOAD_IMAGE_METHOD_IO_HW_BREAKPOINT) {
@ -172,7 +172,7 @@ UefiImageLoaderExtraActionCommon (
AsmWriteDr1 (Dr1); AsmWriteDr1 (Dr1);
} }
if (!IsDrxEnabled (2, NewDr7) && (AsmReadDr2 () == (UINTN)&ImageBase)) { if (!IsDrxEnabled (2, NewDr7) && (AsmReadDr2 () == (UINTN)&DebugBase)) {
AsmWriteDr2 (Dr2); AsmWriteDr2 (Dr2);
} }

View File

@ -120,9 +120,10 @@ DumpModuleImageInfo (
{ {
BOOLEAN Result; BOOLEAN Result;
UINTN ImageBase; UINTN ImageBase;
UINTN DebugBase;
CONST CHAR8 *PdbPath; CONST CHAR8 *PdbPath;
Result = GetImageInfoByIp (&ImageBase, &PdbPath, CurrentEip); Result = GetImageInfoByIp (&ImageBase, &DebugBase, &PdbPath, CurrentEip);
if (!Result) { if (!Result) {
InternalPrintMessage ("!!!! Can't find image information. !!!!\n"); InternalPrintMessage ("!!!! Can't find image information. !!!!\n");
@ -139,8 +140,9 @@ DumpModuleImageInfo (
} }
InternalPrintMessage ( InternalPrintMessage (
" (ImageBase=%016lp) !!!!\n", " (ImageBase=%016lp, DebugBase=%016lp) !!!!\n",
(EFI_PHYSICAL_ADDRESS) ImageBase (EFI_PHYSICAL_ADDRESS) ImageBase,
(EFI_PHYSICAL_ADDRESS) DebugBase
); );
} }
} }

View File

@ -327,6 +327,7 @@ AsmGetTssTemplateMap (
BOOLEAN BOOLEAN
GetImageInfoByIp ( GetImageInfoByIp (
OUT UINTN *ImageBase, OUT UINTN *ImageBase,
OUT UINTN *DebugBase,
OUT CONST CHAR8 **SymbolsPath, OUT CONST CHAR8 **SymbolsPath,
IN UINTN CurrentEip IN UINTN CurrentEip
); );

View File

@ -143,13 +143,14 @@ InitializeSeparateExceptionStacks (
BOOLEAN BOOLEAN
GetImageInfoByIp ( GetImageInfoByIp (
OUT UINTN *ImageBase, OUT UINTN *ImageBase,
OUT UINTN *DebugBase,
OUT CONST CHAR8 **SymbolsPath, OUT CONST CHAR8 **SymbolsPath,
IN UINTN CurrentEip IN UINTN CurrentEip
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
UINT32 Index; UINT32 Index;
CONST EFI_DEBUG_IMAGE_INFO_NORMAL *NormalImage; CONST EFI_DEBUG_IMAGE_INFO_NORMAL2 *NormalImage2;
if (mDebugImageInfoTable == NULL) { if (mDebugImageInfoTable == NULL) {
Status = EfiGetSystemConfigurationTable ( Status = EfiGetSystemConfigurationTable (
@ -169,18 +170,19 @@ GetImageInfoByIp (
continue; continue;
} }
if (*mDebugImageInfoTable->EfiDebugImageInfoTable[Index].ImageInfoType != EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL) { if (*mDebugImageInfoTable->EfiDebugImageInfoTable[Index].ImageInfoType != EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL2) {
continue; 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 && if (CurrentEip >= (UINTN) NormalImage2->LoadedImageProtocolInstance->ImageBase &&
CurrentEip < (UINTN) NormalImage->LoadedImageProtocolInstance->ImageBase + NormalImage->LoadedImageProtocolInstance->ImageSize) { CurrentEip < (UINTN) NormalImage2->LoadedImageProtocolInstance->ImageBase + NormalImage2->LoadedImageProtocolInstance->ImageSize) {
*ImageBase = (UINTN) NormalImage->LoadedImageProtocolInstance->ImageBase; *ImageBase = (UINTN) NormalImage2->LoadedImageProtocolInstance->ImageBase;
*SymbolsPath = NormalImage->PdbPath; *DebugBase = NormalImage2->DebugBase;
*SymbolsPath = NormalImage2->PdbPath;
return TRUE; return TRUE;
} }
} }

View File

@ -218,6 +218,7 @@ InitializeSeparateExceptionStacks (
BOOLEAN BOOLEAN
GetImageInfoByIp ( GetImageInfoByIp (
OUT UINTN *ImageBase, OUT UINTN *ImageBase,
OUT UINTN *DebugBase,
OUT CONST CHAR8 **SymbolsPath, OUT CONST CHAR8 **SymbolsPath,
IN UINTN CurrentEip IN UINTN CurrentEip
) )
@ -232,6 +233,7 @@ GetImageInfoByIp (
} }
*ImageBase = UefiImageLoaderGetImageAddress (&ImageContext); *ImageBase = UefiImageLoaderGetImageAddress (&ImageContext);
*DebugBase = UefiImageLoaderGetDebugAddress (&ImageContext);
Status = UefiImageGetSymbolsPath (&ImageContext, SymbolsPath, &PdbPathSize); Status = UefiImageGetSymbolsPath (&ImageContext, SymbolsPath, &PdbPathSize);
return !RETURN_ERROR (Status); return !RETURN_ERROR (Status);

View File

@ -226,6 +226,7 @@ InitializeSeparateExceptionStacks (
BOOLEAN BOOLEAN
GetImageInfoByIp ( GetImageInfoByIp (
OUT UINTN *ImageBase, OUT UINTN *ImageBase,
OUT UINTN *DebugBase,
OUT CONST CHAR8 **SymbolsPath, OUT CONST CHAR8 **SymbolsPath,
IN UINTN CurrentEip IN UINTN CurrentEip
) )

View File

@ -150,13 +150,14 @@ InternalGetSystemConfigurationTable (
BOOLEAN BOOLEAN
GetImageInfoByIp ( GetImageInfoByIp (
OUT UINTN *ImageBase, OUT UINTN *ImageBase,
OUT UINTN *DebugBase,
OUT CONST CHAR8 **SymbolsPath, OUT CONST CHAR8 **SymbolsPath,
IN UINTN CurrentEip IN UINTN CurrentEip
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
UINT32 Index; UINT32 Index;
CONST EFI_DEBUG_IMAGE_INFO_NORMAL *NormalImage; CONST EFI_DEBUG_IMAGE_INFO_NORMAL2 *NormalImage2;
if (mDebugImageInfoTableHeader == NULL) { if (mDebugImageInfoTableHeader == NULL) {
Status = InternalGetSystemConfigurationTable ( Status = InternalGetSystemConfigurationTable (
@ -176,18 +177,19 @@ GetImageInfoByIp (
continue; continue;
} }
if (*mDebugImageInfoTableHeader->EfiDebugImageInfoTable[Index].ImageInfoType != EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL) { if (*mDebugImageInfoTableHeader->EfiDebugImageInfoTable[Index].ImageInfoType != EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL2) {
continue; 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 && if (CurrentEip >= (UINTN) NormalImage2->LoadedImageProtocolInstance->ImageBase &&
CurrentEip < (UINTN) NormalImage->LoadedImageProtocolInstance->ImageBase + NormalImage->LoadedImageProtocolInstance->ImageSize) { CurrentEip < (UINTN) NormalImage2->LoadedImageProtocolInstance->ImageBase + NormalImage2->LoadedImageProtocolInstance->ImageSize) {
*ImageBase = (UINTN) NormalImage->LoadedImageProtocolInstance->ImageBase; *ImageBase = (UINTN) NormalImage2->LoadedImageProtocolInstance->ImageBase;
*SymbolsPath = NormalImage->PdbPath; *DebugBase = NormalImage2->DebugBase;
*SymbolsPath = NormalImage2->PdbPath;
return TRUE; return TRUE;
} }
} }

View File

@ -197,14 +197,14 @@ SmmGetSystemConfigurationTable (
CONST EFI_DEBUG_IMAGE_INFO_TABLE_HEADER *mDebugImageInfoTableHeader = NULL; CONST EFI_DEBUG_IMAGE_INFO_TABLE_HEADER *mDebugImageInfoTableHeader = NULL;
// FIXME: // FIXME:
CONST EFI_DEBUG_IMAGE_INFO_NORMAL * CONST EFI_DEBUG_IMAGE_INFO_NORMAL2 *
InternalLocateImage ( InternalLocateImage (
IN UINTN CurrentEip IN UINTN CurrentEip
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
UINT32 Index; UINT32 Index;
CONST EFI_DEBUG_IMAGE_INFO_NORMAL *NormalImage; CONST EFI_DEBUG_IMAGE_INFO_NORMAL2 *NormalImage2;
if (mDebugImageInfoTableHeader == NULL) { if (mDebugImageInfoTableHeader == NULL) {
Status = SmmGetSystemConfigurationTable ( Status = SmmGetSystemConfigurationTable (
@ -224,17 +224,17 @@ InternalLocateImage (
continue; continue;
} }
if (*mDebugImageInfoTableHeader->EfiDebugImageInfoTable[Index].ImageInfoType != EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL) { if (*mDebugImageInfoTableHeader->EfiDebugImageInfoTable[Index].ImageInfoType != EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL2) {
continue; 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 && if (CurrentEip >= (UINTN) NormalImage2->LoadedImageProtocolInstance->ImageBase &&
CurrentEip < (UINTN) NormalImage->LoadedImageProtocolInstance->ImageBase + NormalImage->LoadedImageProtocolInstance->ImageSize) { CurrentEip < (UINTN) NormalImage2->LoadedImageProtocolInstance->ImageBase + NormalImage2->LoadedImageProtocolInstance->ImageSize) {
return NormalImage; return NormalImage2;
} }
} }
@ -252,17 +252,17 @@ DumpModuleInfoByIp (
IN UINTN CallerIpAddress 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 // Find Image Base
// //
if (NormalImage != NULL) { if (NormalImage2 != NULL) {
DEBUG ((DEBUG_ERROR, "It is invoked from the instruction before IP(0x%p)", (VOID *)CallerIpAddress)); DEBUG ((DEBUG_ERROR, "It is invoked from the instruction before IP(0x%p)", (VOID *)CallerIpAddress));
if (NormalImage->PdbPath!= NULL) { if (NormalImage2->PdbPath!= NULL) {
DEBUG ((DEBUG_ERROR, " in module (%a)\n", NormalImage->PdbPath)); DEBUG ((DEBUG_ERROR, " in module (%a)\n", NormalImage2->PdbPath));
} }
} }
} }