Linux Kernel debugging methods

Source: Internet
Author: User

The kernel configuration option is to enable the CONFIG_MAGIC_SYSRQ option so that after the system starts, the/proc/sysrq-trigger node is generated for debugging.

Second, the Kernel.sysrq=1 default enable SYSQ feature can be set in/etc/sysctl.conf. It is also possible to dynamically enable SYSRQ functions by writing/PROC/SYS/KERNEL/SYSRQ nodes. Different values are written to enable different functions:

0-disable SysRq completely

1-enable all functions of SYSRQ

2-enable control of console logging level

4-enable Control of keyboard (SAK, Unraw)

8-enable debugging dumps of processes etc.

16-enable Sync Command

32-enable remount read-only

64-enable signalling of processes (term, kill, Oom-kill)

128-allow Reboot/poweroff

256-allow nicing of all RT tasks

"Instructions for use"

#echo m >/proc/sysrq-trigger Exporting memory allocation information

#echo T >/proc/sysrq-trigger Export Current task status information

#echo p >/proc/sysrq-trigger Export current CPU register and flag bit information

#echo C >/proc/sysrq-trigger generates a null pointer panic event that causes the system to crash

#echo s >/proc/sysrq-trigger sync all mounted file systems instantly

#echo u >/proc/sysrq-trigger instantly re-mount all file systems as read-only

#echo w >/proc/sysrq-trigger dump tasks in uninterruptable blocking state

easy to kill Linux, introducing the powerful features of/proc/sysrq-trigger

Restart your computer now echo "B" >/proc/sysrq-trigger

Turn off the computer now echo "O" >/proc/sysrq-trigger

Export memory allocation information echo "M" > Proc/sysrq-trigger (can be viewed with/var/log/message) Outputs memory statistics to the console

Export current CPU register information and flag bits echo "P" > Proc/sysrq-trigger (Outputs all flags and registers to the console)

Exporting thread state information echo "T" > Proc/sysrq-trigger (Outputs a list of processes to the console)

Deliberately let the system crash echo "C" > Proc/sysrq-trigger (Crashes the system without first unmounting file systems or Syncing disks attached to the system)

Immediately re-mount all file systems echo "S" > Proc/sysrq-trigger (attempts to sync disks attached to the system)

Immediately re-mount all file systems as read-only echo "U" > Proc/sysrq-trigger (Attempts to unmount and remount all files systems as Read-only)

In addition, there are two features that are similar to forced logoff

E----kills all processes except init using SIGTERM

I----kills all processes except init using SIGKILL

When a SYSRQ command is triggered, the kernel will print the message to the kernel's ring buffer and output it to the system console. This information is also typically output to/var/log/messages via a syslog. Sometimes, the system may be unresponsive and syslogd may not be able to log this information. In this case, it is recommended that you set up a serial terminal to collect this information. What types of SYSRQ events can be triggered? After the SYSRQ function is opened, several SYSRQ events can be triggered. Different kernel versions may be somewhat different. But some are shared: * M-Export information about memory allocations, * t-Export thread state information, * p-Export current CPU register information and flag bit information, * C-deliberately let the system crash (useful when using Netdump or diskdump), * s-Synchronize all mounts instantly File System, * U-instantly re-mount all file systems as read-only, * B-Instant reboot system, * O-instant shutdown (if the machine is set up and supports this feature).

Linux Kernel debugging methods

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.