Files
tldr/pages.zh/linux/strace.md

32 lines
863 B
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# strace
> 用于跟踪系统调用的故障排除工具。
> 更多信息:<https://manned.org/strace>。
- 通过进程IDPID开始跟踪特定的[p]rocess
`strace -p {{pid}}`
- 跟踪一个[p]rocess并通过系统调用过滤输出
`strace -p {{pid}} -e {{system_call,system_call2,...}}`
- 计算每个系统调用的时间、调用次数和错误,并在程序退出时报告摘要:
`strace -p {{pid}} -c`
- 显示每个系统调用所花费的[T]ime并指定要打印的最大字符串[s]ize
`strace -p {{pid}} -T -s {{32}}`
- 通过执行程序开始跟踪:
`strace {{program}}`
- 开始跟踪程序的文件操作:
`strace -e trace=file {{program}}`
- 开始跟踪程序的网络操作以及所有其[f]orked和子进程将[o]utput保存到文件中
`strace -f -e trace=network -o {{trace.txt}} {{program}}`