Booting, Loading, and Unloading kmdb
To facilitate the debugging of kernel startup, kmdb
can be loaded during the earliest stages of the boot process, before control has passed from the kernel runtime linker (krtld
) to the kernel.
On an Oracle Solaris 11 x86 system, grub is loaded first. You can boot kmdb
by adding the -k
or -kd
options to the grub kernel line.
On an Oracle Solaris 11.1 x86 system, grub is loaded first, and you can change the boot options to load kmdb in one of the following ways:
-
Run the following command as root:
# bootadm change-entry boot-environment kargs=-kd
Use the
beadm
(8) command to find the boot environment. -
Edit the grub entry by adding the
-k
or-kd
options to the boot-archive line in grub before the${kern}
entry.
If kmdb
is loaded at boot, the debugger cannot be unloaded until the system subsequently reboots. Some functionality is not immediately available during the earliest stages of boot. In particular, debugging modules are not loaded until the kernel module subsystem has initialized. Processor-specific functionality is not enabled until the kernel has completed the processor identification process.
If you boot your system using the -k
option, kmdb
automatically loads during the boot process. You can use the -d
boot option to request a debugger breakpoint prior to starting the kernel. This feature works with the default kernel as well as alternate kernels. For example, to boot a SPARC system with kmdb
and request immediate entry to the debugger, type any of the following commands:
ok boot -kd ok boot kmdb -d ok boot kadb -d
To boot an x86 system in the same manner, type any of the following commands:
Select (b)oot or (i)nterpreter: b -kd Select (b)oot or (i)nterpreter: b kmdb -d Select (b)oot or (i)nterpreter: b kadb -d
To boot a SPARC system with kmdb
and load an alternate 64-bit kernel, type the following command:
ok boot kernel.test/sparcv9/unix -k
To boot an x86 system with kmdb
and load an alternate 64-bit kernel, type the following command:
Select (b)oot or (i)nterpreter: b kernel.test/amd64/unix -k
If the boot file is set to the string kmdb
or kadb
and you want to boot an alternate kernel, use the -D
option to specify the name of the kernel to boot. To boot a SPARC system in this manner, type the following command:
ok boot kmdb -D kernel.test/sparcv9/unix
To boot a 64-bit x86 system in this manner, type the following command:
Select (b) or (i)nterpreter: b kmdb -D kernel.test/amd64/unix
To debug a system that has already booted, use one of the mdb -K
commands to load kmdb
and stop kernel execution. For information about these commands, see kmdb Debugger Entry and the
mdb
(1) man page. When the debugger is loaded by using this method, it can be subsequently unloaded. You can unload kmdb
when you are done debugging by specifying the -u
option to the ::quit
dcmd. Alternatively, you can resume execution of the operating system by using the mdb -U
command.