Debugging EFI apps built with Zig on Linux

Hi,

I’m new to embedded programming, and I’ve got the itch to build an EFI app because it sounds fun.

My main issue now is how to trace the execution of the app via the debugger—I’m using gdb—and qemu.

I know I need the base image address and offsets to .text and .data sections of the app (with debug symbols).

Problem is, Zig generates .pdb file from the stripped debug symbols of the app, and this file I can’t—or more correctly, don’t know how to—work with since I’m a Linux machine (precisely, Android Termux).

I tried using lldb, but it complains about a missing symbol in itself, so I gave up on it. llvm-pdbutil is moot for me.

So, how do you debug your EFI apps? What’s your process? Any resources on using .pdb files on non-MSVC toolchain?

Thanks.

I might be missing something, but why do you want to use PDB debug information on linux? Can’t you just let zig produce an ELF file? This you can inspect easily with common tools like objdump or readelf and read the specification if you need to.

well, I asked zig to generate .efi directly, so there’s that.

Are you perhaps suggesting to do it all manually?

Hi @gyre
Welcome to ziggit!

See this guide for debugging EFI applications running under QEMU with gdb: https://wiki.osdev.org/Debugging_UEFI_applications_with_GDB

I am sorry, I misunderstood your question.
You can use lldb, that supports PDB, to connect to QEMU using the gdb debug protocol.

I’ve figured out a working solution to this: https://github.com/gyreas/uefi-app-zig

I’m yet to write the details on how to debug the binary using gdb