strace
Introduction
Installation Method
Take CentOS as an example. Run the following command to install the tool:
1 | # yum -y install strace
|
How to Use
Command format: strace [parameter]
Common parameters are as follows:
Parameter |
Description |
|---|---|
-T |
Displays the time consumed by each call. |
-tt |
Adds time before each line in the output, in microseconds. |
-p |
Traces ID of the specified thread. |
Output format:
1 | 18:25:47.902439 epoll_pwait(716, [{EPOLLIN, {u32=1052576880, u64=281463144385648}}, {EPOLLIN, {u32=1052693569, u64=281463144502337}}, {EPOLLOUT, {u32=1052638657, u64=281463144447425}}, {EPOLLIN|EPOLLOUT|EPOLLRDHUP, {u32=1052673241, u64=281463144482009}}, {EPOLLIN|EPOLLOUT|EPOLLERR|EPOLLHUP|EPOLLRDHUP, {u32=1052636016, u64=281463144444784}}], 512, 1, NULL, 8) = 5 <0.000038> |
The parameters are described as follows:
Parameter |
Description |
|---|---|
18:25:47.902439 |
Indicates the time of the system call. |
epoll_pwait |
Indicates the name of the function called by the system. |
(716...) |
The value in the brackets is a function parameter. |
=5 |
Indicates the return value of the system call. |
<0.000038> |
Indicates the execution time of the system call. |