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 wrote: > > 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. > > >