Re: bhyve -G <port>

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Wed, 15 Nov 2023 23:55:37 UTC
On 11/15/23 3:06 PM, Bakul Shah wrote:
> 
> 
>> On Nov 15, 2023, at 7:57 AM, John Baldwin <jhb@FreeBSD.org> wrote:
>>
>> On 10/9/23 5:21 PM, Bakul Shah wrote:
>>> Any hints on how to use bhyve's -G <port> option to debug a VM
>>> kernel? I can connect to it from gdb with "target remote :<port>"
>>> & bhyve stops the VM initially but beyond that I am not sure.
>>> Ideally this should work just like an in-circuit-emulator, not
>>> requiring anything special in the VM or kernel itself.
>>
>> step only works on Intel CPUs currently (and is a bit fragile
>> anyway due to interrupts firing while you try to step, but that
>> happens for me in QEMU as well).   Breakpoints should work fine.
>> I tend to use 'until' to do stepping (basically stepping via
>> temporary breakpoints) when debugging the kernel this way.
> 
> Thanks for your response!
> 
> I can ^C to stop the VM, examine the stack, set breakpoints,
> continue etc. but when the breakpoint is hit, kgdb doesn't
> regain control -- instead I get the usual
> 
> db> ...
> 
> prompt on the console. I guess I have to set some sysctl for
> this?

Hmm, no, it shouldn't be breaking into DDB in the guest as the
breakpoint exception should be intercepted by the stub and
never made visible to the guest.

-- 
John Baldwin