使用dtrace跟踪系统调用 [英] Tracing system calls using dtrace
问题描述
我正在运行一个进程ID为 423
的应用程序.基本上想调试这个过程.
I am running an application that runs with a process Id 423
.
Basically want to debug this process.
问题是,使用命令 sudo dtruss -a -t open_nocancel -p 423
我看不到打印消息已执行,而且 sudo kill -30 423
之类的系统信号似乎也没有显示在堆栈中痕迹.我想念什么吗?我该如何实现呢?
The problem is that,
using the command sudo dtruss -a -t open_nocancel -p 423
I dont see print messages executed and also systems signals like sudo kill -30 423
dont seem to show in the stack trace. Am I missing something?. How do I achieve this?.
下面的示例堆栈跟踪
PID/THRD RELATIVE ELAPSD CPU SYSCALL(args) = return
423/0xcf5: 109498638 14 9 open_nocancel("/Users/krishna/.rstudio-desktop/sdb/s-3F25A09C/373AE888\0", 0x0, 0x1B6) = 21 0
423/0xcf5: 109509540 20 16 open_nocancel("/Users/krishna/.rstudio-desktop/history_database\0", 0x209, 0x1B6) = 20 0
423/0xcf5: 109510342 56 44 open_nocancel(".\0", 0x0, 0x1) = 20 0
423/0xcf5: 109516113 19 15 open_nocancel("/Users/krishna/.rstudio-desktop/history_database\0", 0x209, 0x1B6) = 20 0
423/0xcf5: 109517099 35 30 open_nocancel(".\0", 0x0, 0x1) = 20 0
423/0xcf5: 109576820 16 11 open_nocancel("/Users/krishna/.rstudio-desktop/sdb/s-3F25A09C/373AE888\0", 0x0, 0x1B6) = 21 0
423/0xcf5: 109673038 16 10 open_nocancel("/Users/krishna/.rstudio-desktop/sdb/s-3F25A09C/373AE888\0", 0x0, 0x1B6) = 21 0
推荐答案
命令 sudo dtruss -a -t open_nocancel -p 423
将仅跟踪 open_nocancel
系统调用.根据用于 dtruss
:
The command sudo dtruss -a -t open_nocancel -p 423
will trace only the open_nocancel
system call. Per the OS X man page for dtruss
:
NAME
dtruss - process syscall details. Uses DTrace.
SYNOPSIS
dtruss [-acdeflhoLs] [-t syscall] { -p PID | -n name | command }
...
-t syscall
examine this syscall only
如果要跟踪其他系统调用,则需要更改 -t ...
参数,或将其删除.
If you want to trace other system calls, you need to either change the -t ...
argument, or remove it.
这篇关于使用dtrace跟踪系统调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!