From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail05.groups.io (mail05.groups.io [45.79.224.7]) by spool.mail.gandi.net (Postfix) with ESMTPS id 3CD44AC1857 for ; Wed, 14 Aug 2024 18:40:30 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=dAmBdGZVbRFSujlpNv4lTP0htuGibmwLWneHmOZ+ka8=; c=relaxed/simple; d=groups.io; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject:To:Cc:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Resent-Date:Resent-From:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Type; s=20240206; t=1723660830; v=1; b=EKXq9BGdGbKrNk1D3RvkKe3Z7S16pibSRxwStyzm+MXv09I3FlZsCrC90XKS22RK4BDjeEpn X9cvEHA/MHVJKdX02a2nHCpIHTOLLcXdnebFqnjplqwDgjaZAw1yFl61wt6qmsfLWiuuX9wgC27 bBrpzzVR/iX7ytUPu6zCAwcstF35Y2ThAC+izdTgw54KP6yqSHv6vxm2q84GkFMycfd1ULaqMME PQWv6787N+m7lmOnHtdoiMTzs8cJ23UKOff/I5oDjuMmWdm9o+wLftYqs7uqN45+0TttuTmOA1a IOCJiAG2dSgfYW06YgXxOTyjbkwQz1I77Ud2z8z9uOD+w== X-Received: by 127.0.0.2 with SMTP id klnvYY7687511xzM4JNRqt81; Wed, 14 Aug 2024 11:40:28 -0700 X-Received: from mail-ed1-f49.google.com (mail-ed1-f49.google.com [209.85.208.49]) by mx.groups.io with SMTP id smtpd.web11.105730.1723660827705754373 for ; Wed, 14 Aug 2024 11:40:28 -0700 X-Received: by mail-ed1-f49.google.com with SMTP id 4fb4d7f45d1cf-5a156557026so271126a12.2 for ; Wed, 14 Aug 2024 11:40:27 -0700 (PDT) X-Gm-Message-State: 29B0UlrDI8hCCt8lqmTsgE8gx7686176AA= X-Google-Smtp-Source: AGHT+IHvjgnoqvem8XASrm8fEmJSPDW7NjYDBN3fD9xWq3cEnfTT1rYggXEgZKo0BSK5htq66/IFyPDdkR2qHCydunQ= X-Received: by 2002:a17:907:c891:b0:a7a:bb54:c858 with SMTP id a640c23a62f3a-a8366d39467mr248693066b.26.1723660825759; Wed, 14 Aug 2024 11:40:25 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: "M.T." Date: Wed, 14 Aug 2024 14:40:14 -0400 Message-ID: Subject: Re: [edk2-devel] enable MemoryProfile for uefi shell app To: Rafael Rodrigues Machado Cc: devel@edk2.groups.io Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Resent-Date: Wed, 14 Aug 2024 11:40:28 -0700 Resent-From: xzavierpower@gmail.com Reply-To: devel@edk2.groups.io,xzavierpower@gmail.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Type: multipart/alternative; boundary="0000000000003b991d061fa90f36" X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20240206 header.b=EKXq9BGd; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 45.79.224.7 as permitted sender) smtp.mailfrom=bounce@groups.io --0000000000003b991d061fa90f36 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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=E2=80=AFAM 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 wi= th > support to MemoryProfile. > > > > In case you don=E2=80=99t have access to a real BIOS code or CRB, maybe y= ou 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 =C3=A0s 11:34, M.T. > 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-detect= ion-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 Mem= ory >> 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/Uef= iMemoryAllocationProfileLib.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 >> >>=20 >> >> -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- 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] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- --0000000000003b991d061fa90f36 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hello Rafael

Apologies for the lack of = response.=C2=A0 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=C2=A0edk2-stable202405.=
I setup the build as normal and went through=C2=A0OvmfPkg/OvmfPk= gX64.dsc, and added the memory profiler libs wherever it seemed necessary.<= /div>
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, bu= t it also does not show any signs of running either.
I tried runn= ing my utility prior to running MemoryProfileInfo.efi, and it still won'= ;t put anything out.
Looking at MemoryProfileInfo.efi itself, I s= ee it should print out some text as soon as it runs, or an error message, b= ut neither is happening.
I'm not sure what I'm doing wron= g 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 UefiM= emoryAllocationLib with UefiMemoryAllocationProfileLib, or just adding it i= n?

Thank you
M.T.


On= Thu, Jun 15, 2023 at 8:40=E2=80=AFAM Rafael Rodrigues Machado <rafaelrodrigues.machado@gmail= .com> wrote:

Hi MT

=C2=A0

Just to understand better.

Do you have access to the BIOS code so you can compile the BIOS with support to MemoryProfile?

=C2=A0

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=C2=A0the required protocols are not detec= ted, this indicates you don't have the BIOS code compiled with support = to MemoryProfile.

=C2=A0

In case you don=E2=80=99t 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).

=C2=A0

Hope this can help.

Thanks

Rafael


Em qua., 7 de jun. de 2023 =C3=A0s 11:34, M.T. <xzavierpower@gmail.com> escreve= u:
Hello group

I'm looking for some help with Memor= yProfile to catch some memory leaks in a custom uefi application.


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=C2=A0all the changes to enable Memory Profiler.
The memory I want to watch for is UEFI_APPLICATION, any calls to A= llocate* functions to make sure everything has been freed accordingly, I su= spect it has not hence the leak.

So my debug build= has the following Libs:
MemoryAllocationLib|MdeModulePkg/Library= /UefiMemoryAllocationProfileLib/UefiMemoryAllocationProfileLib.inf
Memor= yProfileLib|MdeModulePkg/Library/UefiMemoryAllocationProfileLib/UefiMemoryA= llocationProfileLib.inf

PCDs are set like this= :
gEfiMdeModu= lePkgTokenSpaceGuid.PcdMemoryProfilePropertyMask|0x1
gEfiMdeModulePkgTokenSpaceGuid.PcdMemoryProfileMemoryType|0x60
gEfiMdeModulePkgTokenSpaceGuid.PcdMemoryProfileDriverPath|{0x0= 4, 0x06, 0x14, 0x00, =C2=A00x83, 0xA5, 0x04, 0x7C, 0x3E, 0x9E, 0x1C, 0x4F, = 0xAD, 0x65, 0xE0, 0x52, 0x68, 0xD0, 0xB4, 0xD1, 0x7F, 0xFF, 0x04, 0x00}

In Components I added:
MdeModuleP= kg/Application/MemoryProfileInfo/MemoryProfileInfo.inf

This also required that I add DxeServiceL= ib

Everything builds = without issues, my app runs as expected, however when I try to run <= /div>
MemoryProfileInfo.ef= i, I only get the following:
UefiMemoryProfile: Locate Mem= oryProfile protocol - Not Found
GetUefiMemoryProfileData - Not Found
= SmramProfile: Locate SmmCommunication protocol - Not Found
GetSmramProfi= leData - Not Found
<= /div>

Couple of questions about this:
Is Memor= yProfileInfo.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 el= se aside for my app?

Appreciate any help, debuggin= g third party libs has become a major headache and I hope
memoryP= rofiler can help with this.

Cheers
mt

_._,_._,_

Groups.io Links:

=20 You receive all messages sent to this group. =20 =20

View/Reply Online (#120340) | =20 | Mute = This Topic | New Topic
Your Subscriptio= n | Contact Group Owner | Unsubscribe [rebecca@openfw.io]

_._,_._,_
--0000000000003b991d061fa90f36--