“Strace”的版本间的差异

来自百问网嵌入式Linux wiki
 
标签visualeditor-switched
 
第1行: 第1行:
 +
 +
=Strace=
 +
==文章目的==
 +
: 本文提供了开始使用 Linux 工具(strace [1 ])所需的基本信息。
 +
==简介==
 +
: 下表简要介绍了该工具及其可用性,具体取决于软件包:
 +
* 是:该工具已经存在(可以使用或激活),也可以在软件包中集成和激活。
 +
* 没有:该工具不存在且无法集成,或者存在但无法在软件包中激活。
 +
{| class="wikitable"
 +
!colspan="3" | 工具
 +
|-
 +
| 名称
 +
| 类别
 +
| 目的
 +
|-
 +
|Strace
 +
|追踪工具
 +
|strace [1 ]能够截获和记录一个进程调用的系统调用以及另一个进程接收的信号。
 +
|-
 +
!colspan="3" | STM32MPU嵌入式软件发行版
 +
|-
 +
| 入门资料包
 +
| 开发者资料包
 +
| 发行版资料包
 +
|-
 +
|是
 +
|是
 +
|是
 +
|-
 +
!colspan="3" | 适用于 Android 的STM32MPU嵌入式软件发行版
 +
|-
 +
| 入门资料包
 +
| 开发者资料包
 +
| 发行版资料包
 +
|-
 +
|是
 +
|是
 +
|是
 +
|}
 +
 +
==在目标板上安装跟踪和调试工具==
 +
===使用 STM32MPU 嵌入式软件发行版===
 +
: strace 默认情况下已安装,可以与所有 STM32MPU 嵌入式软件包一起使用。
 +
<syntaxhighlight lang="bash">
 +
Board $> which strace
 +
/usr/bin/strace
 +
</syntaxhighlight>
 +
 +
: strace 通过 meta-st 软件包集成到 weston 镜像分发中:meta-st/meta-st-openstlinux/recipes-st/packagegroups/packagegroup-framework-tools.bb 。
 +
<syntaxhighlight lang="bash">
 +
RDEPENDS_packagegroup-framework-tools-kernel-base = "\
 +
  can-utils      \
 +
  i2c-tools      \
 +
  strace          \
 +
  usbutils        \
 +
  \
 +
  evtest          \
 +
  memtester      \
 +
  mtd-utils      \
 +
  v4l-utils      \
 +
  "
 +
</syntaxhighlight>
 +
 +
===使用适用于 Android 的 STM32MPU 嵌入式软件发行版===
 +
: strace 默认情况下已安装(/system/bin/strace),并准备与所有适用于 Android 的 STM32MPU 软件包一起使用。
 +
<syntaxhighlight lang="bash">
 +
Board $> which strace
 +
/system/bin/strace
 +
</syntaxhighlight>
 +
 +
: 它通过 Android 基本的 makefile 集成在 Android 镜像分发中 build/make/target/product/base.mk:
 +
<syntaxhighlight lang="bash">
 +
# Packages included only for eng or userdebug builds, previously debug tagged
 +
PRODUCT_PACKAGES_DEBUG := \
 +
    logpersist.start \
 +
    perfprofd \
 +
    sqlite3 \
 +
    strace
 +
</syntaxhighlight>
 +
 +
==使用入门==
 +
: 要使用strace,有两种主要方法:
 +
: 通过提供要列出其系统调用的程序的名称作为参数,并在需要时为其指定参数作为参数运行:
 +
<syntaxhighlight lang="bash">
 +
Board $> strace <Program> [Prog_Args]
 +
</syntaxhighlight>
 +
 +
: 通过给出要研究的过程的PID作为参数:
 +
<syntaxhighlight lang="bash">
 +
Board $> strace -p <PID>
 +
</syntaxhighlight>
 +
 +
: 一些有用的命令选项:
 +
<syntaxhighlight lang="bash">
 +
-a <num> : alignment num COLUMN for printing syscall results
 +
-r : print relative timestamp
 +
-t : print absolute timestamp
 +
-T : print time spent in each syscall
 +
</syntaxhighlight>
 +
: 还可以设置其他选项。有关详细信息,请参阅手册页[2 ]。
 +
 +
==深入学习==
 +
===示例===
 +
: 例如,可以通过 gst-play 获得系统调用来播放多媒体文件:
 +
<syntaxhighlight lang="bash">
 +
Board $> strace -rT -a 100 gst-play-1.0 /usr/local/demo/media/ST2297_visionv3.webm
 +
</syntaxhighlight>
 +
<syntaxhighlight lang="bash">
 +
    0.000000 execve("/usr/bin/gst-play-1.0", ["gst-play-1.0", "[...]"...], 0xbeb10c00 /* 24 vars */) = 0 <0.001485>
 +
    0.002800 brk(NULL)                                                                            = 0x28000 <0.000069>
 +
    0.000717 uname({sysname="Linux", nodename="stm32mp1", ...})                                    = 0 <0.000069>
 +
    0.000591 mmap2(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0)            = 0xb6fa2000 <0.000093>
 +
    0.000673 access("/etc/ld.so.preload", R_OK)                                                    = -1 ENOENT (No such file or directory) <0.000109>
 +
    0.000734 openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC)                              = 3 <0.000115>
 +
    0.000669 fstat64(3, {st_mode=S_IFREG|0644, st_size=24533, ...})                                = 0 <0.000069>
 +
    0.000619 mmap2(NULL, 24533, PROT_READ, MAP_PRIVATE, 3, 0)                                      = 0xb6f9c000 <0.000091>
 +
    0.000599 close(3)                                                                              = 0 <0.000065>
 +
    0.000668 openat(AT_FDCWD, "/usr/lib/libgstpbutils-1.0.so.0", O_RDONLY|O_CLOEXEC)              = 3 <0.000114>
 +
    0.000646 read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\300\234\0\0004\0\0\0"..., 512) = 512 <0.000083>
 +
    0.000611 fstat64(3, {st_mode=S_IFREG|0755, st_size=195640, ...})                              = 0 <0.000080>
 +
    0.000712 mmap2(NULL, 260004, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0)            = 0xb6f34000 <0.000088>
 +
    0.000596 mprotect(0xb6f62000, 61440, PROT_NONE)                                                = 0 <0.000098>
 +
    0.000609 mmap2(0xb6f71000, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x2d000) = 0xb6f71000 <0.000147>
 +
    0.000811 close(3)                                                                              = 0 <0.000070>
 +
    0.000706 openat(AT_FDCWD, "/usr/lib/libgstvideo-1.0.so.0", O_RDONLY|O_CLOEXEC)                = 3 <0.000138>
 +
    0.000754 read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0P\317\0\0004\0\0\0"..., 512)  = 512 <0.000079>
 +
    0.000612 fstat64(3, {st_mode=S_IFREG|0755, st_size=486440, ...})                              = 0 <0.000070>
 +
    0.000618 mmap2(NULL, 552344, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0)            = 0xb6ead000 <0.000087>
 +
    0.000601 mprotect(0xb6f1c000, 61440, PROT_NONE)                                                = 0 <0.000092>
 +
    0.000610 mmap2(0xb6f2b000, 36864, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x6e000) = 0xb6f2b000 <0.000132>
 +
    0.000709 close(3)                                                                              = 0 <0.000067>
 +
    0.000712 openat(AT_FDCWD, "/usr/lib/libgstaudio-1.0.so.0", O_RDONLY|O_CLOEXEC)                = 3 <0.000121>
 +
    0.000673 read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\0\236\0\0004\0\0\0"..., 512)  = 512 <0.000078>
 +
    0.000606 fstat64(3, {st_mode=S_IFREG|0755, st_size=375816, ...})                              = 0 <0.000067>
 +
    0.000623 mmap2(NULL, 440684, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0)            = 0xb6e41000 <0.000150>
 +
    0.000692 mprotect(0xb6e9b000, 61440, PROT_NONE)                                                = 0 <0.000096>
 +
    0.000606 mmap2(0xb6eaa000, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x59000) = 0xb6eaa000 <0.000130>
 +
    0.000722 close(3)                                                                              = 0 <0.000071>
 +
    0.000700 openat(AT_FDCWD, "/usr/lib/libgsttag-1.0.so.0", O_RDONLY|O_CLOEXEC)                  = 3 <0.000135>
 +
    0.000755 read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\370d\0\0004\0\0\0"..., 512)  = 512 <0.000080>
 +
    0.000613 fstat64(3, {st_mode=S_IFREG|0755, st_size=215824, ...})                              = 0 <0.000068>
 +
    0.000617 mmap2(NULL, 280136, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0)            = 0xb6dfc000 <0.000087>
 +
    0.000597 mprotect(0xb6e2f000, 65536, PROT_NONE)                                                = 0 <0.000090>
 +
    0.000617 mmap2(0xb6e3f000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x33000) = 0xb6e3f000 <0.000121>
 +
    0.000702 close(3)                                                                              = 0 <0.000070>
 +
    0.009092 openat(AT_FDCWD, "/usr/lib/libgstreamer-1.0.so.0", O_RDONLY|O_CLOEXEC)                = 3 <0.000146>
 +
    0.010000 read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\270\371\1\0004\0\0\0"..., 512) = 512 <0.000088>
 +
    0.010392 fstat64(3, {st_mode=S_IFREG|0755, st_size=1116268, ...})                              = 0 <0.000072>
 +
    0.010210 mmap2(NULL, 1184392, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0)            = 0xb6cda000 <0.000107>
 +
    0.010879 mprotect(0xb6de7000, 61440, PROT_NONE)                                                = 0 <0.000106>
 +
    0.010048 mmap2(0xb6df6000, 20480, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x10c000) = 0xb6df6000 <0.000186>
 +
    0.011926 mmap2(0xb6dfb000, 648, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xb6dfb000 <0.000141>
 +
    0.011239 close(3)                                                                              = 0 <0.000073>
 +
    0.010260 openat(AT_FDCWD, "/usr/lib/libgobject-2.0.so.0", O_RDONLY|O_CLOEXEC)                  = 3 <0.000147>
 +
    0.009916 read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\250\212\0\0004\0\0\0"..., 512) = 512 <0.000095>
 +
    0.010372 fstat64(3, {st_mode=S_IFREG|0755, st_size=294000, ...})                              = 0 <0.000075>
 +
    0.010086 mmap2(NULL, 359636, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0)            = 0xb6c82000 <0.000102>
 +
    0.010916 mprotect(0xb6cc9000, 61440, PROT_NONE)                                                = 0 <0.000103>
 +
    0.010033 mmap2(0xb6cd8000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x46000) = 0xb6cd8000 <0.000143>
 +
    0.011876 close(3)                                                                              = 0 <0.000074>
 +
    0.010153 openat(AT_FDCWD, "/usr/lib/libglib-2.0.so.0", O_RDONLY|O_CLOEXEC)                    = 3 <0.000146>
 +
    0.009983 read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0XX\1\0004\0\0\0"..., 512)      = 512 <0.000088>
 +
    0.010209 fstat64(3, {st_mode=S_IFREG|0755, st_size=990348, ...})                              = 0 <0.000075>
 +
    0.010215 mmap2(NULL, 1056232, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0)            = 0xb6b80000 <0.000103>
 +
    0.010881 mprotect(0xb6c71000, 61440, PROT_NONE)                                                = 0 <0.000100>
 +
    0.010032 mmap2(0xb6c80000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0xf0000) = 0xb6c80000 <0.000150>
 +
    0.011792 close(3)                                                                              = 0 <0.000073>
 +
    0.010218 openat(AT_FDCWD, "/lib/libm.so.6", O_RDONLY|O_CLOEXEC)                                = 3 <0.000140>
 +
    0.010000 read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\220E\0\0004\0\0\0"..., 512)  = 512 <0.000084>
 +
    0.010212 fstat64(3, {st_mode=S_IFREG|0755, st_size=452028, ...})                              = 0 <0.000073>
 +
    0.010207 mmap2(NULL, 516216, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0)            = 0xb6b01000 <0.000101>
 +
    0.010877 mprotect(0xb6b6f000, 61440, PROT_NONE)                                                = 0 <0.000110>
 +
    0.010035 mmap2(0xb6b7e000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x6d000) = 0xb6b7e000 <0.000152>
 +
    0.011806 close(3)                                                                              = 0 <0.000075>
 +
    0.010130 openat(AT_FDCWD, "/lib/libpthread.so.0", O_RDONLY|O_CLOEXEC)                          = 3 <0.000134>
 +
    0.010086 read(3, "\177ELF\1\1\1\3\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\214H\0\0004\0\0\0"..., 512)  = 512 <0.000085>
 +
    0.010211 fstat64(3, {st_mode=S_IFREG|0755, st_size=92656, ...})                                = 0 <0.000074>
 +
    0.010208 mmap2(NULL, 164424, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0)            = 0xb6ad8000 <0.000100>
 +
    0.010813 mprotect(0xb6aee000, 61440, PROT_NONE)                                                = 0 <0.000108>
 +
    0.010205 mmap2(0xb6afd000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x15000) = 0xb6afd000 <0.000172>
 +
    0.011742 mmap2(0xb6aff000, 4680, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xb6aff000 <0.000137>
 +
    0.011249 close(3)                                                                              = 0 <0.000072>
 +
    0.010170 openat(AT_FDCWD, "/lib/libc.so.6", O_RDONLY|O_CLOEXEC)                                = 3 <0.000149>
 +
    0.009988 read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\34l\1\0004\0\0\0"..., 512)    = 512 <0.000088>
 +
    0.010219 fstat64(3, {st_mode=S_IFREG|0755, st_size=1218336, ...})                              = 0 <0.000075>
 +
    0.010198 mmap2(NULL, 1287556, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0)            = 0xb699d000 <0.000105>
 +
    0.010876 mprotect(0xb6ac3000, 61440, PROT_NONE)                                                = 0 <0.000132>
 +
    0.010123 mmap2(0xb6ad2000, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x125000) = 0xb6ad2000 <0.000177>
 +
    0.011925 mmap2(0xb6ad5000, 9604, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xb6ad5000 <0.000141>
 +
    0.011252 close(3)                                                                              = 0 <0.000077>
 +
    0.010267 openat(AT_FDCWD, "/usr/lib/liborc-0.4.so.0", O_RDONLY|O_CLOEXEC)                      = 3 <0.000150>
 +
    0.009799 read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0`u\0\0004\0\0\0"..., 512)      = 512 <0.000090>
 +
    0.010386 fstat64(3, {st_mode=S_IFREG|0755, st_size=402508, ...})                              = 0 <0.000073>
 +
    0.010032 mmap2(NULL, 466900, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0)            = 0xb692b000 <0.000098>
 +
    0.010893 mprotect(0xb698a000, 61440, PROT_NONE)                                                = 0 <0.000103>
 +
    0.010193 mmap2(0xb6999000, 16384, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x5e000) = 0xb6999000 <0.000141>
 +
    0.011890 close(3)                                                                              = 0 <0.000073>
 +
    0.010150 openat(AT_FDCWD, "/lib/libz.so.1", O_RDONLY|O_CLOEXEC)                                = 3 <0.000149>
 +
    0.009972 read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\300\32\0\0004\0\0\0"..., 512) = 512 <0.000090>
 +
    0.010203 fstat64(3, {st_mode=S_IFREG|0755, st_size=79468, ...})                                = 0 <0.000074>
 +
    0.010227 mmap2(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0)            = 0xb6f9a000 <0.000105>
 +
    0.010939 mmap2(NULL, 143584, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0)            = 0xb6907000 <0.000098>
 +
    0.010737 mprotect(0xb691a000, 61440, PROT_NONE)                                                = 0 <0.000104>
 +
    0.010209 mmap2(0xb6929000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x12000) = 0xb6929000 <0.000152>
 +
    0.011788 close(3)                                                                              = 0 <0.000075>
 +
    0.010144 openat(AT_FDCWD, "/usr/lib/libgstbase-1.0.so.0", O_RDONLY|O_CLOEXEC)                  = 3 <0.000149>
 +
    0.009981 read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\20\244\0\0004\0\0\0"..., 512) = 512 <0.000083>
 +
    0.010217 fstat64(3, {st_mode=S_IFREG|0755, st_size=375700, ...})                              = 0 <0.000073>
 +
    0.010125 mmap2(NULL, 440032, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0)            = 0xb689b000 <0.000104>
 +
    0.010882 mprotect(0xb68f6000, 61440, PROT_NONE)                                                = 0 <0.000110>
 +
    0.010198 mmap2(0xb6905000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x5a000) = 0xb6905000 <0.000149>
 +
    0.011807 close(3)                                                                              = 0 <0.000075>
 +
    0.010290 openat(AT_FDCWD, "/usr/lib/libgmodule-2.0.so.0", O_RDONLY|O_CLOEXEC)                  = 3 <0.000143>
 +
    0.009822 read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\230\f\0\0004\0\0\0"..., 512)  = 512 <0.000081>
 +
    0.010205 fstat64(3, {st_mode=S_IFREG|0755, st_size=13764, ...})                                = 0 <0.000074>
 +
    0.010219 mmap2(NULL, 78056, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0)              = 0xb6887000 <0.000099>
 +
    0.010891 mprotect(0xb6889000, 65536, PROT_NONE)                                                = 0 <0.000106>
 +
    0.010105 mmap2(0xb6899000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x2000) = 0xb6899000 <0.000229>
 +
    0.011760 close(3)                                                                              = 0 <0.000076>
 +
    0.009988 openat(AT_FDCWD, "/lib/librt.so.1", O_RDONLY|O_CLOEXEC)                              = 3 <0.000160>
 +
    0.010017 read(3, "\177ELF\1\1\1\3\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0@\27\0\0004\0\0\0"..., 512)    = 512 <0.000092>
 +
    0.010371 fstat64(3, {st_mode=S_IFREG|0755, st_size=26520, ...})                                = 0 <0.000076>
 +
    0.010039 mmap2(NULL, 90640, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0)              = 0xb6870000 <0.000113>
 +
    0.010881 mprotect(0xb6876000, 61440, PROT_NONE)                                                = 0 <0.000116>
 +
    0.010223 mmap2(0xb6885000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x5000) = 0xb6885000 <0.000169>
 +
    0.011617 close(3)                                                                              = 0 <0.000073>
 +
    0.010093 openat(AT_FDCWD, "/lib/libdl.so.2", O_RDONLY|O_CLOEXEC)                              = 3 <0.000151>
 +
    0.010016 read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0l\t\0\0004\0\0\0"..., 512)    = 512 <0.000088>
 +
    0.010390 fstat64(3, {st_mode=S_IFREG|0755, st_size=9688, ...})                                = 0 <0.000075>
 +
    0.010039 mmap2(NULL, 73916, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0)              = 0xb685d000 <0.000123>
 +
    0.010884 mprotect(0xb685f000, 61440, PROT_NONE)                                                = 0 <0.000108>
 +
    0.010192 mmap2(0xb686e000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1000) = 0xb686e000 <0.000152>
 +
    0.011636 close(3)                                                                              = 0 <0.000073>
 +
    0.010119 openat(AT_FDCWD, "/usr/lib/libpcre.so.1", O_RDONLY|O_CLOEXEC)                        = 3 <0.000151>
 +
    0.010004 read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\10\16\0\0004\0\0\0"..., 512)  = 512 <0.000091>
 +
    0.010378 fstat64(3, {st_mode=S_IFREG|0755, st_size=263672, ...})                              = 0 <0.000075>
 +
    0.010090 mmap2(NULL, 327900, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0)            = 0xb680c000 <0.000107>
 +
    0.010920 mprotect(0xb684c000, 61440, PROT_NONE)                                                = 0 <0.000104>
 +
    0.010024 mmap2(0xb685b000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x3f000) = 0xb685b000 <0.000146>
 +
    0.011805 close(3)                                                                              = 0 <0.000074>
 +
    0.010104 openat(AT_FDCWD, "/usr/lib/libffi.so.6", O_RDONLY|O_CLOEXEC)                          = 3 <0.000143>
 +
    0.010024 read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\\\23\0\0004\0\0\0"..., 512)  = 512 <0.000086>
 +
    0.010382 fstat64(3, {st_mode=S_IFREG|0755, st_size=26232, ...})                                = 0 <0.000073>
 +
    0.010051 mmap2(NULL, 90920, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0)              = 0xb67f5000 <0.000105>
 +
    0.010872 mprotect(0xb67fb000, 61440, PROT_NONE)                                                = 0 <0.000102>
 +
    0.010200 mmap2(0xb680a000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x5000) = 0xb680a000 <0.000148>
 +
    0.011641 close(3)                                                                              = 0 <0.000075>
 +
    0.010292 openat(AT_FDCWD, "/lib/libgcc_s.so.1", O_RDONLY|O_CLOEXEC)                            = 3 <0.000137>
 +
    0.009911 read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\340\320\0\0004\0\0\0"..., 512) = 512 <0.000086>
 +
    0.010385 fstat64(3, {st_mode=S_IFREG|0644, st_size=116300, ...})                              = 0 <0.000074>
 +
    0.010041 mmap2(NULL, 180524, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0)            = 0xb67c8000 <0.000104>
 +
    0.010880 mprotect(0xb67e4000, 61440, PROT_NONE)                                                = 0 <0.000118>
 +
    0.010201 mmap2(0xb67f3000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1b000) = 0xb67f3000 <0.000148>
 +
    0.011796 close(3)                                                                              = 0 <0.000086>
 +
    0.010379 mmap2(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0)            = 0xb6f98000 <0.000101>
 +
    0.010683 set_tls(0xb6f98b20, 0xb6f99218, 0xb6fa5000, 0xb6f98b20, 0xb6fa5000)                  = 0 <0.000072>
 +
    0.010361 mprotect(0xb6ad2000, 8192, PROT_READ)                                                = 0 <0.000142>
 +
    0.009734 mprotect(0xb67f3000, 4096, PROT_READ)                                                = 0 <0.000106>
 +
    0.010069 mprotect(0xb680a000, 4096, PROT_READ)                                                = 0 <0.000097>
 +
    0.010222 mprotect(0xb685b000, 4096, PROT_READ)                                                = 0 <0.000093>
 +
    0.010220 mprotect(0xb686e000, 4096, PROT_READ)                                                = 0 <0.000103>
 +
    0.010384 mprotect(0xb6afd000, 4096, PROT_READ)                                                = 0 <0.000112>
 +
    0.010054 mprotect(0xb6885000, 4096, PROT_READ)                                                = 0 <0.000103>
 +
    0.009813 mprotect(0xb6c80000, 4096, PROT_READ)                                                = 0 <0.000100>
 +
    0.010081 mprotect(0xb6899000, 4096, PROT_READ)                                                = 0 <0.000098>
 +
    0.010369 mprotect(0xb6cd8000, 4096, PROT_READ)                                                = 0 <0.000126>
 +
    0.009958 mprotect(0xb6b7e000, 4096, PROT_READ)                                                = 0 <0.000106>
 +
    0.010580 mprotect(0xb6df6000, 12288, PROT_READ)                                                = 0 <0.000124>
 +
    0.009648 mprotect(0xb6905000, 4096, PROT_READ)                                                = 0 <0.000105>
 +
    0.010043 mprotect(0xb6929000, 4096, PROT_READ)                                                = 0 <0.000104>
 +
    0.010156 mprotect(0xb6999000, 4096, PROT_READ)                                                = 0 <0.000107>
 +
    0.010271 mprotect(0xb6e3f000, 4096, PROT_READ)                                                = 0 <0.000105>
 +
    0.010043 mprotect(0xb6eaa000, 8192, PROT_READ)                                                = 0 <0.000106>
 +
    0.010246 mprotect(0xb6f2b000, 32768, PROT_READ)                                                = 0 <0.000132>
 +
    0.010042 mprotect(0xb6f71000, 8192, PROT_READ)                                                = 0 <0.000108>
 +
    0.009957 mprotect(0x26000, 4096, PROT_READ)                                                    = 0 <0.000105>
 +
    0.010137 mprotect(0xb6fa4000, 4096, PROT_READ)                                                = 0 <0.000107>
 +
    0.010023 munmap(0xb6f9c000, 24533)                                                            = 0 <0.000165>
 +
    0.010125 set_tid_address(0xb6f986c8)                                                          = 865 <0.000069>
 +
    0.010190 set_robust_list(0xb6f986d0, 12)                                                      = 0 <0.000066>
 +
    0.010395 rt_sigaction(SIGRTMIN, {sa_handler=0xb6adc24c, sa_mask=[], sa_flags=SA_RESTORER|SA_SIGINFO, sa_restorer=0xb69c8a60}, NULL, 8) = 0 <0.000084>
 +
    0.013419 rt_sigaction(SIGRT_1, {sa_handler=0xb6adc308, sa_mask=[], sa_flags=SA_RESTORER|SA_RESTART|SA_SIGINFO, sa_restorer=0xb69c8a60}, NULL, 8) = 0 <0.000074>
 +
    0.014382 rt_sigprocmask(SIG_UNBLOCK, [RTMIN RT_1], NULL, 8)                                    = 0 <0.000067>
 +
    0.010288 ugetrlimit(RLIMIT_STACK, {rlim_cur=8192*1024, rlim_max=RLIM_INFINITY})                = 0 <0.000071>
 +
    0.011172 brk(NULL)                                                                            = 0x28000 <0.000079>
 +
    0.009511 brk(0x49000)                                                                          = 0x49000 <0.000099>
 +
    0.012309 futex(0xb6c81cac, FUTEX_WAKE_PRIVATE, 2147483647)                                    = 0 <0.000087>
 +
    0.008552 futex(0xb6c81cac, FUTEX_WAKE_PRIVATE, 2147483647)                                    = 0 <0.000075>
 +
    0.011329 uname({sysname="Linux", nodename="stm32mp1", ...})                                    = 0 <0.000079>
 +
    0.009512 futex(0xb6c81cac, FUTEX_WAKE_PRIVATE, 2147483647)                                    = 0 <0.000084>
 +
    0.009496 futex(0xb6c81cac, FUTEX_WAKE_PRIVATE, 2147483647)                                    = 0 <0.000076>
 +
    0.010059 futex(0xb6c81cac, FUTEX_WAKE_PRIVATE, 2147483647)                                    = 0 <0.000090>
 +
...
 +
    0.000866 poll([{fd=0, events=POLLIN}, {fd=3, events=POLLIN}, {fd=5, events=POLLIN}], 3, 95)    = 0 (Timeout) <0.103064>
 +
    0.103921 getpid()                                                                              = 865 <0.000090>
 +
    0.001614 getpid()                                                                              = 865 <0.000104>
 +
    0.001243 futex(0xb50715f0, FUTEX_WAKE_PRIVATE, 1)                                              = 1 <0.000108>
 +
)                                        = 29 <0.000213> 290:00:01.7/0:00:04.0     
 +
    0.000921 poll([{fd=0, events=POLLIN}, {fd=3, events=POLLIN}, {fd=5, events=POLLIN}], 3, 94)    = 0 (Timeout) <0.102831>
 +
    0.103744 getpid()                                                                              = 865 <0.000117>
 +
    0.000806 futex(0xb50715f0, FUTEX_WAKE_PRIVATE, 1)                                              = 1 <0.000129>
 +
    0.000953 getpid()                                                                              = 865 <0.000101>
 +
)                                        = 29 <0.000230> 290:00:01.8/0:00:04.0     
 +
    0.000919 poll([{fd=0, events=POLLIN}, {fd=3, events=POLLIN}, {fd=5, events=POLLIN}], 3, 94)    = 0 (Timeout) <0.103294>
 +
    0.104092 getpid()                                                                              = 865 <0.000085>
 +
    0.000768 getpid()                                                                              = 865 <0.000076>
 +
)                                  )    = ? ERESTART_RESTARTBLOCK (Interrupted by signal) <0.028771>
 +
strace: Process 865 detached
 +
</syntaxhighlight>
 +
 +
==参考==
 +
: 1. [https://strace.io/ https://strace.io/]
 +
: 2. [http://man7.org/linux/man-pages/man1/strace.1.html http://man7.org/linux/man-pages/man1/strace.1.html]
 +
 +
*有用的外部链接
 +
{| class="wikitable"
 +
|-
 +
! 文件链接 !! 文件类型 !! 描述
 +
|-
 +
| [http://linux.die.net/man/1/strace strace linux.die.net] || 标准 || linux.die.net
 +
|-
 +
| [https://en.wikipedia.org/wiki/strace strace wikipedia.org] || 标准 || wikipedia.org
 +
|-
 +
| 如何使用 strace] || 用户指南 || go4expert.com
 +
|-
 +
| [http://www.thegeekstuff.com/2011/11/strace-examples strace 示例] || 训练 || thegeekstuff.com
 +
|}
 +
 +
 
[[Category:Linux_Operating_System]]
 
[[Category:Linux_Operating_System]]
 
[[Category:Linux_tracing_tools]]
 
[[Category:Linux_tracing_tools]]

2019年12月26日 (四) 15:53的最新版本

Strace

文章目的

本文提供了开始使用 Linux 工具(strace [1 ])所需的基本信息。

简介

下表简要介绍了该工具及其可用性,具体取决于软件包:
  • 是:该工具已经存在(可以使用或激活),也可以在软件包中集成和激活。
  • 没有:该工具不存在且无法集成,或者存在但无法在软件包中激活。
工具
名称 类别 目的
Strace 追踪工具 strace [1 ]能够截获和记录一个进程调用的系统调用以及另一个进程接收的信号。
STM32MPU嵌入式软件发行版
入门资料包 开发者资料包 发行版资料包
适用于 Android 的STM32MPU嵌入式软件发行版
入门资料包 开发者资料包 发行版资料包

在目标板上安装跟踪和调试工具

使用 STM32MPU 嵌入式软件发行版

strace 默认情况下已安装,可以与所有 STM32MPU 嵌入式软件包一起使用。
	Board $> which strace
	/usr/bin/strace
strace 通过 meta-st 软件包集成到 weston 镜像分发中:meta-st/meta-st-openstlinux/recipes-st/packagegroups/packagegroup-framework-tools.bb 。
	RDEPENDS_packagegroup-framework-tools-kernel-base = "\
	   can-utils       \
	   i2c-tools       \
	   strace          \
	   usbutils        \
	   \
	   evtest          \
	   memtester       \
	   mtd-utils       \
	   v4l-utils       \
	   "

使用适用于 Android 的 STM32MPU 嵌入式软件发行版

strace 默认情况下已安装(/system/bin/strace),并准备与所有适用于 Android 的 STM32MPU 软件包一起使用。
	Board $> which strace
	/system/bin/strace
它通过 Android 基本的 makefile 集成在 Android 镜像分发中 build/make/target/product/base.mk:
	# Packages included only for eng or userdebug builds, previously debug tagged
	PRODUCT_PACKAGES_DEBUG := \
	    logpersist.start \
	    perfprofd \
	    sqlite3 \
	    strace

使用入门

要使用strace,有两种主要方法:
通过提供要列出其系统调用的程序的名称作为参数,并在需要时为其指定参数作为参数运行:
	Board $> strace <Program> [Prog_Args]
通过给出要研究的过程的PID作为参数:
	Board $> strace -p <PID>
一些有用的命令选项:
	-a <num> : alignment num COLUMN for printing syscall results
	-r : print relative timestamp
	-t : print absolute timestamp
	-T : print time spent in each syscall
还可以设置其他选项。有关详细信息,请参阅手册页[2 ]。

深入学习

示例

例如,可以通过 gst-play 获得系统调用来播放多媒体文件:
	Board $> strace -rT -a 100 gst-play-1.0 /usr/local/demo/media/ST2297_visionv3.webm
	     0.000000 execve("/usr/bin/gst-play-1.0", ["gst-play-1.0", "[...]"...], 0xbeb10c00 /* 24 vars */) = 0 <0.001485>
	     0.002800 brk(NULL)                                                                             = 0x28000 <0.000069>
	     0.000717 uname({sysname="Linux", nodename="stm32mp1", ...})                                    = 0 <0.000069>
	     0.000591 mmap2(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0)             = 0xb6fa2000 <0.000093>
	     0.000673 access("/etc/ld.so.preload", R_OK)                                                    = -1 ENOENT (No such file or directory) <0.000109>
	     0.000734 openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC)                              = 3 <0.000115>
	     0.000669 fstat64(3, {st_mode=S_IFREG|0644, st_size=24533, ...})                                = 0 <0.000069>
	     0.000619 mmap2(NULL, 24533, PROT_READ, MAP_PRIVATE, 3, 0)                                      = 0xb6f9c000 <0.000091>
	     0.000599 close(3)                                                                              = 0 <0.000065>
	     0.000668 openat(AT_FDCWD, "/usr/lib/libgstpbutils-1.0.so.0", O_RDONLY|O_CLOEXEC)               = 3 <0.000114>
	     0.000646 read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\300\234\0\0004\0\0\0"..., 512) = 512 <0.000083>
	     0.000611 fstat64(3, {st_mode=S_IFREG|0755, st_size=195640, ...})                               = 0 <0.000080>
	     0.000712 mmap2(NULL, 260004, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0)             = 0xb6f34000 <0.000088>
	     0.000596 mprotect(0xb6f62000, 61440, PROT_NONE)                                                = 0 <0.000098>
	     0.000609 mmap2(0xb6f71000, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x2d000) = 0xb6f71000 <0.000147>
	     0.000811 close(3)                                                                              = 0 <0.000070>
	     0.000706 openat(AT_FDCWD, "/usr/lib/libgstvideo-1.0.so.0", O_RDONLY|O_CLOEXEC)                 = 3 <0.000138>
	     0.000754 read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0P\317\0\0004\0\0\0"..., 512)   = 512 <0.000079>
	     0.000612 fstat64(3, {st_mode=S_IFREG|0755, st_size=486440, ...})                               = 0 <0.000070>
	     0.000618 mmap2(NULL, 552344, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0)             = 0xb6ead000 <0.000087>
	     0.000601 mprotect(0xb6f1c000, 61440, PROT_NONE)                                                = 0 <0.000092>
	     0.000610 mmap2(0xb6f2b000, 36864, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x6e000) = 0xb6f2b000 <0.000132>
	     0.000709 close(3)                                                                              = 0 <0.000067>
	     0.000712 openat(AT_FDCWD, "/usr/lib/libgstaudio-1.0.so.0", O_RDONLY|O_CLOEXEC)                 = 3 <0.000121>
	     0.000673 read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\0\236\0\0004\0\0\0"..., 512)  = 512 <0.000078>
	     0.000606 fstat64(3, {st_mode=S_IFREG|0755, st_size=375816, ...})                               = 0 <0.000067>
	     0.000623 mmap2(NULL, 440684, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0)             = 0xb6e41000 <0.000150>
	     0.000692 mprotect(0xb6e9b000, 61440, PROT_NONE)                                                = 0 <0.000096>
	     0.000606 mmap2(0xb6eaa000, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x59000) = 0xb6eaa000 <0.000130>
	     0.000722 close(3)                                                                              = 0 <0.000071>
	     0.000700 openat(AT_FDCWD, "/usr/lib/libgsttag-1.0.so.0", O_RDONLY|O_CLOEXEC)                   = 3 <0.000135>
	     0.000755 read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\370d\0\0004\0\0\0"..., 512)   = 512 <0.000080>
	     0.000613 fstat64(3, {st_mode=S_IFREG|0755, st_size=215824, ...})                               = 0 <0.000068>
	     0.000617 mmap2(NULL, 280136, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0)             = 0xb6dfc000 <0.000087>
	     0.000597 mprotect(0xb6e2f000, 65536, PROT_NONE)                                                = 0 <0.000090>
	     0.000617 mmap2(0xb6e3f000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x33000) = 0xb6e3f000 <0.000121>
	     0.000702 close(3)                                                                              = 0 <0.000070>
	     0.009092 openat(AT_FDCWD, "/usr/lib/libgstreamer-1.0.so.0", O_RDONLY|O_CLOEXEC)                = 3 <0.000146>
	     0.010000 read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\270\371\1\0004\0\0\0"..., 512) = 512 <0.000088>
	     0.010392 fstat64(3, {st_mode=S_IFREG|0755, st_size=1116268, ...})                              = 0 <0.000072>
	     0.010210 mmap2(NULL, 1184392, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0)            = 0xb6cda000 <0.000107>
	     0.010879 mprotect(0xb6de7000, 61440, PROT_NONE)                                                = 0 <0.000106>
	     0.010048 mmap2(0xb6df6000, 20480, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x10c000) = 0xb6df6000 <0.000186>
	     0.011926 mmap2(0xb6dfb000, 648, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xb6dfb000 <0.000141>
	     0.011239 close(3)                                                                              = 0 <0.000073>
	     0.010260 openat(AT_FDCWD, "/usr/lib/libgobject-2.0.so.0", O_RDONLY|O_CLOEXEC)                  = 3 <0.000147>
	     0.009916 read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\250\212\0\0004\0\0\0"..., 512) = 512 <0.000095>
	     0.010372 fstat64(3, {st_mode=S_IFREG|0755, st_size=294000, ...})                               = 0 <0.000075>
	     0.010086 mmap2(NULL, 359636, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0)             = 0xb6c82000 <0.000102>
	     0.010916 mprotect(0xb6cc9000, 61440, PROT_NONE)                                                = 0 <0.000103>
	     0.010033 mmap2(0xb6cd8000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x46000) = 0xb6cd8000 <0.000143>
	     0.011876 close(3)                                                                              = 0 <0.000074>
	     0.010153 openat(AT_FDCWD, "/usr/lib/libglib-2.0.so.0", O_RDONLY|O_CLOEXEC)                     = 3 <0.000146>
	     0.009983 read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0XX\1\0004\0\0\0"..., 512)      = 512 <0.000088>
	     0.010209 fstat64(3, {st_mode=S_IFREG|0755, st_size=990348, ...})                               = 0 <0.000075>
	     0.010215 mmap2(NULL, 1056232, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0)            = 0xb6b80000 <0.000103>
	     0.010881 mprotect(0xb6c71000, 61440, PROT_NONE)                                                = 0 <0.000100>
	     0.010032 mmap2(0xb6c80000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0xf0000) = 0xb6c80000 <0.000150>
	     0.011792 close(3)                                                                              = 0 <0.000073>
	     0.010218 openat(AT_FDCWD, "/lib/libm.so.6", O_RDONLY|O_CLOEXEC)                                = 3 <0.000140>
	     0.010000 read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\220E\0\0004\0\0\0"..., 512)   = 512 <0.000084>
	     0.010212 fstat64(3, {st_mode=S_IFREG|0755, st_size=452028, ...})                               = 0 <0.000073>
	     0.010207 mmap2(NULL, 516216, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0)             = 0xb6b01000 <0.000101>
	     0.010877 mprotect(0xb6b6f000, 61440, PROT_NONE)                                                = 0 <0.000110>
	     0.010035 mmap2(0xb6b7e000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x6d000) = 0xb6b7e000 <0.000152>
	     0.011806 close(3)                                                                              = 0 <0.000075>
	     0.010130 openat(AT_FDCWD, "/lib/libpthread.so.0", O_RDONLY|O_CLOEXEC)                          = 3 <0.000134>
	     0.010086 read(3, "\177ELF\1\1\1\3\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\214H\0\0004\0\0\0"..., 512)   = 512 <0.000085>
	     0.010211 fstat64(3, {st_mode=S_IFREG|0755, st_size=92656, ...})                                = 0 <0.000074>
	     0.010208 mmap2(NULL, 164424, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0)             = 0xb6ad8000 <0.000100>
	     0.010813 mprotect(0xb6aee000, 61440, PROT_NONE)                                                = 0 <0.000108>
	     0.010205 mmap2(0xb6afd000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x15000) = 0xb6afd000 <0.000172>
	     0.011742 mmap2(0xb6aff000, 4680, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xb6aff000 <0.000137>
	     0.011249 close(3)                                                                              = 0 <0.000072>
	     0.010170 openat(AT_FDCWD, "/lib/libc.so.6", O_RDONLY|O_CLOEXEC)                                = 3 <0.000149>
	     0.009988 read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\34l\1\0004\0\0\0"..., 512)    = 512 <0.000088>
	     0.010219 fstat64(3, {st_mode=S_IFREG|0755, st_size=1218336, ...})                              = 0 <0.000075>
	     0.010198 mmap2(NULL, 1287556, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0)            = 0xb699d000 <0.000105>
	     0.010876 mprotect(0xb6ac3000, 61440, PROT_NONE)                                                = 0 <0.000132>
	     0.010123 mmap2(0xb6ad2000, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x125000) = 0xb6ad2000 <0.000177>
	     0.011925 mmap2(0xb6ad5000, 9604, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xb6ad5000 <0.000141>
	     0.011252 close(3)                                                                              = 0 <0.000077>
	     0.010267 openat(AT_FDCWD, "/usr/lib/liborc-0.4.so.0", O_RDONLY|O_CLOEXEC)                      = 3 <0.000150>
	     0.009799 read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0`u\0\0004\0\0\0"..., 512)      = 512 <0.000090>
	     0.010386 fstat64(3, {st_mode=S_IFREG|0755, st_size=402508, ...})                               = 0 <0.000073>
	     0.010032 mmap2(NULL, 466900, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0)             = 0xb692b000 <0.000098>
	     0.010893 mprotect(0xb698a000, 61440, PROT_NONE)                                                = 0 <0.000103>
	     0.010193 mmap2(0xb6999000, 16384, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x5e000) = 0xb6999000 <0.000141>
	     0.011890 close(3)                                                                              = 0 <0.000073>
	     0.010150 openat(AT_FDCWD, "/lib/libz.so.1", O_RDONLY|O_CLOEXEC)                                = 3 <0.000149>
	     0.009972 read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\300\32\0\0004\0\0\0"..., 512) = 512 <0.000090>
	     0.010203 fstat64(3, {st_mode=S_IFREG|0755, st_size=79468, ...})                                = 0 <0.000074>
	     0.010227 mmap2(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0)             = 0xb6f9a000 <0.000105>
	     0.010939 mmap2(NULL, 143584, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0)             = 0xb6907000 <0.000098>
	     0.010737 mprotect(0xb691a000, 61440, PROT_NONE)                                                = 0 <0.000104>
	     0.010209 mmap2(0xb6929000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x12000) = 0xb6929000 <0.000152>
	     0.011788 close(3)                                                                              = 0 <0.000075>
	     0.010144 openat(AT_FDCWD, "/usr/lib/libgstbase-1.0.so.0", O_RDONLY|O_CLOEXEC)                  = 3 <0.000149>
	     0.009981 read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\20\244\0\0004\0\0\0"..., 512) = 512 <0.000083>
	     0.010217 fstat64(3, {st_mode=S_IFREG|0755, st_size=375700, ...})                               = 0 <0.000073>
	     0.010125 mmap2(NULL, 440032, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0)             = 0xb689b000 <0.000104>
	     0.010882 mprotect(0xb68f6000, 61440, PROT_NONE)                                                = 0 <0.000110>
	     0.010198 mmap2(0xb6905000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x5a000) = 0xb6905000 <0.000149>
	     0.011807 close(3)                                                                              = 0 <0.000075>
	     0.010290 openat(AT_FDCWD, "/usr/lib/libgmodule-2.0.so.0", O_RDONLY|O_CLOEXEC)                  = 3 <0.000143>
	     0.009822 read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\230\f\0\0004\0\0\0"..., 512)  = 512 <0.000081>
	     0.010205 fstat64(3, {st_mode=S_IFREG|0755, st_size=13764, ...})                                = 0 <0.000074>
	     0.010219 mmap2(NULL, 78056, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0)              = 0xb6887000 <0.000099>
	     0.010891 mprotect(0xb6889000, 65536, PROT_NONE)                                                = 0 <0.000106>
	     0.010105 mmap2(0xb6899000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x2000) = 0xb6899000 <0.000229>
	     0.011760 close(3)                                                                              = 0 <0.000076>
	     0.009988 openat(AT_FDCWD, "/lib/librt.so.1", O_RDONLY|O_CLOEXEC)                               = 3 <0.000160>
	     0.010017 read(3, "\177ELF\1\1\1\3\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0@\27\0\0004\0\0\0"..., 512)    = 512 <0.000092>
	     0.010371 fstat64(3, {st_mode=S_IFREG|0755, st_size=26520, ...})                                = 0 <0.000076>
	     0.010039 mmap2(NULL, 90640, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0)              = 0xb6870000 <0.000113>
	     0.010881 mprotect(0xb6876000, 61440, PROT_NONE)                                                = 0 <0.000116>
	     0.010223 mmap2(0xb6885000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x5000) = 0xb6885000 <0.000169>
	     0.011617 close(3)                                                                              = 0 <0.000073>
	     0.010093 openat(AT_FDCWD, "/lib/libdl.so.2", O_RDONLY|O_CLOEXEC)                               = 3 <0.000151>
	     0.010016 read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0l\t\0\0004\0\0\0"..., 512)     = 512 <0.000088>
	     0.010390 fstat64(3, {st_mode=S_IFREG|0755, st_size=9688, ...})                                 = 0 <0.000075>
	     0.010039 mmap2(NULL, 73916, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0)              = 0xb685d000 <0.000123>
	     0.010884 mprotect(0xb685f000, 61440, PROT_NONE)                                                = 0 <0.000108>
	     0.010192 mmap2(0xb686e000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1000) = 0xb686e000 <0.000152>
	     0.011636 close(3)                                                                              = 0 <0.000073>
	     0.010119 openat(AT_FDCWD, "/usr/lib/libpcre.so.1", O_RDONLY|O_CLOEXEC)                         = 3 <0.000151>
	     0.010004 read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\10\16\0\0004\0\0\0"..., 512)  = 512 <0.000091>
	     0.010378 fstat64(3, {st_mode=S_IFREG|0755, st_size=263672, ...})                               = 0 <0.000075>
	     0.010090 mmap2(NULL, 327900, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0)             = 0xb680c000 <0.000107>
	     0.010920 mprotect(0xb684c000, 61440, PROT_NONE)                                                = 0 <0.000104>
	     0.010024 mmap2(0xb685b000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x3f000) = 0xb685b000 <0.000146>
	     0.011805 close(3)                                                                              = 0 <0.000074>
	     0.010104 openat(AT_FDCWD, "/usr/lib/libffi.so.6", O_RDONLY|O_CLOEXEC)                          = 3 <0.000143>
	     0.010024 read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\\\23\0\0004\0\0\0"..., 512)   = 512 <0.000086>
	     0.010382 fstat64(3, {st_mode=S_IFREG|0755, st_size=26232, ...})                                = 0 <0.000073>
	     0.010051 mmap2(NULL, 90920, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0)              = 0xb67f5000 <0.000105>
	     0.010872 mprotect(0xb67fb000, 61440, PROT_NONE)                                                = 0 <0.000102>
	     0.010200 mmap2(0xb680a000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x5000) = 0xb680a000 <0.000148>
	     0.011641 close(3)                                                                              = 0 <0.000075>
	     0.010292 openat(AT_FDCWD, "/lib/libgcc_s.so.1", O_RDONLY|O_CLOEXEC)                            = 3 <0.000137>
	     0.009911 read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\340\320\0\0004\0\0\0"..., 512) = 512 <0.000086>
	     0.010385 fstat64(3, {st_mode=S_IFREG|0644, st_size=116300, ...})                               = 0 <0.000074>
	     0.010041 mmap2(NULL, 180524, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0)             = 0xb67c8000 <0.000104>
	     0.010880 mprotect(0xb67e4000, 61440, PROT_NONE)                                                = 0 <0.000118>
	     0.010201 mmap2(0xb67f3000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1b000) = 0xb67f3000 <0.000148>
	     0.011796 close(3)                                                                              = 0 <0.000086>
	     0.010379 mmap2(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0)             = 0xb6f98000 <0.000101>
	     0.010683 set_tls(0xb6f98b20, 0xb6f99218, 0xb6fa5000, 0xb6f98b20, 0xb6fa5000)                   = 0 <0.000072>
	     0.010361 mprotect(0xb6ad2000, 8192, PROT_READ)                                                 = 0 <0.000142>
	     0.009734 mprotect(0xb67f3000, 4096, PROT_READ)                                                 = 0 <0.000106>
	     0.010069 mprotect(0xb680a000, 4096, PROT_READ)                                                 = 0 <0.000097>
	     0.010222 mprotect(0xb685b000, 4096, PROT_READ)                                                 = 0 <0.000093>
	     0.010220 mprotect(0xb686e000, 4096, PROT_READ)                                                 = 0 <0.000103>
	     0.010384 mprotect(0xb6afd000, 4096, PROT_READ)                                                 = 0 <0.000112>
	     0.010054 mprotect(0xb6885000, 4096, PROT_READ)                                                 = 0 <0.000103>
	     0.009813 mprotect(0xb6c80000, 4096, PROT_READ)                                                 = 0 <0.000100>
	     0.010081 mprotect(0xb6899000, 4096, PROT_READ)                                                 = 0 <0.000098>
	     0.010369 mprotect(0xb6cd8000, 4096, PROT_READ)                                                 = 0 <0.000126>
	     0.009958 mprotect(0xb6b7e000, 4096, PROT_READ)                                                 = 0 <0.000106>
	     0.010580 mprotect(0xb6df6000, 12288, PROT_READ)                                                = 0 <0.000124>
	     0.009648 mprotect(0xb6905000, 4096, PROT_READ)                                                 = 0 <0.000105>
	     0.010043 mprotect(0xb6929000, 4096, PROT_READ)                                                 = 0 <0.000104>
	     0.010156 mprotect(0xb6999000, 4096, PROT_READ)                                                 = 0 <0.000107>
	     0.010271 mprotect(0xb6e3f000, 4096, PROT_READ)                                                 = 0 <0.000105>
	     0.010043 mprotect(0xb6eaa000, 8192, PROT_READ)                                                 = 0 <0.000106>
	     0.010246 mprotect(0xb6f2b000, 32768, PROT_READ)                                                = 0 <0.000132>
	     0.010042 mprotect(0xb6f71000, 8192, PROT_READ)                                                 = 0 <0.000108>
	     0.009957 mprotect(0x26000, 4096, PROT_READ)                                                    = 0 <0.000105>
	     0.010137 mprotect(0xb6fa4000, 4096, PROT_READ)                                                 = 0 <0.000107>
	     0.010023 munmap(0xb6f9c000, 24533)                                                             = 0 <0.000165>
	     0.010125 set_tid_address(0xb6f986c8)                                                           = 865 <0.000069>
	     0.010190 set_robust_list(0xb6f986d0, 12)                                                       = 0 <0.000066>
	     0.010395 rt_sigaction(SIGRTMIN, {sa_handler=0xb6adc24c, sa_mask=[], sa_flags=SA_RESTORER|SA_SIGINFO, sa_restorer=0xb69c8a60}, NULL, 8) = 0 <0.000084>
	     0.013419 rt_sigaction(SIGRT_1, {sa_handler=0xb6adc308, sa_mask=[], sa_flags=SA_RESTORER|SA_RESTART|SA_SIGINFO, sa_restorer=0xb69c8a60}, NULL, 8) = 0 <0.000074>
	     0.014382 rt_sigprocmask(SIG_UNBLOCK, [RTMIN RT_1], NULL, 8)                                    = 0 <0.000067>
	     0.010288 ugetrlimit(RLIMIT_STACK, {rlim_cur=8192*1024, rlim_max=RLIM_INFINITY})                = 0 <0.000071>
	     0.011172 brk(NULL)                                                                             = 0x28000 <0.000079>
	     0.009511 brk(0x49000)                                                                          = 0x49000 <0.000099>
	     0.012309 futex(0xb6c81cac, FUTEX_WAKE_PRIVATE, 2147483647)                                     = 0 <0.000087>
	     0.008552 futex(0xb6c81cac, FUTEX_WAKE_PRIVATE, 2147483647)                                     = 0 <0.000075>
	     0.011329 uname({sysname="Linux", nodename="stm32mp1", ...})                                    = 0 <0.000079>
	     0.009512 futex(0xb6c81cac, FUTEX_WAKE_PRIVATE, 2147483647)                                     = 0 <0.000084>
	     0.009496 futex(0xb6c81cac, FUTEX_WAKE_PRIVATE, 2147483647)                                     = 0 <0.000076>
	     0.010059 futex(0xb6c81cac, FUTEX_WAKE_PRIVATE, 2147483647)                                     = 0 <0.000090>
	...
	     0.000866 poll([{fd=0, events=POLLIN}, {fd=3, events=POLLIN}, {fd=5, events=POLLIN}], 3, 95)    = 0 (Timeout) <0.103064>
	     0.103921 getpid()                                                                              = 865 <0.000090>
	     0.001614 getpid()                                                                              = 865 <0.000104>
	     0.001243 futex(0xb50715f0, FUTEX_WAKE_PRIVATE, 1)                                              = 1 <0.000108>
	)                                        = 29 <0.000213> 290:00:01.7/0:00:04.0       
	     0.000921 poll([{fd=0, events=POLLIN}, {fd=3, events=POLLIN}, {fd=5, events=POLLIN}], 3, 94)    = 0 (Timeout) <0.102831>
	     0.103744 getpid()                                                                              = 865 <0.000117>
	     0.000806 futex(0xb50715f0, FUTEX_WAKE_PRIVATE, 1)                                              = 1 <0.000129>
	     0.000953 getpid()                                                                              = 865 <0.000101>
	)                                        = 29 <0.000230> 290:00:01.8/0:00:04.0       
	     0.000919 poll([{fd=0, events=POLLIN}, {fd=3, events=POLLIN}, {fd=5, events=POLLIN}], 3, 94)    = 0 (Timeout) <0.103294>
	     0.104092 getpid()                                                                              = 865 <0.000085>
	     0.000768 getpid()                                                                              = 865 <0.000076>
	)                                   )    = ? ERESTART_RESTARTBLOCK (Interrupted by signal) <0.028771>
	strace: Process 865 detached

参考

1. https://strace.io/
2. http://man7.org/linux/man-pages/man1/strace.1.html
  • 有用的外部链接
文件链接 文件类型 描述
strace linux.die.net 标准 linux.die.net
strace wikipedia.org 标准 wikipedia.org
如何使用 strace] 用户指南 go4expert.com
strace 示例 训练 thegeekstuff.com