git: 4f8f9d708e6a - main - sys: add conf/std.debug, generic debugging options

From: Warner Losh <imp_at_FreeBSD.org>
Date: Tue, 23 Apr 2024 21:43:24 UTC
The branch main has been updated by imp:

URL: https://cgit.FreeBSD.org/src/commit/?id=4f8f9d708e6a4143f3b178bfab10d0a9b75ba2fe

commit 4f8f9d708e6a4143f3b178bfab10d0a9b75ba2fe
Author:     Lexi Winter <lexi@le-Fay.ORG>
AuthorDate: 2024-04-23 21:11:24 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2024-04-23 21:13:31 +0000

    sys: add conf/std.debug, generic debugging options
    
    The new sys/conf/std.debug contains the list of debugging options
    enabled by default in -CURRENT, so they don't need to be listed
    individually in every kernel config.
    
    The enabled options are the set of all debug options which were enabled
    for the GENERIC kernel on any platform.  This means some architectures
    now have debugging options enabled in GENERIC which weren't previously
    enabled:
    
    - amd64: [1]
    - arm64: [2]
    - arm: [2]. [3]
    - i386: [1], [2]
    - powerpc: [1], [2], [3]
    - riscv: [2]
    
    [1] ALT_BREAK_TO_DEBUGGER is now enabled.
    [2] BUF_TRACKING, FULL_BUF_TRACKING, and QUEUE_MACRO_DEBUG_TRASH are now
        enabled.
    [3] DEADLKRES is now enabled.
    
    While here, move the documentation for the (commented out) K*SAN options
    for amd64 from GENERIC to NOTES.
    
    Reviewed by: imp
    Pull Request: https://github.com/freebsd/freebsd-src/pull/1124
---
 sys/amd64/conf/GENERIC         | 20 +-------------------
 sys/amd64/conf/MINIMAL         |  2 ++
 sys/amd64/conf/MINIMAL-NODEBUG | 11 +++++++++++
 sys/amd64/conf/NOTES           | 12 ++++++++++++
 sys/arm/conf/std.armv6         | 14 +++-----------
 sys/arm/conf/std.armv7         | 14 +++-----------
 sys/arm64/conf/std.arm64       | 11 +----------
 sys/conf/std.debug             | 17 +++++++++++++++++
 sys/i386/conf/GENERIC          | 10 +---------
 sys/i386/conf/MINIMAL          |  2 ++
 sys/i386/conf/MINIMAL-NODEBUG  | 11 +++++++++++
 sys/powerpc/conf/GENERIC       |  9 +--------
 sys/powerpc/conf/GENERIC64     |  9 +--------
 sys/powerpc/conf/GENERIC64LE   |  9 +--------
 sys/riscv/conf/GENERIC         | 11 +----------
 15 files changed, 68 insertions(+), 94 deletions(-)

diff --git a/sys/amd64/conf/GENERIC b/sys/amd64/conf/GENERIC
index f11601891efd..a49a5c006d77 100644
--- a/sys/amd64/conf/GENERIC
+++ b/sys/amd64/conf/GENERIC
@@ -94,25 +94,7 @@ options 	RCTL			# Resource limits
 options 	KDB			# Enable kernel debugger support.
 options 	KDB_TRACE		# Print a stack trace for a panic.
 # For full debugger support use (turn off in stable branch):
-options 	BUF_TRACKING		# Track buffer history
-options 	DDB			# Support DDB.
-options 	FULL_BUF_TRACKING	# Track more buffer history
-options 	GDB			# Support remote GDB.
-options 	DEADLKRES		# Enable the deadlock resolver
-options 	INVARIANTS		# Enable calls of extra sanity checking
-options 	INVARIANT_SUPPORT	# Extra sanity checks of internal structures, required by INVARIANTS
-options 	QUEUE_MACRO_DEBUG_TRASH	# Trash queue(2) internal pointers on invalidation
-options 	WITNESS			# Enable checks to detect deadlocks and cycles
-options 	WITNESS_SKIPSPIN	# Don't run witness on spinlocks for speed
-options 	MALLOC_DEBUG_MAXZONES=8	# Separate malloc(9) zones
-options 	VERBOSE_SYSINIT=0	# Support debug.verbose_sysinit, off by default
-
-# 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
+include ../../conf/std.debug
 
 # Kernel dump features.
 options 	EKCD			# Support for encrypted kernel dumps
diff --git a/sys/amd64/conf/MINIMAL b/sys/amd64/conf/MINIMAL
index fb6d75a2ae1a..c413590586e6 100644
--- a/sys/amd64/conf/MINIMAL
+++ b/sys/amd64/conf/MINIMAL
@@ -78,6 +78,8 @@ options 	INCLUDE_CONFIG_FILE	# Include this file in kernel
 # Debugging support.  Always need this:
 options 	KDB			# Enable kernel debugger support.
 options 	KDB_TRACE		# Print a stack trace for a panic.
+# For full debugger support use (turn off in stable branch):
+include ../../conf/std.debug
 
 # Make an SMP-capable kernel by default
 options 	SMP			# Symmetric MultiProcessor Kernel
diff --git a/sys/amd64/conf/MINIMAL-NODEBUG b/sys/amd64/conf/MINIMAL-NODEBUG
new file mode 100644
index 000000000000..35281b2212d9
--- /dev/null
+++ b/sys/amd64/conf/MINIMAL-NODEBUG
@@ -0,0 +1,11 @@
+#
+# MINIMAL-NODEBUG -- Non-debug MINIMAL kernel.
+#
+# This is the MINIMAL equivalent to GENERIC-NODEBUG.
+
+#NO_UNIVERSE
+
+include MINIMAL
+include "../../conf/std.nodebug"
+
+ident   MINIMAL-NODEBUG
diff --git a/sys/amd64/conf/NOTES b/sys/amd64/conf/NOTES
index 31db96e6d0e2..a6f12aec7dc8 100644
--- a/sys/amd64/conf/NOTES
+++ b/sys/amd64/conf/NOTES
@@ -159,3 +159,15 @@ options 	KSTACK_PAGES=5
 # Enable detailed accounting by the PV entry allocator.
 
 options 	PV_STATS
+
+#####################################################################
+# 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
+#options	KASAN			# Kernel Address Sanitizer
+#options	KCSAN			# Kernel Concurrency Sanitizer
+#options	KMSAN			# Kernel Memory Sanitizer
diff --git a/sys/arm/conf/std.armv6 b/sys/arm/conf/std.armv6
index b4b83d66809a..9ae37eab90d5 100644
--- a/sys/arm/conf/std.armv6
+++ b/sys/arm/conf/std.armv6
@@ -63,18 +63,10 @@ makeoptions	DEBUG=-g		# Build kernel with gdb(1) debug symbols
 options 	KDB			# Enable kernel debugger support.
 options 	KDB_TRACE		# Print a stack trace for a panic.
 
+options		USB_DEBUG		# Enable usb debug support code
+
 # For full debugger support use (turn off in stable branch):
-options 	DDB			# Support DDB
-options 	GDB			# Support remote GDB
-#options 	DEADLKRES		# Enable the deadlock resolver
-options 	INVARIANTS		# Enable calls of extra sanity checking
-options 	INVARIANT_SUPPORT	# Extra sanity checks of internal structures, required by INVARIANTS
-options 	WITNESS			# Enable checks to detect deadlocks and cycles
-options 	WITNESS_SKIPSPIN	# Don't run witness on spinlocks for speed
-options 	MALLOC_DEBUG_MAXZONES=8	# Separate malloc(9) zones
-options 	ALT_BREAK_TO_DEBUGGER	# Enter debugger on keyboard escape sequence
-options 	USB_DEBUG		# Enable usb debug support code
-options 	VERBOSE_SYSINIT=0	# Support debug.verbose_sysinit, off by default
+include ../../conf/std.debug
 
 # Optional extras, never enabled by default:
 #options 	BOOTVERBOSE
diff --git a/sys/arm/conf/std.armv7 b/sys/arm/conf/std.armv7
index 80b4e898bfdc..72f22efd0c28 100644
--- a/sys/arm/conf/std.armv7
+++ b/sys/arm/conf/std.armv7
@@ -63,18 +63,10 @@ makeoptions	DEBUG=-g		# Build kernel with gdb(1) debug symbols
 options 	KDB			# Enable kernel debugger support.
 options 	KDB_TRACE		# Print a stack trace for a panic.
 
+options		USB_DEBUG		# Enable usb debug support code
+
 # For full debugger support use (turn off in stable branch):
-options 	DDB			# Support DDB
-options 	GDB			# Support remote GDB
-#options 	DEADLKRES		# Enable the deadlock resolver
-options 	INVARIANTS		# Enable calls of extra sanity checking
-options 	INVARIANT_SUPPORT	# Extra sanity checks of internal structures, required by INVARIANTS
-options 	WITNESS			# Enable checks to detect deadlocks and cycles
-options 	WITNESS_SKIPSPIN	# Don't run witness on spinlocks for speed
-options 	MALLOC_DEBUG_MAXZONES=8	# Separate malloc(9) zones
-options 	ALT_BREAK_TO_DEBUGGER	# Enter debugger on keyboard escape sequence
-options 	USB_DEBUG		# Enable usb debug support code
-options 	VERBOSE_SYSINIT=0	# Support debug.verbose_sysinit, off by default
+include ../../conf/std.debug
 
 # Optional extras, never enabled by default:
 #options 	BOOTVERBOSE
diff --git a/sys/arm64/conf/std.arm64 b/sys/arm64/conf/std.arm64
index 1b6b0e8b1812..cb3c591947fc 100644
--- a/sys/arm64/conf/std.arm64
+++ b/sys/arm64/conf/std.arm64
@@ -73,16 +73,7 @@ options 	PERTHREAD_SSP		# Per-thread SSP canary
 options 	KDB			# Enable kernel debugger support.
 options 	KDB_TRACE		# Print a stack trace for a panic.
 # For full debugger support use (turn off in stable branch):
-options 	DDB			# Support DDB.
-options 	GDB			# Support remote GDB.
-options 	DEADLKRES		# Enable the deadlock resolver
-options 	INVARIANTS		# Enable calls of extra sanity checking
-options 	INVARIANT_SUPPORT	# Extra sanity checks of internal structures, required by INVARIANTS
-options 	WITNESS			# Enable checks to detect deadlocks and cycles
-options 	WITNESS_SKIPSPIN	# Don't run witness on spinlocks for speed
-options 	MALLOC_DEBUG_MAXZONES=8	# Separate malloc(9) zones
-options 	ALT_BREAK_TO_DEBUGGER	# Enter debugger on keyboard escape sequence
-options 	VERBOSE_SYSINIT=0	# Support debug.verbose_sysinit, off by default
+include ../../conf/std.debug
 
 # Kernel Sanitizers
 #options 	COVERAGE		# Generic kernel coverage. Used by KCOV
diff --git a/sys/conf/std.debug b/sys/conf/std.debug
new file mode 100644
index 000000000000..53789f269b80
--- /dev/null
+++ b/sys/conf/std.debug
@@ -0,0 +1,17 @@
+#
+# std.debug -- Enable debug options for -CURRENT.
+#
+
+options 	BUF_TRACKING		# Track buffer history
+options 	DDB			# Support DDB.
+options 	FULL_BUF_TRACKING	# Track more buffer history
+options 	GDB			# Support remote GDB.
+options 	DEADLKRES		# Enable the deadlock resolver
+options 	INVARIANTS		# Enable calls of extra sanity checking
+options 	INVARIANT_SUPPORT	# Extra sanity checks of internal structures, required by INVARIANTS
+options 	QUEUE_MACRO_DEBUG_TRASH	# Trash queue(2) internal pointers on invalidation
+options 	WITNESS			# Enable checks to detect deadlocks and cycles
+options 	WITNESS_SKIPSPIN	# Don't run witness on spinlocks for speed
+options 	MALLOC_DEBUG_MAXZONES=8	# Separate malloc(9) zones
+options 	VERBOSE_SYSINIT=0	# Support debug.verbose_sysinit, off by default
+options		ALT_BREAK_TO_DEBUGGER	# Enter debugger on keyboard escape sequence
diff --git a/sys/i386/conf/GENERIC b/sys/i386/conf/GENERIC
index b5898ed94b81..7bd01d4e60e7 100644
--- a/sys/i386/conf/GENERIC
+++ b/sys/i386/conf/GENERIC
@@ -88,15 +88,7 @@ options 	RCTL			# Resource limits
 options 	KDB			# Enable kernel debugger support.
 options 	KDB_TRACE		# Print a stack trace for a panic.
 # For full debugger support use (turn off in stable branch):
-options 	DDB			# Support DDB.
-options 	GDB			# Support remote GDB.
-options 	DEADLKRES		# Enable the deadlock resolver
-options 	INVARIANTS		# Enable calls of extra sanity checking
-options 	INVARIANT_SUPPORT	# Extra sanity checks of internal structures, required by INVARIANTS
-options 	WITNESS			# Enable checks to detect deadlocks and cycles
-options 	WITNESS_SKIPSPIN	# Don't run witness on spinlocks for speed
-options 	MALLOC_DEBUG_MAXZONES=8	# Separate malloc(9) zones
-options 	VERBOSE_SYSINIT=0	# Support debug.verbose_sysinit, off by default
+include ../../conf/std.debug
 
 # Kernel dump features.
 options 	EKCD			# Support for encrypted kernel dumps
diff --git a/sys/i386/conf/MINIMAL b/sys/i386/conf/MINIMAL
index e27bb68e31fe..b29a179d2bdf 100644
--- a/sys/i386/conf/MINIMAL
+++ b/sys/i386/conf/MINIMAL
@@ -86,6 +86,8 @@ options 	INCLUDE_CONFIG_FILE	# Include this file in kernel
 # Debugging support.  Always need this:
 options 	KDB			# Enable kernel debugger support.
 options 	KDB_TRACE		# Print a stack trace for a panic.
+# For full debugger support use (turn off in stable branch):
+include ../../conf/std.debug
 
 # Make an SMP-capable kernel by default
 options 	SMP			# Symmetric MultiProcessor Kernel
diff --git a/sys/i386/conf/MINIMAL-NODEBUG b/sys/i386/conf/MINIMAL-NODEBUG
new file mode 100644
index 000000000000..35281b2212d9
--- /dev/null
+++ b/sys/i386/conf/MINIMAL-NODEBUG
@@ -0,0 +1,11 @@
+#
+# MINIMAL-NODEBUG -- Non-debug MINIMAL kernel.
+#
+# This is the MINIMAL equivalent to GENERIC-NODEBUG.
+
+#NO_UNIVERSE
+
+include MINIMAL
+include "../../conf/std.nodebug"
+
+ident   MINIMAL-NODEBUG
diff --git a/sys/powerpc/conf/GENERIC b/sys/powerpc/conf/GENERIC
index 47c84956facd..bb7865301fcb 100644
--- a/sys/powerpc/conf/GENERIC
+++ b/sys/powerpc/conf/GENERIC
@@ -91,14 +91,7 @@ options 	RCTL			# Resource limits
 options 	KDB			# Enable kernel debugger support.
 options 	KDB_TRACE		# Print a stack trace for a panic.
 # For full debugger support use (turn off in stable branch):
-options 	DDB			# Support DDB
-#options 	DEADLKRES		# Enable the deadlock resolver
-options 	INVARIANTS		# Enable calls of extra sanity checking
-options 	INVARIANT_SUPPORT	# Extra sanity checks of internal structures, required by INVARIANTS
-options 	WITNESS			# Enable checks to detect deadlocks and cycles
-options 	WITNESS_SKIPSPIN	# Don't run witness on spinlocks for speed
-options 	MALLOC_DEBUG_MAXZONES=8	# Separate malloc(9) zones
-options 	VERBOSE_SYSINIT=0	# Support debug.verbose_sysinit, off by default
+include ../../conf/std.debug
 
 # Kernel dump features.
 options 	EKCD			# Support for encrypted kernel dumps
diff --git a/sys/powerpc/conf/GENERIC64 b/sys/powerpc/conf/GENERIC64
index 9d2de9c8095b..b077cf3f2feb 100644
--- a/sys/powerpc/conf/GENERIC64
+++ b/sys/powerpc/conf/GENERIC64
@@ -101,14 +101,7 @@ options 	RCTL			# Resource limits
 options 	KDB			# Enable kernel debugger support.
 options 	KDB_TRACE		# Print a stack trace for a panic.
 # For full debugger support use (turn off in stable branch):
-options 	DDB			# Support DDB
-#options 	DEADLKRES		# Enable the deadlock resolver
-options 	INVARIANTS		# Enable calls of extra sanity checking
-options 	INVARIANT_SUPPORT	# Extra sanity checks of internal structures, required by INVARIANTS
-options 	WITNESS			# Enable checks to detect deadlocks and cycles
-options 	WITNESS_SKIPSPIN	# Don't run witness on spinlocks for speed
-options 	MALLOC_DEBUG_MAXZONES=8	# Separate malloc(9) zones
-options 	VERBOSE_SYSINIT=0	# Support debug.verbose_sysinit, off by default
+include ../../conf/std.debug
 
 # Kernel dump features.
 options 	EKCD			# Support for encrypted kernel dumps
diff --git a/sys/powerpc/conf/GENERIC64LE b/sys/powerpc/conf/GENERIC64LE
index 6ca1a01e5969..f090cd47ecf8 100644
--- a/sys/powerpc/conf/GENERIC64LE
+++ b/sys/powerpc/conf/GENERIC64LE
@@ -97,14 +97,7 @@ options 	RCTL			# Resource limits
 options 	KDB			# Enable kernel debugger support.
 options 	KDB_TRACE		# Print a stack trace for a panic.
 # For full debugger support use (turn off in stable branch):
-options 	DDB			# Support DDB
-#options 	DEADLKRES		# Enable the deadlock resolver
-options 	INVARIANTS		# Enable calls of extra sanity checking
-options 	INVARIANT_SUPPORT	# Extra sanity checks of internal structures, required by INVARIANTS
-options 	WITNESS			# Enable checks to detect deadlocks and cycles
-options 	WITNESS_SKIPSPIN	# Don't run witness on spinlocks for speed
-options 	MALLOC_DEBUG_MAXZONES=8	# Separate malloc(9) zones
-options 	VERBOSE_SYSINIT=0	# Support debug.verbose_sysinit, off by default
+include ../../conf/std.debug
 
 # Kernel dump features.
 options 	EKCD			# Support for encrypted kernel dumps
diff --git a/sys/riscv/conf/GENERIC b/sys/riscv/conf/GENERIC
index ca71f7423cfa..52edc01b5c89 100644
--- a/sys/riscv/conf/GENERIC
+++ b/sys/riscv/conf/GENERIC
@@ -156,17 +156,8 @@ device		spigen
 options 	KDB			# Enable kernel debugger support.
 options 	KDB_TRACE		# Print a stack trace for a panic.
 # For full debugger support use (turn off in stable branch):
-options 	DDB			# Support DDB.
-options 	GDB			# Support remote GDB.
-options 	DEADLKRES		# Enable the deadlock resolver
-options 	INVARIANTS		# Enable calls of extra sanity checking
-options 	INVARIANT_SUPPORT	# Extra sanity checks of internal structures, required by INVARIANTS
-options 	WITNESS			# Enable checks to detect deadlocks and cycles
-options 	WITNESS_SKIPSPIN	# Don't run witness on spinlocks for speed
-options 	MALLOC_DEBUG_MAXZONES=8	# Separate malloc(9) zones
-options 	ALT_BREAK_TO_DEBUGGER	# Enter debugger on keyboard escape sequence
+include "std.debug"
 # options 	EARLY_PRINTF=sbi
-options 	VERBOSE_SYSINIT=0	# Support debug.verbose_sysinit, off by default
 
 # Kernel dump features.
 options 	EKCD			# Support for encrypted kernel dumps