Skip Navigation Links | |
Exit Print View | |
Oracle Solaris Modular Debugger Guide Oracle Solaris 11.1 Information Library |
4. Using MDB Commands Interactively
9. Debugging With the Kernel Memory Allocator
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 , and you can boot kmdb by adding the -kor -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(1M) 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 will not be immediately available during the earliest stages of boot. In particular, debugging modules will not be loaded until the kernel module subsystem has initialized. Processor-specific functionality will not be enabled until the kernel has completed the processor identification process.
If you boot your system using the -k option, kmdb will automatically load 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 the mdb -K option to load kmdb and stop kernel execution. When the debugger is loaded 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 using the command mdb -U.