Summary of common debugging tools under Linux

Source: Internet
Author: User
Tags exit in http post message queue semaphore

Kdump+crash using:Kdump is a tool for analyzing the causes of kernel crashes under Linux. When the system crashes, kdump is used to dump the running memory, capture the current running information, and collect all the running state and data information in memory at this time into a dump core file (typically in Var/crash Vmcore) for subsequent analysis. (PS: The crash memory set in the virtual machine is 256M, too large or too small) crash is a tool for analyzing kdump-generated core files.          Crash commonly used directives: (1) LOG: Display kernel message buffers (2) bt: Show stack information before kernel crash (can specify process number, e.g. BT <pid>) (3) PS: Display the status of the process in the system         (4) Dis: Disassembly of a given address where the instructions we commonly use in the project are log, BT, and Dis, specifically: (1) write some information in the code that PRINTK prints, and then use the log command to view the kernel after it crashes. (2) bt displays the stack information before the kernel crashes, finds the crash point rip, and then uses DIS to disassemble the address provided by the RIP to find the location of the error in the program (specific to the function instruction) Vim uses:Vim is a Linux programming environment tool, through the vim/usr/code.cpp command open, the common directives are as follows: (1) Normal mode cursor up and down: H: Left J: K: Up L: Right (2) Save and exit in Normal mode: Do not save exit:: Q Save exit:: Wq (ps:q or Wq! Indicates forced exit)         (3) Normal mode delete:                 single character: x     &NBSP ;   Full line: DD         cursor to end of line: d$           (4) Undo in normal mode:               REVOKE final instruction:u        (5) Normal mode place:         & nbsp      Copy the last deleted content to the cursor:p        (6) Normal mode replace:                 Replace all characters of the cursor with the specified characters: R character         (7) Normal mode jump:         &NB Sp     Skip to last line: Shift-g         Skip to line 21: Enter 21 after input shift-g        (8) Search in normal mode: & nbsp;               Search "int":/int           Find Next:n        (9) Normal mode copy:                 Copy n whole line: Nyy   &NB Sp       Copy to end of line: y$        copy specified n0-n1 line N2 line: &NBSP;:N0,N1 Co n2           (10) Normal mode enters insert mode: &nbs P       Insert from cursor: I             from the next line of the cursor: o           &NBS P Insert:a   from the next character of the cursor    GDB uses:GDB is a program debugging tool under Linux that allows you to set breakpoints and steps, detect deadlocks, and more. (1) Start GDB debug: GdB Program Path (Ps:gdb/usr/code/bucket) (2) Set breakpoint: 1. B Program Name: line number (ps:b bucket.cpp:21) 2. B Program Name: function name (ps:b Bucket.cpp:main) (3) run to the breakpoint: R (Ps:r runs to the breakpoint and displays the breakpoint line code and the function where the breakpoint is located) (4) View breakpoint: Info Breakpoints (PS: The breakpoint number, type, number of rows and function are displayed) (5) Delete breakpoint: Delete Breakpoint Number (6) Displays the code around the breakpoint: L (7) Stepping: One step into the middle calling function: s skips the middle call function's Single step: n (8) Continue execution: C (9) View and set variables: View variable i:p I set the value of the variable i to 5:set i = 5 (10) Exit Gdb:q netstat using:      Netstat is a tool that Linux systems use to monitor TCP/IP networks, and can monitor network connections such as TCP, UDP, ICMP, and view routing tables. Common directives are:        (1) netstat-a     List all connections          (2) netstat-t       List TCP connections         (3) netstat-u     list UDP connections         (4) netstat-c     Continuous list of links         (5) netstat-s     Show connection statistics Information         (6) netstat-n     Direct use of IP without dns        (7) netstat- P     Show PID and process name         (8) netstat-r     Show kernel IP routing table       actual common The compound instructions are:            NETSTAT-ACTNP | grep           Continuous display of all 80-port TCP connections, and show process and pid            &NBSP;NETSTAT-ACTNP | grep chrome   Continuously displays TCP connections for all Chrome processes     tcpdump using:       Tcpdump is a capture tool under Linux that can intercept the headers of transmitted packets in the network to provide analysis. You can only catch a specific packet such as a SYN or ACK of TCP, or you can just grab the HTTP POST or get instruction package, and so on. Common directives are:        (1) tcpdump -i eth0              -I indicates the specified grab interface, such as: Eth0, Wlan0 and so on (Ifconfig inet have the value can catch)         (2) tcpdump-a                    -a means displaying each packet in ASCII format         (3) tcpdump-c  100   &N Bsp         &NBSP;-C means grabbing a specified number of packages, such as grabbing 100 or tcpdump-c 100        (4) tcpdump-t                      -t means time stamp not shown          (4) tcpdump host                   host can add IP or domain name, such as: Host www.baidu.com        (5) tcpdump port                &NBSP;&NBSp  port port numbers for monitoring, such as: Port 80        (6) tcpdump src net               SRC Net backend source IP address         (7) tcpdump-w ./data.cap     -W to save the output information to./ Data.cap, convenient after analysis        in practice, the commonly used directives are:            Tcpdump-i eth9-t-a-c host Www.baidu.com and Port 80-w ./data.cap    IPCS using:       IPCS is a tool for Linux to view shared memory, Message Queuing, semaphore information for inter-process communication. Common directives are:        (1) ipcs-a                   View Linux under Total All information about memory, message queues, semaphores, including: Key, ID, owner, number of bytes, status, and so on.         (2) ipcs-p                   View Linux shared memory, messaging team The associated process number for the column, such as the send process for Message Queuing and the PID of the receiving process.         (3) ipcs-u                  See the resources used for shared memory, Message Queuing, and semaphores under Linux.         (4) ipcs-l                    Check the system resource limit of shared memory, message queue and semaphore under Linux, such as: Maximum number, maximum footprint, etc.         (5) ipcs-t                    View shared memory, Message Queuing, semaphore creation and disconnection times under Linux.         (6) ipcs-m-q-s         -M for viewing shared memory,-Q for viewing Message Queuing,- s means to view the semaphore.  &nbsp IPCRM using:IPCRM is a tool for removing the IPC resources for shared memory, Message Queuing, semaphores under Linux. Common directives are: (1) ipcrm-m key Delete shared memory via key (2) IPCRM-M ID Delete shared memory by ID (3) ipcrm-q Ke        Y Delete message queue via key (4) IPCRM-Q ID Delete message queue via ID (5) ipcrm-s key to delete semaphore via key (6) Ipcrm-s ID delete semaphore by ID

Summary of common debugging tools under Linux

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.