I've done some experimentation on the memory logging and if possible it is very 
useful to have 4 stack frames (non-LTO)  as it is common for the 
MemoryAllocationLib to to call a sequence of Internal functions, so to find the 
calling spot in the driver you need 4 entries. 
For example:
FunctionThatAllocatePool()
AllocateZeroPool()
InternalAllocateZeroPool()
InternalAllocatePool()

I see that only RETURN_ADDRESS (0) is logged. 

MdeModulePkg/Core/Dxe/Mem/Page.c:1338:    CoreUpdateProfile 
((EFI_PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS (0), 
MemoryProfileActionAllocatePages, MemoryType, EFI_PAGES_TO_SIZE 
(NumberOfPages), (VOID *) (UINTN) *Memory);
MdeModulePkg/Core/Dxe/Mem/Page.c:1447:    CoreUpdateProfile 
((EFI_PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS (0), 
MemoryProfileActionFreePages, MemoryType, EFI_PAGES_TO_SIZE (NumberOfPages), 
(VOID *) (UINTN) Memory);
MdeModulePkg/Core/Dxe/Mem/Pool.c:279:    CoreUpdateProfile 
((EFI_PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS (0), 
MemoryProfileActionAllocatePool, PoolType, Size, *Buffer);
MdeModulePkg/Core/Dxe/Mem/Pool.c:508:    CoreUpdateProfile 
((EFI_PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS (0), 
MemoryProfileActionFreePool, PoolType, 0, Buffer);

On platforms that emit frame pointers you can do RETURN_ADDRESS (0), 
RETURN_ADDRESS (1), RETURN_ADDRESS (2), and RETURN_ADDRESS (3) and it is very 
useful to find the location of the allocation. Is it possible to log more data 
on platforms that can support it? Is there some alternate scheme that is planed 
to find the driver code calling the MemoryAllocationLib function?

Thanks,

Andrew Fish


_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to