kernel/kld debugging on amd64 (qemu gdbstub, gdbinit, asf(1)...)

Juergen Lock nox at
Thu May 1 15:57:46 UTC 2008

On Thu, May 01, 2008 at 10:14:34AM -0400, John Baldwin wrote:
> On Thursday 01 May 2008 06:51:38 am Juergen Lock wrote:
> > Before I forget, here are some things I found out while debugging the
> > kqemu amd64 SMP issue...
> >
> > 1. I used a patched kgdb to be able to use it with qemu's gdbstub
> > (kgdb -r 127.1:1234 kernel.debug), that patch I already posted:
> >
> > (Yeah you can also used regular gdb or gdb66 from ports with qemu's
> > gdbstub, but those don't understand kernel stack frames and maybe
> > other things...)
> This patch just went into the tree (a variant of it) in the commits to kgdb in 
> HEAD earlier this week.
Ah cool!

> > 2. the ps and kldstat macros from src/tools/debugscripts/gdbinit.kernel
> > (and probably others) use %08x for pointers, so on 64 bit archs like amd64
> > the upper half gets chopped off.  I didn't fix this correctly tho, but
> > instead defined my own ps64 and kldstat64 macros using %016lx...
> Try using macros at instead as they handle 
> 64-bit vs 32-bit.
 Ah, good to know for next time...

> > 3. asf(1) also didn't work correctly for amd64 (bss and data were wrong),
> > here is the patch I ended up using: (maybe you want to ifdef for amd64
> > instead of checking for zero VMA tho)
> I haven't seen this, but I also haven't used asf(8) on amd64.  You can grab 
> the kgdb sources from HEAD though and then you can use kgdb's native kld 
> support (i.e. add-kld and the shared library stuff) for remote targets to 
> load symbols.
 OK, will try next time. :)


More information about the freebsd-amd64 mailing list