Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 9 Jun 2025 11:22:11 -0400
From:      Mark Johnston <markj@freebsd.org>
To:        jmblqe <jmblqe@pm.me>
Cc:        "freebsd-hackers@freebsd.org" <freebsd-hackers@freebsd.org>
Subject:   Re: kgdb with bhyve -G : cannot set debug.kdb.current=gdb
Message-ID:  <aEb8I6xzzdp133Zb@nuc>
In-Reply-To: <UYHqwNydfCGJo60V438sV4eAe6OoeXnrOCW9MAbRdt0ESTnmf66gZlhKc-pTPPcj4gWaprcexf0bvOavkImzrx1QgwFn17ewD0PkXI0GgNA=@pm.me>

index | next in thread | previous in thread | raw e-mail

On Fri, Jun 06, 2025 at 05:35:13PM +0000, jmblqe wrote:
> hello,
> i would like to attach kgdb remotely to a FreeBSD 13.5-RELEASE system, as described in in the Handbook and in https://freebsdfoundation.org/wp-content/uploads/2021/11/Kernel_Development_Recipes.pdf
> right now i must do this remotely over TCP (with bhyve -G) because the host is a different OS and I don't want to try to do this over serial console in that setting; and for other reasons.
> 
> 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)).

> however, gdb is not in "debug.kdb.available", so it returns,
> 
> sysctl: debug.kdb.current=gdb: Invalid argument
> 
> i have the following added to my kernel config, in addition to other options, like lots of "nodevice", which I think should be harmless:
> 
> makeoptions DEBUG=-g
> options KDB
> options GDB
> 
> (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?


help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?aEb8I6xzzdp133Zb>