From: "Andrew Fish" <afish@apple.com>
To: edk2-devel-groups-io <devel@edk2.groups.io>, sebastien.boeuf@intel.com
Cc: "kraxel@redhat.com" <kraxel@redhat.com>,
"Yao, Jiewen" <jiewen.yao@intel.com>
Subject: Re: [edk2-devel] Debug OVMF
Date: Mon, 09 May 2022 11:18:07 -0700 [thread overview]
Message-ID: <ABAD3D46-3CA1-41DD-A939-173532D1EF6A@apple.com> (raw)
In-Reply-To: <9db9a4e4993be2641c2e8752a456481cb71a1181.camel@intel.com>
[-- Attachment #1: Type: text/plain, Size: 3456 bytes --]
Sebastien,
The UEFI ROMs generally contain sets of PE/COFF images (drivers, apps, etc) that execute not at their linked address. These PE/COFF images have been stripped of debug information and optionally contain a PE/COFF debug directory entry that points to a file that contains the debug info. Generally for Windows this is a PDB file, for macOS it is a dSYM, for Linux it is the ELF. Given this we have to teach debuggers how to load EFI symbols.
The idea behind efi_gdb.py is to add a gdb command that can load EFI symbols. The idea is to take the PC/address/frame address and walk backwards to find the PE/COFF header. The PE/COFF header start gives you the load address and the PE/COFF debug directory entry lets you point gdb at the file with the symbols. If you are into EFI proper (DXE) you can also pass an —extended flag and the gdb command will use symbols from the frame to try and find the EFI System Table that contains a list of the load address of all the modules, and then load symbols for everything.
Assuming you tell QEMU to create a gdb remote stub (-gdb tcp::9000)… TL;DR….
When OVMF is running from another terminal window gdb -ex "target remote localhost:9000" -ex "source efi_gdb.py” and that should connect to OVMF and load the EFI Symbols.
There are some basic instructions in the header of the Python script.
https://github.com/tianocore/edk2/blob/master/BaseTools/Scripts/efi_gdb.py
The efi_gdb.py script also adds some other useful EFI related gdb commands to dump things like Device Path, HOB, guid, and EFI System Tables.
Caveat emptor there is a debugger agnostic script, efi_debugging.py, that needs to be next to efi_gdb.py. My daily driver is lldb so I wrote these scripts for lldb, and then ported to gdb with lots of interweb searching. But even if something goes wrong I can probably help out on the mailing list.
Thanks,
Andrew Fish
PS It should be possible to use the efi_debugging.py Python classes with any debugger that supports Python, or to use the services from other gdb debugging scripts etc.
> On May 9, 2022, at 3:00 AM, Boeuf, Sebastien <sebastien.boeuf@intel.com> wrote:
>
> On Mon, 2022-05-09 at 11:49 +0200, kraxel@redhat.com <mailto:kraxel@redhat.com> wrote:
>> On Mon, May 09, 2022 at 09:32:52AM +0000, Boeuf, Sebastien wrote:
>>> Hi,
>>>
>>> I'm trying to debug OVMF with gdb connected to Cloud Hypervisor but
>>> the
>>> problem is that the debug binary that I have generated doesn't
>>> contain
>>> any symbols. Do you know how to generate debug symbols for OVMF?
>>
>> Build/OvmfX64/DEBUG_GCC5/X64/*.debug
>>
>> You might want checkout BaseTools/Scripts/efi_*.py too (didn't try
>> them
>> myself yet).
>
> Ah thanks for the pointers, I'll try these :)
>
> Sebastien
>
>>
>> take care,
>> Gerd
>>
>
> ---------------------------------------------------------------------
> Intel Corporation SAS (French simplified joint stock company)
> Registered headquarters: "Les Montalets"- 2, rue de Paris,
> 92196 Meudon Cedex, France
> Registration Number: 302 456 199 R.C.S. NANTERRE
> Capital: 5 208 026.16 Euros
>
> This e-mail and any attachments may contain confidential material for
> the sole use of the intended recipient(s). Any review or distribution
> by others is strictly prohibited. If you are not the intended
> recipient, please contact the sender and delete all copies.
>
>
>
[-- Attachment #2: Type: text/html, Size: 18497 bytes --]
prev parent reply other threads:[~2022-05-09 18:18 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-09 9:32 Debug OVMF Boeuf, Sebastien
2022-05-09 9:49 ` [edk2-devel] " Gerd Hoffmann
2022-05-09 10:00 ` Boeuf, Sebastien
2022-05-09 18:18 ` Andrew Fish [this message]
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=ABAD3D46-3CA1-41DD-A939-173532D1EF6A@apple.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