[ipxe-devel] GDB remote debugging on relocated iPXE code within virtual machine

Michael Brown mbrown at fensystems.co.uk
Mon Aug 13 11:59:18 BST 2012


On Monday 13 Aug 2012 11:46:55 Huy, Hermann (NSN - DE/Munich) wrote:
> 5) Make gdb aware of the code beeing relocated.
>  This is the step that gives me some headaches.
> When running iPXE withing qemu-kvm its code is taken from ROM area
> and relocated. With debug enabled for relocate.c file the line
> "Relocating from [1ff03b40,1ffaf358) to [1ff03b40,1ffaf358)"
> tells me that the iPXE code is located at 0x1ff03b40 for execution.
> 
> When I tried to teach GDB to use an offset for the code I became
> aware that there is no ".text" section within ixgbevf.rom.tmp file.
> Looking at the sections contained in ixgbevf.rom.tmp it seems that
> ".textdata" and ".bss.textdata" are the sections to be used instead
> of the typical ".text" and ".bss" sections. Is my conclusion
> correct?

Yes.  .textdata is the protected-mode text and data sections (which share an 
address space); .text16 is the real-mode text section, .data16 is the real-
mode data section.

.textdata is linked to start at address 0, so using an offset of 0x1ff03b40 for 
symbols in this section should work.

You may also want to try iPXE's built-in support for GDB, since that will show 
only the virtual addresses to GDB, and so won't require any relocation 
calculation within GDB.

As a quick check, it might be worth enabling all assertions by editing 
include/assert.h and adding a

  #undef NDEBUG

immediately before the "#ifdef NDEBUG".  This will enable assertions (but no 
other debug statements) in all objects, which can often catch memory-
corruption problems.

Michael


More information about the ipxe-devel mailing list