* enable MemoryProfile for uefi shell app @ 2023-06-07 14:34 M.T. 2023-06-15 12:40 ` [edk2-devel] " Rafael Machado 0 siblings, 1 reply; 3+ messages in thread From: M.T. @ 2023-06-07 14:34 UTC (permalink / raw) To: edk2-devel-groups-io [-- Attachment #1: Type: text/plain, Size: 2193 bytes --] Hello group I'm looking for some help with MemoryProfile to catch some memory leaks in a custom uefi application. I followed the instructions found on: https://github.com/tianocore/tianocore.github.io/wiki/Memory-leak-detection-with-memory-profile-feature However I can't seem to get this to work, let me paint a more complete picture. My uefi app is standalone, it is not a part of any other package and has its own .dsc file and this is where I make all the changes to enable Memory Profiler. The memory I want to watch for is UEFI_APPLICATION, any calls to Allocate* functions to make sure everything has been freed accordingly, I suspect it has not hence the leak. So my debug build has the following Libs: MemoryAllocationLib|MdeModulePkg/Library/UefiMemoryAllocationProfileLib/UefiMemoryAllocationProfileLib.inf MemoryProfileLib|MdeModulePkg/Library/UefiMemoryAllocationProfileLib/UefiMemoryAllocationProfileLib.inf PCDs are set like this: gEfiMdeModulePkgTokenSpaceGuid.PcdMemoryProfilePropertyMask|0x1 gEfiMdeModulePkgTokenSpaceGuid.PcdMemoryProfileMemoryType|0x60 gEfiMdeModulePkgTokenSpaceGuid.PcdMemoryProfileDriverPath|{0x04, 0x06, 0x14, 0x00, 0x83, 0xA5, 0x04, 0x7C, 0x3E, 0x9E, 0x1C, 0x4F, 0xAD, 0x65, 0xE0, 0x52, 0x68, 0xD0, 0xB4, 0xD1, 0x7F, 0xFF, 0x04, 0x00} In Components I added: MdeModulePkg/Application/MemoryProfileInfo/MemoryProfileInfo.inf This also required that I add DxeServiceLib Everything builds without issues, my app runs as expected, however when I try to run MemoryProfileInfo.efi, I only get the following: UefiMemoryProfile: Locate MemoryProfile protocol - Not Found GetUefiMemoryProfileData - Not Found SmramProfile: Locate SmmCommunication protocol - Not Found GetSmramProfileData - Not Found Couple of questions about this: Is MemoryProfileInfo.efi supposed to be run after my app exits? Or is it more like a wrapper for my app (ie. valgrind)? The errors seem to indicate that the libs are still missing, are they supposed to be linked into the OVMF image as well perhaps, or anywhere else aside for my app? Appreciate any help, debugging third party libs has become a major headache and I hope memoryProfiler can help with this. Cheers mt [-- Attachment #2: Type: text/html, Size: 5117 bytes --] ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [edk2-devel] enable MemoryProfile for uefi shell app 2023-06-07 14:34 enable MemoryProfile for uefi shell app M.T. @ 2023-06-15 12:40 ` Rafael Machado 2024-08-14 18:40 ` M.T. 0 siblings, 1 reply; 3+ messages in thread From: Rafael Machado @ 2023-06-15 12:40 UTC (permalink / raw) To: devel, xzavierpower [-- Attachment #1: Type: text/plain, Size: 3149 bytes --] Hi MT Just to understand better. Do you have access to the BIOS code so you can compile the BIOS with support to MemoryProfile? As far as I can see it seems you have added the needed libraries to your .dsc file, but to make memoryprofile working you need to have a BIOS capable of doing that. At the BIOS you are running the required protocols are not detected, this indicates you don't have the BIOS code compiled with support to MemoryProfile. In case you don’t have access to a real BIOS code or CRB, maybe you can try using OVMF with MemoryProfile enabled (not sure if this already works, but it may be a way). Hope this can help. Thanks Rafael Em qua., 7 de jun. de 2023 às 11:34, M.T. <xzavierpower@gmail.com> escreveu: > Hello group > > I'm looking for some help with MemoryProfile to catch some memory leaks in > a custom uefi application. > > I followed the instructions found on: > https://github.com/tianocore/tianocore.github.io/wiki/Memory-leak-detection-with-memory-profile-feature > > However I can't seem to get this to work, let me paint a more complete > picture. > > My uefi app is standalone, it is not a part of any other package and has > its own .dsc file and this is where I make all the changes to enable Memory > Profiler. > The memory I want to watch for is UEFI_APPLICATION, any calls to Allocate* > functions to make sure everything has been freed accordingly, I suspect it > has not hence the leak. > > So my debug build has the following Libs: > > MemoryAllocationLib|MdeModulePkg/Library/UefiMemoryAllocationProfileLib/UefiMemoryAllocationProfileLib.inf > > MemoryProfileLib|MdeModulePkg/Library/UefiMemoryAllocationProfileLib/UefiMemoryAllocationProfileLib.inf > > PCDs are set like this: > gEfiMdeModulePkgTokenSpaceGuid.PcdMemoryProfilePropertyMask|0x1 > gEfiMdeModulePkgTokenSpaceGuid.PcdMemoryProfileMemoryType|0x60 > gEfiMdeModulePkgTokenSpaceGuid.PcdMemoryProfileDriverPath|{0x04, 0x06, > 0x14, 0x00, 0x83, 0xA5, 0x04, 0x7C, 0x3E, 0x9E, 0x1C, 0x4F, 0xAD, 0x65, > 0xE0, 0x52, 0x68, 0xD0, 0xB4, 0xD1, 0x7F, 0xFF, 0x04, 0x00} > > In Components I added: > MdeModulePkg/Application/MemoryProfileInfo/MemoryProfileInfo.inf > > This also required that I add DxeServiceLib > > Everything builds without issues, my app runs as expected, however when I > try to run > MemoryProfileInfo.efi, I only get the following: > UefiMemoryProfile: Locate MemoryProfile protocol - Not Found > GetUefiMemoryProfileData - Not Found > SmramProfile: Locate SmmCommunication protocol - Not Found > GetSmramProfileData - Not Found > > Couple of questions about this: > Is MemoryProfileInfo.efi supposed to be run after my app exits? > Or is it more like a wrapper for my app (ie. valgrind)? > > The errors seem to indicate that the libs are still missing, are they > supposed > to be linked into the OVMF image as well perhaps, or anywhere else aside > for my app? > > Appreciate any help, debugging third party libs has become a major > headache and I hope > memoryProfiler can help with this. > > Cheers > mt > > > > [-- Attachment #2: Type: text/html, Size: 7099 bytes --] ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [edk2-devel] enable MemoryProfile for uefi shell app 2023-06-15 12:40 ` [edk2-devel] " Rafael Machado @ 2024-08-14 18:40 ` M.T. 0 siblings, 0 replies; 3+ messages in thread From: M.T. @ 2024-08-14 18:40 UTC (permalink / raw) To: Rafael Rodrigues Machado; +Cc: devel [-- Attachment #1: Type: text/plain, Size: 5028 bytes --] Hello Rafael Apologies for the lack of response. Life had other plans for me, but I am getting back into the project, and am still wondering how to get this working. I took your advice on rebuilding the BIOS to include the protocols. First I grabbed the latest repo which is edk2-stable202405. I setup the build as normal and went through OvmfPkg/OvmfPkgX64.dsc, and added the memory profiler libs wherever it seemed necessary. At first the build complained a few times about the protocols not being supported in a few sections, so I removed those, and eventually got it to build. I'm able to startup the built image in qemu, and I can run MemoryProfileInfo.efi, and now it does not return any errors, but it also does not show any signs of running either. I tried running my utility prior to running MemoryProfileInfo.efi, and it still won't put anything out. Looking at MemoryProfileInfo.efi itself, I see it should print out some text as soon as it runs, or an error message, but neither is happening. I'm not sure what I'm doing wrong here, but I will keep tinkering with it to see if I can figure it out. One question comes to mind, am I replacing the UefiMemoryAllocationLib with UefiMemoryAllocationProfileLib, or just adding it in? Thank you M.T. On Thu, Jun 15, 2023 at 8:40 AM Rafael Rodrigues Machado < rafaelrodrigues.machado@gmail.com> wrote: > Hi MT > > > > Just to understand better. > > Do you have access to the BIOS code so you can compile the BIOS with > support to MemoryProfile? > > > > As far as I can see it seems you have added the needed libraries to your > .dsc file, but to make memoryprofile working you need to have a BIOS > capable of doing that. At the BIOS you are running the required protocols > are not detected, this indicates you don't have the BIOS code compiled with > support to MemoryProfile. > > > > In case you don’t have access to a real BIOS code or CRB, maybe you can > try using OVMF with MemoryProfile enabled (not sure if this already works, > but it may be a way). > > > > Hope this can help. > > Thanks > > Rafael > > Em qua., 7 de jun. de 2023 às 11:34, M.T. <xzavierpower@gmail.com> > escreveu: > >> Hello group >> >> I'm looking for some help with MemoryProfile to catch some memory leaks >> in a custom uefi application. >> >> I followed the instructions found on: >> https://github.com/tianocore/tianocore.github.io/wiki/Memory-leak-detection-with-memory-profile-feature >> >> However I can't seem to get this to work, let me paint a more complete >> picture. >> >> My uefi app is standalone, it is not a part of any other package and has >> its own .dsc file and this is where I make all the changes to enable Memory >> Profiler. >> The memory I want to watch for is UEFI_APPLICATION, any calls to >> Allocate* functions to make sure everything has been freed accordingly, I >> suspect it has not hence the leak. >> >> So my debug build has the following Libs: >> >> MemoryAllocationLib|MdeModulePkg/Library/UefiMemoryAllocationProfileLib/UefiMemoryAllocationProfileLib.inf >> >> MemoryProfileLib|MdeModulePkg/Library/UefiMemoryAllocationProfileLib/UefiMemoryAllocationProfileLib.inf >> >> PCDs are set like this: >> gEfiMdeModulePkgTokenSpaceGuid.PcdMemoryProfilePropertyMask|0x1 >> gEfiMdeModulePkgTokenSpaceGuid.PcdMemoryProfileMemoryType|0x60 >> gEfiMdeModulePkgTokenSpaceGuid.PcdMemoryProfileDriverPath|{0x04, 0x06, >> 0x14, 0x00, 0x83, 0xA5, 0x04, 0x7C, 0x3E, 0x9E, 0x1C, 0x4F, 0xAD, 0x65, >> 0xE0, 0x52, 0x68, 0xD0, 0xB4, 0xD1, 0x7F, 0xFF, 0x04, 0x00} >> >> In Components I added: >> MdeModulePkg/Application/MemoryProfileInfo/MemoryProfileInfo.inf >> >> This also required that I add DxeServiceLib >> >> Everything builds without issues, my app runs as expected, however when I >> try to run >> MemoryProfileInfo.efi, I only get the following: >> UefiMemoryProfile: Locate MemoryProfile protocol - Not Found >> GetUefiMemoryProfileData - Not Found >> SmramProfile: Locate SmmCommunication protocol - Not Found >> GetSmramProfileData - Not Found >> >> Couple of questions about this: >> Is MemoryProfileInfo.efi supposed to be run after my app exits? >> Or is it more like a wrapper for my app (ie. valgrind)? >> >> The errors seem to indicate that the libs are still missing, are they >> supposed >> to be linked into the OVMF image as well perhaps, or anywhere else aside >> for my app? >> >> Appreciate any help, debugging third party libs has become a major >> headache and I hope >> memoryProfiler can help with this. >> >> Cheers >> mt >> >> >> >> -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#120340): https://edk2.groups.io/g/devel/message/120340 Mute This Topic: https://groups.io/mt/99385913/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=- [-- Attachment #2: Type: text/html, Size: 9781 bytes --] ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-08-14 18:40 UTC | newest] Thread overview: 3+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2023-06-07 14:34 enable MemoryProfile for uefi shell app M.T. 2023-06-15 12:40 ` [edk2-devel] " Rafael Machado 2024-08-14 18:40 ` M.T.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox