Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Linux \ Using Linux strace command trace / debug a program commonly used options     - PXE install CentOS 6.4 (Linux)

- Linux Shell Understanding and Learning (Linux)

- Install apr support for Tomcat on Linux (Server)

- Element content of Java HashSet change issues (Programming)

- Oracle 11g + RAC + RHEL6.5 + udev + ASM + PSU installation summary (Database)

- Linux system firewall defense network attacks (Linux)

- CentOS / Linux kernel upgrade (Linux)

- Implement firewall function on a closed Linux machine (Linux)

- jobs command example (Linux)

- Linux operating system set up to effectively prevent ARP attacks (Linux)

- Xmanager Remote Desktop connection CentOS (Linux)

- The Concept and Semantics of Java Memory Model (Programming)

- Struts2 interceptor simulation (Programming)

- Linux Shell Scripting (Programming)

- ORA-00824: can not set sga_target due to existing problem-solving (Database)

- MySQL Data Types (Database)

- To resolve Ubuntu 14.04 Unity Desktop Environment Login freeze problem (Linux)

- Linux operating system security settings initial understanding (Linux)

- Use Python automatically cleared Android Engineering excess resources (Programming)

- On Android running ClojureScript (Linux)

 
         
  Using Linux strace command trace / debug a program commonly used options
     
  Add Date : 2018-11-21      
         
         
         
  When debugging, strace can help you track the system calls a program executed. When you want to know how to interact with programs and the operating system, which is extremely convenient, for example, you want to know what the implementation of system calls, and in what sequence.

This simple yet powerful tool for almost all of the Linux operating system is available, and can be used to debug a lot of programs.

Command Usage

Let's see how strace command to track the implementation of a program.

In its simplest form, the back strace can follow any commands. It lists many system calls. At first, we did not understand all of the output, but if you're looking for something special, then you should find it from the output.

Let's look at a simple command ls system call tracking situation.

raghu @ raghu-Linoxide ~ $ strace ls

This is the first few lines of strace command output. Other outputs are truncated.

Output section shows the write system call, it is the current directory listing to standard output.

The image below shows the use ls command to list the contents of a directory (not used strace).

raghu @ raghu-Linoxide ~ $ ls

Option 1 to find the configuration file is read program

One usage Strace (except for debugging certain problems outside) is that you can find the configuration file is read by a program. E.g,

raghu @ raghu-Linoxide ~ $ strace php 2> & 1 | grep php.ini

Option 2 tracking system call specified

strace -e option command is used to display only certain system calls (for example, open, write, etc.)

Let's trace what 'open' system call cat command.

raghu @ raghu-Linoxide ~ $ strace -e open cat dead.letter

Option 3 tracing process

strace can be used only on the command, and by using the -p option can be used in the process running.

raghu @ raghu-Linoxide ~ $ sudo strace -p 1846

Statistical summary of option 4 strace

It includes a summary of system calls, the execution time, errors, etc. Use the -c option to be able to show it in an orderly way:

raghu @ raghu-Linoxide ~ $ strace -c ls

5 Save the output options

You can save the output of strace command by using the -o option to a file.

raghu @ raghu-Linoxide ~ $ sudo strace -o process_strace -p 3229

The reason to sudo to run the above command, in order to prevent the owner of the ID and the user ID does not match the viewing process.

6 shows the timestamp option

Using the -t option, you can add a timestamp before the output of each line.

raghu @ raghu-Linoxide ~ $ strace -t ls

Option 7 finer timestamp

-tt option can show microsecond timestamp.

raghu @ raghu-Linoxide ~ $ strace -tt ls

-ttt can also demonstrate to the above as microsecond timestamps, but it is not to print the current time, but show since epoch (Annotation: January 1, 1970 00:00:00 UTC) since elapsed seconds number.

raghu @ raghu-Linoxide ~ $ strace -ttt ls

Option 8 relative time

A relative time stamp between calls to the -r option display system.

raghu @ raghu-Linoxide ~ $ strace -r ls
     
         
         
         
  More:      
 
- Linux modify the system time (Linux)
- Linux Tutorial: Open multiple tabs in the GNOME terminal in Ubuntu 15.04 (Linux)
- Python function arguments * args and ** kwargs usage (Programming)
- Google open source TCP team repaired the Linux kernel TCP flaw (Linux)
- How to set cache valid time in Apache (Server)
- HAProxy performance under high concurrency (Server)
- Use install_updates upgrade GAMIT / GLOBK (Linux)
- Ubuntu users to install Xtreme Download Manager (Linux)
- Android imageView in the Src and Background (Programming)
- Linux kernel source tree to establish load module hello (Linux)
- EXP-00091: Exporting questionable statistics Processing Method (Database)
- CentOS system dual network card IP information configuration (Linux)
- Install Redis 2.6 5.5 32 position CentOS error resolved (Linux)
- SQL Beginner Guide (Database)
- Hardware Firewall Basics (Linux)
- To achieve Linux Security (Linux)
- Oriented C ++ test-driven development (Programming)
- Linux daemon (Linux)
- Struts2 interceptor simulation (Programming)
- Linux Firewall IPCop Profile (Linux)
     
           
     
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.