public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "M.T." <xzavierpower@gmail.com>
To: edk2-devel-groups-io <devel@edk2.groups.io>
Subject: enable MemoryProfile for uefi shell app
Date: Wed, 7 Jun 2023 10:34:24 -0400	[thread overview]
Message-ID: <CAEsd5RuM8+QZzHs4u_Z_EHi1BmY_cuOEDXYENooeVv8VL-QHhQ@mail.gmail.com> (raw)

[-- 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 --]

             reply	other threads:[~2023-06-07 14:34 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-07 14:34 M.T. [this message]
2023-06-15 12:40 ` [edk2-devel] enable MemoryProfile for uefi shell app Rafael Machado
2024-08-14 18:40   ` M.T.

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAEsd5RuM8+QZzHs4u_Z_EHi1BmY_cuOEDXYENooeVv8VL-QHhQ@mail.gmail.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox