Re: kgdb with bhyve -G : cannot set debug.kdb.current=gdb

From: Mark Johnston <markj_at_freebsd.org>
Date: Mon, 09 Jun 2025 17:26:46 UTC
On Mon, Jun 09, 2025 at 05:06:41PM +0000, jmblqe wrote:
> > On Fri, Jun 06, 2025 at 05:35:13PM +0000, jmblqe wrote:
> >
> >> [...]
> >>
> >> i am unable to solve the following problem:
> >>
> >> using kgdb requires the following:
> >>
> >> # sysctl debug.kdb.current=gdb
> >
> > This is not required when connecting to the gdb stub in bhyve(8)
> > (enabled with the -G flag). In that case, the gdb stub lives in the
> > hypervisor, not in the kernel.
> >
> > debug.kdb.current is for when you're connecting directly to the
> > in-kernel gdb stub over the serial console or post-panic network stack
> > (see netgdb(4)).
> >
> >> [...]
> >>
> >> (i found that it actually is possible to attach with kgdb when debug.kdb.current is empty, but then when i set a breakpoint and reach the breakpoint, there is a panic due to the unhandled breakpoint)
> >
> > This sounds like a bug in the bhyve gdb stub. Can you share a recipe
> > for how you're triggering the panic?
> 
> Hello Mark,
> Thank you for your message.
> so, I understand better now how this works, that GDB is inside bhyve in this case.
> because of this I think the problem is that the host that I'm running bhyve from is running 12.4. on this isolated physical machine my upgrade process has been delayed/blocked and also I'm being extremely cautious on some things.
> so I will try moving this over to machine with a supported release, and reply again with the results.
> 
> however, for reference, here is what I do to trigger this panic.

Does the machine have an AMD CPU?  If so, I think what you're seeing
might be expected to some extent.  Upgrading to 13.5 or a newer 14.x
release ought to fix it, but I'm not certain--please let us know if not.