# How to enable by default the kernel debugger?



## openbsd98324 (Feb 10, 2022)

Hello,

Alike netbsd and openbsd, I would like to have access to the debugger. 

How is it possible in FreeBSD?

Please find herewith a screenshot.


----------



## grahamperrin@ (Feb 11, 2022)

Welcome to FreeBSD Forums.

Not a direct answer to your question, but FYI:

LLDB FreeBSD kernel debugging support summary | Moritz Systems (2022-01-20) ◀ <https://old.reddit.com/r/freebsd/comments/s8zy4f/-/>

More usefully, but with limitations: 

<https://docs.freebsd.org/en/books/developers-handbook/book/#kerneldebug-online-ddb>


----------



## openbsd98324 (Feb 11, 2022)

grahamperrin said:


> Welcome to FreeBSD Forums.
> 
> Not a direct answer to your question, but FYI:
> 
> ...


Thank you for the documentation about GDB, DB,...

Concerning the direct db, if I recall well, this feature can be enabled, but only with recompiling the kernel FreeBSD from source.
Hopefully, it can today be made available a bit easier. This is very useful thing, as shown in the above screenshot.

Using a VM, qemu,... is possible but quite cumbersome method.

It would be very doubtful, that FreeBSD hasn't any longer, because it is a common thing in BSD.
Even Linux, with much less features, compared to FreeBSD can have it and be enabled - after kernel build.


----------



## sko (Feb 11, 2022)

Depending on the specific problem you are facing: Instead of probably using a sledgehammer to crack a nut, FreeBSD has superb dtrace(1) support which allows for instrumentation of almost every part of the system without the major performance impacts fully enabled debugging would have.


----------



## SirDice (Feb 11, 2022)

Note that the default GENERIC kernel has some debug options enabled by default. But there's certainly a configuration difference between -RELEASE, -STABLE and -CURRENT. -CURRENT has almost everything debug-wise turned up to 11 by default. 


```
makeoptions	DEBUG=-g		# Build kernel with gdb(1) debug symbols
makeoptions	WITH_CTF=1		# Run ctfconvert(1) for DTrace support

...

# Debugging support.  Always need this:
options 	KDB			# Enable kernel debugger support.
options 	KDB_TRACE		# Print a stack trace for a panic.

# Kernel Sanitizers
#options 	COVERAGE		# Generic kernel coverage. Used by KCOV
#options 	KCOV			# Kernel Coverage Sanitizer
# Warning: KUBSAN can result in a kernel too large for loader to load
#options 	KUBSAN			# Kernel Undefined Behavior Sanitizer
#options 	KCSAN			# Kernel Concurrency Sanitizer

# Kernel dump features.
options 	EKCD			# Support for encrypted kernel dumps
options 	GZIO			# gzip-compressed kernel and user dumps
options 	ZSTDIO			# zstd-compressed kernel and user dumps
options 	DEBUGNET		# debugnet networking
options 	NETDUMP			# netdump(4) client support
options 	NETGDB			# netgdb(4) client support
```






						GENERIC « conf « amd64 « sys - src - FreeBSD source tree
					






					cgit.freebsd.org


----------

