Linux kernel debugging tool: Kdb Application Guide (2)
Source: Internet
Author: User
Article Title: Linux kernel debugging tool: Kdb Application Guide (2 ). 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
Basic usage of kdb
After the new kernel is installed, restart the machine with the new kernel. Now, kdb supports the kernel. So how to enter the debugging environment? If kdb-off by default is not selected during Kernel configuration, press the "pause" key after the kernel is started to enter the kdb debugging environment. If kdb-off by default is selected during Kernel configuration, you can add "kdb = on" at startup ", another method is to input the following command after the proc file system is loaded:
# Echo 1 ">/proc/sys/kernel/kdb.
Then you can press the "pause" key to enter the debugging environment. After you press the "pause" key, the prompt kdb> appears, and the Caps and Scroll indicators on the keyboard do not stop flashing, prompting you To Be In The kdb debugging environment.
Kdb provides a variety of commands to implement many functions, such as running control, memory control, register control, breakpoint settings, and stack tracing. A total of 33 commands are provided.
Operation Control
It includes three commands: go, ss, and ssb, which provide control over program execution. The usage is as follows:
Go: Continue Program Execution
Format: go
This command causes the kernel to continue running until a breakpoint is encountered. If no breakpoint is set, this command leaves the kdb debugger and the system returns to normal running status. The Caps and Scroll indicators are restored to their original status.
Ss: One-step execution Program
Format: ss
This command only executes the next command and stops after execution. This is essential for tracking.
Ssb: stops when it is executed to the branch or function call.
Format: ssb
The difference between this command and ss is that ss only executes one statement, while ssb executes a group of statements so that the command continues to be executed. When a branch statement is encountered, or stop a function call statement.
Breakpoint class
Kdb provides powerful breakpoint functions, including setting, clearing, activating, and disabling breakpoints. kdb can also set hardware breakpoints. The breakpoint Commands include bp, bl, bpa, ALB, bpha, bc, be, and bd.
Bp: sets or displays breakpoints.
Format: bp [ ]
This command sets a new breakpoint, where vaddr is the address of the breakpoint to be set. If no parameter is specified, running bp will display all breakpoints currently set.
Bl: set or display breakpoints
Format: bl [ ]
The operation of this command is the same as that of the bp command.
Bpa: set or display a Global breakpoint
Format: bpa [ ]
This command is used to set a Global breakpoint or display all global breakpoints.
If you set a hardware breakpoint or display all breakpoints
If no parameter is specified, all breakpoints are displayed. If there is a parameter, set the breakpoint. Here, vaddr is the address for setting the hardware breakpoint. datar indicates the read operation on the memory area, dataw indicates the write operation, and io indicates the io input and output operations on the memory area. Length indicates the Data length of the read/write io operation.
Bpha: Set hardware breakpoints or display all breakpoints
The format and usage are the same as those of the upper limit.
Bc: Clear breakpoints
Format: bc
Clear the breakpoint labeled bpnum. If the breakpoint number is "*", all breakpoints are cleared.
Bd: Make the breakpoint invalid
Format: bd
The breakpoint marked with bpnum is invalid. If it is marked with "*", all breakpoints are invalid.
Be: activates a breakpoint.
Format: be
Enable the breakpoint labeled bpnum. If it is marked as "*", all invalid breakpoints are activated.
Memory operations
Memory Operation Commands include four commands for displaying and modifying the memory: md, MCM, mds, and mm.
Md: Display memory content
Format 1: md [vaddr [line-count [output-radix]
Displays the memory content of the vaddr address. Line-count is the number of rows in the memory to be displayed. output-radix is displayed in octal, decimal, or hexadecimal format. If line-count and output-radix are omitted, the set environment variables MDCOUNT and RADIX are displayed. Without any parameters, the md command displays the memory content at the subsequent address of the last md command.
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.