Debugging (rust built) UEFI programs (running in Qemu) on Linux

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
carbonBased
Member
Member
Posts: 389
Joined: Sat Nov 20, 2004 12:00 am
Location: Wellesley, Ontario, Canada
Contact:

Debugging (rust built) UEFI programs (running in Qemu) on Linux

Post by carbonBased »

Has anyone has any success with source-level debugging a UEFI program in Linux?

Debugging my kernel is fairly straight-forward; I build an elf object with debug info, and use that for symbols while connecting to Qemu's remote gdb server (localhost:1234).

The same scenario somewhat works for the bootloader, except I'm stuck debugging at the assembly level because:
* Rust generates windows-style pdb debug symbols with GDB doesn't understand
* Attempts to add a custom UEFI target w/ dwarf debug symbols to Rust haven't been successful (has anybody succeeded in this? I even tried debugging through with Gemini, but was never successful)
* lldb supports pdb debug symbols, but doesn't seem to want to set breakpoints (it'll display then via `image lookup -r -n <sym>`, but wont set a breakpoint from a symbol name, and setting a breakpiont on the source line doesn't seem to take effect)

I'd prefer to just continue using gdb, as I already have a handful of debug scripts for the kernel, so it would be ideal if I could import debug/symbolic information from a UEFI binary into gdb, but so far haven't been successful.
User avatar
iansjack
Member
Member
Posts: 4935
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: Debugging (rust built) UEFI programs (running in Qemu) on Linux

Post by iansjack »

rust-gdb
User avatar
carbonBased
Member
Member
Posts: 389
Joined: Sat Nov 20, 2004 12:00 am
Location: Wellesley, Ontario, Canada
Contact:

Re: Debugging (rust built) UEFI programs (running in Qemu) on Linux

Post by carbonBased »

Hmm... interesting.
`rust-gdb` does allow me to set breakpoints, but it still isn't able to inspect locals or do any source level debugging.
That's one step closer than I was, though, which is nice.
Thanks!

Code: Select all

(gdb) add-symbol-file /home/jweeks/code/satus/target/x86_64-unknown-uefi/debug/satus.efi 0x7E191000
add symbol table from file "/home/jweeks/code/satus/target/x86_64-unknown-uefi/debug/satus.efi" at
	.text_addr = 0x7e191000
(y or n) y
Reading symbols from /home/jweeks/code/satus/target/x86_64-unknown-uefi/debug/satus.efi...
warning: remote target does not support file transfer, attempting to access files from local filesystem.
(No debugging symbols found in /home/jweeks/code/satus/target/x86_64-unknown-uefi/debug/satus.efi)
(gdb) b satus::set_framebuffer
Breakpoint 2 at 0x7e195c80
(gdb) c
Continuing.
[Switching to Thread 1.1]

Thread 1 hit Breakpoint 2, 0x000000007e195c80 in satus::set_framebuffer ()
(gdb) p config
No symbol table is loaded.  Use the "file" command.
Post Reply