Linux kernel debugging tool: Kdb Application Guide (4)
Source: Internet
Author: User
Article Title: Linux kernel debugging tool: Kdb Application Guide (4 ). Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
Author: Hu FengHua
Miscellaneous
Id: Command Disassembly
Format: id
Address disassembly instruction starting with vaddr.
Cpu: switch to another CPU
Format: cpu
This command is only useful in the SMP structure. It switches to the CPU specified by cpunum.
Ps: displays all active processes.
Format: ps
Displays the active processes. Including pid, parent process pid, CPU number, current status, and corresponding thread.
Reboot: restart the machine
Format: reboot
In some cases, the kernel cannot return to the normal working state. In this case, you can use reboot to restart the machine. Note that it does not save any status before restarting the machine.
Sections: lists information about all the known segments in the kernel.
Format: sections
Lists information about all the known segments of the module and kernel. The first is the module information, and the last is the kernel information. Including the module name and one or more segments. Segment information includes the segment name, segment start address, segment end address, and segment ID. This command is only set up for the external debugger.
Sr: Activate the SysRq code, that is, call the MAGIC_SYSRQ function.
Format: sr
Pass the sysrq key as a parameter to the SysRq function for processing, just as you have already typed the SysRq key and this character. To use this command, select Magic SysRq Key When configuring the kernel. After the new kernel is started, run the following command to activate the SysRq function.
# Echo "1">/proc/sys/kernel/sysrq
This is a powerful command that allows you to use the SysRq processing function provided by the operating system in kdb.
Lsmod: list all modules loaded in the kernel
Format: lsmod
Displays information about all modules. The module name, module size, module structure address, reference count, and the referenced module.
Rmmod: Uninstall a module
Format: rmmod
Detaches a module specified by modname from the kernel.
Ll: execute commands repeatedly for each element in the linked list.
Format: ll
It repeatedly executes the cmd command on the link-offset element in the header of the linked list starting with the address addr.
Help and? : Displays help information.
Format: help or?
Display kdb commands and simple usage.
Improve debugging Efficiency
Kdb is a powerful kernel debugging tool. gdb requires two machines to debug through the serial port, while kdb requires only one machine for debugging, which is very convenient for common users. For programmers who write kernel programs (such as loaded modules), the commands provided by kdb greatly reduce the difficulty of debugging and improve the debugging efficiency. In addition, people interested in the kernel can use kdb to view the data structure and running status of the kernel, so as to deepen their understanding of the kernel. The disadvantage is that kdb cannot provide source code-level debugging and requires programmers to have a certain basis for assembler programs. But in general, kdb provides a powerful kernel debugging method. When developing the kernel module, I used kdb for debugging and completed the debugging task in a short time.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.