Linux kernel debugging tool: Kdb Application Guide (3)

Source: Internet
Author: User
Article Title: Linux kernel debugging tool: Kdb Application Guide (3 ). 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
  
Format 2: mdWcn
  
By default, md reads data with the value of the current environment variable BYTESPERWORD. when reading the hardware register, you must specify the data width. This can be read using mdWcn. W indicates the read width, in bytes, and cn indicates the number of reads.
  
MCM: displays the content of the original memory.
  
Format: MCM
  
The memory with the count length is displayed from the specified address vaddr, which prints a series of memory data. This command is left to the external debugger and is rarely used.
  
Mds: displays memory content in a symbolic manner.
  
Format: mds [vaddr [line-count [output-radix]
  
The memory content is displayed starting from the specified address vaddr. The difference with md is that each line only displays one word, and it tries to match the address with the symbol table, the corresponding symbol name and offset value are displayed. If no parameter is included, it is displayed from the end of the last mds.
  
Mm: modify memory content
  
Format 1: mm
  
Modify the data starting from the specified vaddr address to the new data. The length of the modified data is a machine word.
  
Format 2: mmW
  
The difference is that it changes the content of W bytes.
  
  
Stack Tracing
  
  
This type of command implements stack tracking, including three commands: bt, btp, and bta.
  
Bt: display the call stack
  
Format: bt [ ]
  
If no parameter is specified, it displays the stack based on the content of the current Register and provides the complete stack trace of the current active thread. If the stack-frame addr parameter is specified, it starts tracing from this address.
  
Btp: displays the process stack
  
Format: btp
  
Displays the stack of processes specified by the pid.
  
Bta: displays the stacks of all processes
  
Format: bta
  
  
Register
  
  
Register Commands include rd and rm commands for displaying and modifying the register content, and ef commands for displaying abnormal frames.
  
Rd: Display register content
  
Format: rd [c | d | u]
  
Without any parameters, rd displays the values of all general registers set at this point when entering the kdb debugger. If the c parameter is included, it displays the content of the control registers cr0, cr1, cr2, and cr4. If the parameter d is included, it displays the content of the debugging register. If the u parameter is included, it displays all registers of the current task when entering the kdb debugger.
  
Rm: Modify the register content
  
Format: rm
  
This command modifies the content of the register specified by register-name to register-content. The register-name is % eax, % ebx, % ecx, % edx, % esi, % edi, % esp, % eip, or % ebp. If the parameter is %, the Register specified by rd u will be modified. The current rm command does not allow modification of control registers or display or modify specific registers of the Pentium and Pentium Pro series.
  
Ef: displays abnormal frames.
  
Format: ef
  
Displays abnormal frames at the vaddr address.
  
  
Environment Variables
  
  
These commands display and set the environment variables of the kdb debugger. Includes the set and env commands.
  
Set: set Environment Variables
  
Format: set
  
Set the environment variable env-var to value. A maximum of 33 environment variables are available, with each environment variable up to 512 bytes. The main environment variables of kdb are:
  
PROMPT: kdb debugger PROMPT. The default value is kdb>.
  
MOREPROMPT: when the screen cannot be displayed, the system prompt is more> by default.
  
RADIX: The number system used to display data. The default value is hexadecimal.
  
LINES: number of LINES displayed by the kdb debugger. The default value is 24.
  
COLUMNS: Number of COLUMNS displayed by the kdb debugger. The default value is 80 columns.
  
MDCOUNT: the number of memory lines displayed when the md command is executed. The default value is 8.
  
BTARGS: specifies the maximum number of parameters used for printing any function when performing bt tracking.
  
SSCOUNT: This environment variable specifies that when the ssb command is executed, the execution stops if the number is exceeded. The default value is 20.
  
IDMODE: indicates the instruction format used for disassembly. The default value is x86.
  
BYTESPERWORD: Specifies the word length. The default value is 4 bytes.
  
IDCOUNT: indicates the length of a disassembly instruction. The default value is 16.
  
Env: Display Environment Variables
  
Format: env
  
Displays the values of all environment variables.

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.