MDB or the modular debugger is used for extremely low level debugging. It falls into the category of debuggers that are used in combination with core files and the platform assembly language to diagnose and correct problems. Its main use is for analyzing the state of the program that you are running at the assembly language level.
MDB allows programmers to implement modules that will execute commands while you are debugging your programs. There are already modules for kernel, and device driver debugging that are included with Solaris. Using the kernel debugging modules you can do the following things:
• Locate a kernel thread’s memory
• Print a picture of a kernel stream
• Determine the type of structure that an address points to
• Detect memory leaks
• Locate stack traces
MDB currently supports debugging and examining the following targets.
• User level processes
• User level core files
• Viewing operating system execution using /dev/kmem and /dev/ksyms
• Controlling operating system execution using kmdb
• Kernel crash dumps
• Elf object files
• Raw data files
To start the kernel level debugger kmdb you should start mdb with the –k option.
Debugging Kernel Crash Dumps:
When the Solaris kernel crashes it will leave a core file in /var/crash on the system that has crash. The debugger needs to be invoked on a system that is the same architecture and solaris version as the system that crashed. If you do not do this then debugging will not work.
Command What it does
::showrev Prints the kernel version information
::status Prints the module and cause of the kernel panic
::panicinfo Prints the registers and there values at the time of the panic
::msgbuf Shows the content of the kernel message buffer
$C Prints a kernel level stack trace for the kernel thread that had the kernel panic
Functionname::dis Prints the disassembly of the function that you specify.
::cpuinfo Shows a large amount of information about the cpus in the system.
::threadlist Prints a listing of all the kernel threads that are available in the kernel
::findleaks Helps detect memory leaks. Needs a decent amount of kernel options turned on at build time.
::vatopfn Translates a virtual address to a physical address
::whatis Determines if the address is a pointer to a buffer or a different type of special memory region
Using the Kernel Modular Debugger:
KMDB is extremely powerfull. It not only allows you to view what is going on in the system at the instruction level, it also allows you to modify the values of those instructions and execute your own instructions. There is no safety net, you can do whatever you want on the system.
There are two ways to start kmdb on the system that you are trying to debug. The first one is to start mdb with the –k option from the system’s console login. The second one is to pass the –k option to the kernel boot arguments. On the x86 platform you can do this be modifying the grub configuration file. Also if you need to set any breakpoints for the boot process you can supply the –d flag and the kernel will enter the debugger so you can set kernel variables and breakpoints to the values that you want. If you are working on the SPARC platform you can pass the options at the boot prompt, but you must also specify the command kmdb.
The commands that are used for debugging kernel crash dumps can also be used when you are debugging the kernel.
Posted by mccabemt
Posted by mccabemt
Posted by mccabemt