public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* Debug OVMF
@ 2022-05-09  9:32 Boeuf, Sebastien
  2022-05-09  9:49 ` [edk2-devel] " Gerd Hoffmann
  0 siblings, 1 reply; 4+ messages in thread
From: Boeuf, Sebastien @ 2022-05-09  9:32 UTC (permalink / raw)
  To: kraxel@redhat.com, Yao, Jiewen; +Cc: devel@edk2.groups.io

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?

Thanks,
Sebastien
---------------------------------------------------------------------
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.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [edk2-devel] Debug OVMF
  2022-05-09  9:32 Debug OVMF Boeuf, Sebastien
@ 2022-05-09  9:49 ` Gerd Hoffmann
  2022-05-09 10:00   ` Boeuf, Sebastien
  0 siblings, 1 reply; 4+ messages in thread
From: Gerd Hoffmann @ 2022-05-09  9:49 UTC (permalink / raw)
  To: devel, sebastien.boeuf; +Cc: Yao, Jiewen

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).

take care,
  Gerd


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [edk2-devel] Debug OVMF
  2022-05-09  9:49 ` [edk2-devel] " Gerd Hoffmann
@ 2022-05-09 10:00   ` Boeuf, Sebastien
  2022-05-09 18:18     ` Andrew Fish
  0 siblings, 1 reply; 4+ messages in thread
From: Boeuf, Sebastien @ 2022-05-09 10:00 UTC (permalink / raw)
  To: kraxel@redhat.com, devel@edk2.groups.io; +Cc: Yao, Jiewen

On Mon, 2022-05-09 at 11:49 +0200, 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.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [edk2-devel] Debug OVMF
  2022-05-09 10:00   ` Boeuf, Sebastien
@ 2022-05-09 18:18     ` Andrew Fish
  0 siblings, 0 replies; 4+ messages in thread
From: Andrew Fish @ 2022-05-09 18:18 UTC (permalink / raw)
  To: edk2-devel-groups-io, sebastien.boeuf; +Cc: kraxel@redhat.com, Yao, Jiewen

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-05-09 18:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox