From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ed1-f44.google.com (mail-ed1-f44.google.com [209.85.208.44]) by mx.groups.io with SMTP id smtpd.web10.17075.1686832814356203190 for ; Thu, 15 Jun 2023 05:40:14 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="signature has expired" header.i=@gmail.com header.s=20221208 header.b=E0w1H3BH; spf=pass (domain: gmail.com, ip: 209.85.208.44, mailfrom: rafaelrodrigues.machado@gmail.com) Received: by mail-ed1-f44.google.com with SMTP id 4fb4d7f45d1cf-5183075a5ecso1537072a12.0 for ; Thu, 15 Jun 2023 05:40:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1686832812; x=1689424812; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=kbBj4usewd8S9k8jcE08bAaFvAvUzHLlavNPDxsJLJo=; b=E0w1H3BHREoZrUvHyyMVt+Q/dbaSR9tjcdoR2+ATwUfNVvSw1pUUQn45BB9SQSmPpK 2scMUGHZ3zpwV+N7GtIxR8I77oGayxI6iYBealx4X4O6sAs/Z8IDumDQXgeAUh0XwWO0 tkNfK+8gvqMOPo8+c92PC5Cn9av2YDxc8nvnJzsNSyKnihvpZqIHD5cs3LDK0nBSDJ7n EomkoGhO9KhZdexTGTKCR/5lvNser1KQT5zlMyb7MTIR1Ya/s1uoWskDv/ZLOuxogEHI cVo7QJslbdNoXT9O75/iQVttRueVeEfG1Zvebmq/ghT69YtI2b5/q0+K21jr/Q9psEor E0ag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686832812; x=1689424812; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=kbBj4usewd8S9k8jcE08bAaFvAvUzHLlavNPDxsJLJo=; b=dQzkPOkpYHpyoSSvI9khDLlQCW/xBqWvDuv1M5vw93eFrXMEVdvZ20/xbHy1aVvRU9 /wKzfhoLEk4JBdfzOA1ZNHYPP3LX0MxNp69GlbiO1rInEqceSvzIgM/abSKJzMLi6qF6 /1cna4/VLXkKIPVGT2dpNkeIcJcvNzbFvLpEzvCL/Ad2gF5N6cnkw+41n3mVN+8WGQ1N rZm+2jo3rQLFX3RN2gRrNrZhLPEwEiu7kls2bPBSuKOsyzPM2+jMzREPkJ5PMV3vZPPe LivBPzNJYJ7AcJ3Ddpa/0SRX1sDau3wQNVrgk/bBkXc3uSymKky2xiTiXyFFJ4qQPbxa TrwA== X-Gm-Message-State: AC+VfDyW5CLkoHLlljrjZI3xDx8XjZtN75TpOhOSPoR9zWZe4aqr61nL VnEP8TZ37lErZEG6K0AaGBBtN1NiTKGI8d4Xmq2JRqZx84A= X-Google-Smtp-Source: ACHHUZ5FLL6FJWD0XM9FeaYp8U0RuI7b7V767/6dr4qPwYgvoqpviIh0QoqsTAzmabbstq1Tptv1tajViSBfcf3nslw= X-Received: by 2002:a05:6402:50ce:b0:514:a656:5411 with SMTP id h14-20020a05640250ce00b00514a6565411mr15201626edb.4.1686832812115; Thu, 15 Jun 2023 05:40:12 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: "Rafael Machado" Date: Thu, 15 Jun 2023 09:40:00 -0300 Message-ID: Subject: Re: [edk2-devel] enable MemoryProfile for uefi shell app To: devel@edk2.groups.io, xzavierpower@gmail.com Content-Type: multipart/alternative; boundary="0000000000008fc98105fe2a5ea1" --0000000000008fc98105fe2a5ea1 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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=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). Hope this can help. Thanks Rafael Em qua., 7 de jun. de 2023 =C3=A0s 11:34, M.T. esc= reveu: > Hello group > > I'm looking for some help with MemoryProfile to catch some memory leaks i= n > a custom uefi application. > > I followed the instructions found on: > https://github.com/tianocore/tianocore.github.io/wiki/Memory-leak-detecti= on-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 Memo= ry > 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 i= t > has not hence the leak. > > So my debug build has the following Libs: > > MemoryAllocationLib|MdeModulePkg/Library/UefiMemoryAllocationProfileLib/U= efiMemoryAllocationProfileLib.inf > > MemoryProfileLib|MdeModulePkg/Library/UefiMemoryAllocationProfileLib/Uefi= MemoryAllocationProfileLib.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 > > --0000000000008fc98105fe2a5ea1 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

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. d= e 2023 =C3=A0s 11:34, M.T. <xz= avierpower@gmail.com> escreveu:
Hello group

I= 9;m looking for some help with MemoryProfile 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 oth= er 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 Allocate* functions to make sure everyth= ing has been freed accordingly, I suspect it has not hence the leak.
<= div>
So my debug build has the following Libs:
Memo= ryAllocationLib|MdeModulePkg/Library/UefiMemoryAllocationProfileLib/UefiMem= oryAllocationProfileLib.inf
MemoryProfileLib|MdeModulePkg/Library/UefiMe= moryAllocationProfileLib/UefiMemoryAllocationProfileLib.inf
<= br>
PCDs are set like this:
gEfiMdeModulePkgTokenSpaceGuid.PcdMemoryProfilePro= pertyMask|0x1
gEfiMdeModulePkgTokenSpaceGuid.PcdMemo= ryProfileMemoryType|0x60
gEfiMdeModulePkgTokenSpaceG= uid.PcdMemoryProfileDriverPath|{0x04, 0x06, 0x14, 0x00, =C2=A00x83, 0xA5, 0= x04, 0x7C, 0x3E, 0x9E, 0x1C, 0x4F, 0xAD, 0x65, 0xE0, 0x52, 0x68, 0xD0, 0xB4= , 0xD1, 0x7F, 0xFF, 0x04, 0x00}

In Components I added:
MdeModulePkg/Application/MemoryProfileInfo/MemoryP= rofileInfo.inf
This a= lso 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
GetUe= fiMemoryProfileData - Not Found
SmramProfile: Locate SmmCommunication pr= otocol - Not Found
GetSmramProfileData - Not Found

Couple of quest= ions about this:
Is MemoryProfileInfo.efi supposed to be run afte= r my app exits?
Or is it more like a wrapper for my app (ie. valg= rind)?

The errors seem to indicate that the libs a= re still missing, are they supposed
to be linked into the OVMF im= age as well perhaps, or anywhere else aside for my app?

Appreciate any help, debugging third party libs has become a major he= adache and I hope
memoryProfiler can help with this.
Cheers
mt

--0000000000008fc98105fe2a5ea1--