3. 显示 find 命令的线程标识和常规输出,输入:
truss -l find . -print >find.out
4. 显示 find 命令的时间戳记和常规输出,输入:
truss -d find . -print >find.out
5. 显示 find 命令的增量时间和常规输出,输入:
truss -D find . -print >find.out
6. 运行 ls 命令时,在 libc.a 库中跟踪 malloc() 函数调用及除去 strlen() 函数调用,输入:
truss -u libc.a::malloc,!strlen ls
7. 运行 ls 命令时,跟踪 libc.a 库中名称以“m”开头的所有函数调用,输入:
truss -u libc.a::m*,!strlen ls
8. 运行可执行 foo 时,跟踪来自 libcurses.a 库的所有函数调用及除去来自 libc.a 的调用,输入:
truss -u libcurses.a,!libc.a::* foo
9. 运行可执行 foo 时,跟踪来自 libcurses.a 的 refresh() 函数调用和来自 libc.a 的 malloc() 函数调用,输入:
truss -u libc.a::malloc -u libcurses.a::refresh foo
下面是一个英文版本的介绍和范例。
Truss is used to trace the system/library calls (not user calls) and signals made/received by a new or existing process. It sends the output to stderr.
NOTE: Trussing a process throttles that process to your display speed. Use -wall and -rall sparingly. [Page]
Truss usage
truss -a -e -f -rall -wall -p
truss -a -e -f -rall -wall
-a Show arguments passed to the exec system calls
-e Show environment variables passed to the exec system calls
-f Show forked processes
(they will have a different pid: in column 1)
-rall Show all read data (default is 32 bytes)
-wall Show all written data (default is 32 bytes)
-p Hook to an existing process (must be owner or root)
Specify a program to run
文章来源于领测软件测试网 https://www.ltesting.net/