Kernel Debug Howto

Julian Elischer julian at freebsd.org
Mon Jul 27 04:27:35 UTC 2015


On 7/25/15 5:24 PM, HeTak wrote:
> On Sat, Jul 25, 2015 at 1:41 PM, Kristof Provost <kp at freebsd.org> wrote:

With VMs you can (in some systems) wire two VMs back-to-back using 
serial port support,
and run kgdb (kernel gdb) as a remote server on the target
system and the kgdb binary on the second system
this works well.
if you are using virtualbox or bhyve on a FreeBSD host you can just run
kgdb from the host (assuming you have sources there)
bhyve has a gdb connection built in that allows a suitably compiled 
kernel to have a
direct tcp socket conneciton, however it's deadly slow (because it 
does a VM switch for every byte transfered).
I've been slowly working on a replacement that works faster but $JOB 
keep ssapping all mu free time.

You can also use the nmdm driver (virtual nullmodem) to give
gdb a 'tty' to debg through that actually is a port on the VM.
Once you have kgdb running you can try the 'xxgdb' and 'ddd' as frontends.
My memory is that for xxgdb you need to set some variables to let it 
know to call kdgb instead of gdb.


>
>>> On 25 Jul 2015, at 10:54, HeTak <hetakcoder at gmail.com> wrote:
>>> I have recently started some developments on FreeBSD net section.
>> Great!
>>
> ​Thank you Kristof, b
> oth for your fast answering and your welcome.​ :)
>
>>> But I am kinda new to this field. My base interest is to first
>> understand the
>>> implementation structure via tracing the code and so.
>>>
>>> I have three major questions:
>>> 1-  how to debug changes made to FreeBSD kernel?
>>> (You know, till some levels, I can even use uprintf or so, but, for
>> example
>>> inside radix.c (where I wanna understand how a route is checked to be
>>> unique and then inserted to the tree) I can't do such checks..)
>> dtrace can be quite useful to understand flows. You can grab stack traces
>> (i.e. figure out where things are called from), get function arguments, …
>
>>> 2- are there standards there for freebsd kernel developments of which I
>> can
>>> follow so my job gets a bit simplified?
>>> (Any development guides or so?I prospect it to be some differences
>> between
>>> system developments and normal coding, but I don't have an idea on how to
>>> get that).
>> There’s style(9) for coding style.
>> I’d also recommend "The Design and Implementation of the FreeBSD Operating
>> System”
>> (the second edition).
>>
>>> 3- what is the fastest way to apply changes to FreeBSD kernel?
>>> (For now, I just follow the normal build & install kernel & reboot.)
>> I pretty much do that. Depending on what you’re working on it might be
>> easier to run it in a VM.
>> My work lately has been on the network code, so a VM is very convenient.
>> It’s not so useful if you’re working on drivers, of course.
>>
>> ​Great to hear of such a tool as Dtrace and also the book. and actually I'm
> using a VM as well. ​
>
> ​I'll check these and hope to be successful through my way.
>
>> Regards,
>> Kristof
>
> ​Cheerio,
> HeTak​
> _______________________________________________
> freebsd-hackers at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
> To unsubscribe, send any mail to "freebsd-hackers-unsubscribe at freebsd.org"
>
>



More information about the freebsd-hackers mailing list