Issue
I've been sinking days into getting this working with no results. I want to use gdb to debug u-boot on qemu. I am using the 64 bit efi payload of u-boot (in which u-boot is placed in the payload of an efi stub application), and a x86-64 qemu with ovmf firmware. I have two elf files for the debug symbols: u-boot and u-boot-payload. It seems that u-boot contains the symbols for u-boot itself, while u-boot-payload contains symbols for the stub application.
I have been following several guides on how to do this: https://www.haiku-os.org/blog/kallisti5/2021-01-17_debugging_riscv-64_bootloader_in_qemu/ https://wiki.osdev.org/Debugging_UEFI_applications_with_GDB
My problem is that gdb is never able to hit the breakpoints. I believe the problem is that I can't find the offset I need to load the symbols to. All of these guides mention relocation, and I have tried using the same formula they suggest (<MAXMEM> - SYS_MONITOR_LEN), with no luck. I've tried the addresses that u-boot outputs:
SYS_TEXT = 01110000
UBOOT = 7e36f200
SIZE = 0005cdcf
But none of these worked. I've tried breaking in functions in the stub and u-boot itself, but nothing ever works. I've been going at this for so long its honestly hard for me to recall everything I've tried accurately, but I've run out of ideas.
Is there some underlying assumption I've made that's tripping me up, or is it really just that I'm using the wrong offset? I've read that u-boot relocates, but what I don't understand is what address it relocates to and when. Does the stub relocate, or does relocation happen before the stub runs? These are all things I haven't found any clarification on.
Anything feedback helps, it's hard for me to ask a more specific question because I'm not sure what I'm doing wrong.
Solution
Figured it out! The required argument for add-symbol-file comes from common/board_f.c after the setup_reloc function runs, the value of gd->relocaddr will contain the value you need for add-symbol-file.
The other problem I was having is that you need to use hbreak instead of break in gdb. This is a "hardware assisted" breakpoint, and for some reason all of the guides online I saw fail to mention this. I hope someone else finds this useful
Answered By - exliontamer
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.