dtruss & strace

dtruss for Mac

strace for Linux

Top 10 DTrace scripts for Mac OS X

NAME
       dtruss - process syscall details. Uses DTrace.

SYNOPSIS
       dtruss [-acdeflhoLs] [-t syscall] { -p PID | -n name | command }

DESCRIPTION
       dtruss  prints  details  on  process system calls. It is like a DTrace version of truss, and has been
       designed to be less intrusive than truss.

       Of particular interest is the elapsed times and on cpu times, which can identify  both  system  calls
       that are slow to complete, and those which are consuming CPU cycles.

       Since this uses DTrace, only users with root privileges can run this command.

OPTIONS
       -a     print all details

       -b bufsize
              dynamic  variable  buffer  size. Increase this if you notice dynamic variable drop errors. The
              default is "4m" for 4 megabytes per CPU.

       -c     print system call counts

       -d     print relative timestamps, us

       -e     print elapsed times, us

       -f     follow children as they are forked

       -l     force printing of pid/lwpid per line

       -L     don't print pid/lwpid per line

       -n name
              examine processes with this name

       -o     print on-cpu times, us

       -s     print stack backtraces

       -p PID examine this PID

       -t syscall
              examine this syscall only

EXAMPLES
       run and examine the "df -h" command
              # dtruss df -h

       examine PID 1871
              # dtruss -p 1871

       examine all processes called "tar"
              # dtruss -n tar

       run test.sh and follow children
              # dtruss -f test.sh

       run the "date" command and print elapsed and on cpu times,
              # dtruss -eo date

FIELDS
       PID/LWPID
              Process ID / Lightweight Process ID

       RELATIVE
              relative timestamps to the start of the thread, us (microseconds)

       ELAPSD elapsed time for this system call, us

       CPU    on-cpu time for this system call, us

       SYSCALL(args)
              system call name, with arguments (some may be evaluated)

DOCUMENTATION
       See the DTraceToolkit for further documentation under the Docs directory. The DTraceToolkit docs  may
       include full worked examples with verbose descriptions explaining the output.

EXIT
       dtruss will run forever until Ctrl-C is hit, or if a command was executed dtruss will finish when the
       command ends.

AUTHOR
       Brendan Gregg [Sydney, Australia]

SEE ALSO
       procsystime(1M), dtrace(1M), truss(1)
时间: 2024-09-20 00:57:55

dtruss & strace的相关文章

Linux中strace、pstack命令用法

可谓是 linux 下的调试利器,不仅可以用来找程序错误,系统为什么挂死了,命令为什么报错,还可以用来查找哪些程序占用系统资源. 命令实例 比如,但网站服务器负载过大,网站数量又多,不知是那个网站占用太多资源,这时strace派上用场了. 第一步,查看 php-cgi 进程号: ps aux|grep php-cgi 第二步,查看系统调用 strace -p 进程号 或者,将记录结果存在output.txt文件中 strace -o output.txt -T -tt -e trace=all

系统调用追踪工具strace

当我们想知道某个进程为什么突然卡了,或者是某个工具到底是如何实现的时候.strace就派上了用场.它能将程序的调用信息打印出来. strace原理: 它的实现基础是ptrace系统调用.ptrace系统调用提供了一种方法来跟踪和控制进程的执行,它可以读取和修改进程地址空间中的内容,包括寄存器的值.ptrace主要用于实现断点调试和跟踪系统调用. ptrace系统调用 1 #include <sys/ptrace.h> 2 int ptrace(int request, int pid, int

Linux系统中strace命令的使用教程

  在调试的时候,strace能帮助你追踪到一个程序所执行的系统调用.当你想知道程序和操作系统如何交互的时候,这是极其方便的,比如你想知道执行了哪些系统调用,并且以何种顺序执行. 这个简单而又强大的工具几乎在所有的Linux操作系统上可用,并且可被用来调试大量的程序. 命令用法 让我们看看strace命令如何追踪一个程序的执行情况. 最简单的形式,strace后面可以跟任何命令.它将列出许许多多的系统调用.一开始,我们并不能理解所有的输出,但是如果你正在寻找一些特殊的东西,那么你应该能从输出中发

linux的strace命令

  strace 命令是一种强大的工具,它能够显示所有由用户空间程序发出的系统调用. strace 显示这些调用的参数并返回符号形式的值.strace 从内核接收信息,而且不需要以任何特殊的方式来构建内核. 下面记录几个常用 option . 1 -f -F选项告诉strace同时跟踪fork和vfork出来的进程 2 -o xxx.txt 输出到某个文件. 3 -e execve 只记录 execve 这类系统调用 ----------------- 进程无法启动,软件运行速度突然变慢,程序的

应用-关于Android中strace的问题

问题描述 关于Android中strace的问题 5C 请教各位大神,在Android中用strace可以监控到应用调用了哪个驱动文件么 解决方案 Android - strace runtimeAndroid - strace runtimeAndroid - strace runtime

linux跟踪线程的方法:LWP和strace命令

摘要:在使用多线程程序时,有时会遇到程序功能异常的情况,而这种异常情况并不是每次都发生,很难模拟出来.这时就需要运用在程序运行时跟踪线程的手段,而linux系统的LWP和strace命令正是这种技术手段.本文对LWP和strace命令做了简明扼要的介绍,并通过一个实例来说明如何运用.总而言之,LWP和strace的使用可以提高多线程程序的可维护性. 问题描述: 我们来看一个问题:程序tcp_client同时创建多个线程向同一个服务器发送数据,每个线程发送不同类型的数据,服务器接收数据后,可以通过

Linux系统小技巧(6):刀锋组合-strace和wireshark工具

首先声明下,此处wireshark,可以替换为tcpdump.同样,strace偶尔也可以替换为ltrace,只要熟悉库函数就好. wireshark和strace,对于黑客而言,都是工具箱中的必备工具.有过排查和诊断经历的工程师,谁没有抓包和分析包的经历呢? 相对而言,strace的名气要小一些,毕竟有意愿.有能力追踪并且能够分析进程执行路径的不多.而且常见的系统调用也有二三十个. 系统调用如此强力,why? 让我们先明确下为什么strace工具颇具威力,看图 虽然Linux已经足够复杂,而且

自助Linux之问题诊断工具strace

引言 "Oops,系统挂死了..." "Oops,程序崩溃了..." "Oops,命令执行报错..."   对于维护人员来说,这样的悲剧每天都在上演.理想情况下,系统或应用程序的错误日志提供了足够全面的信息,通过查看相关日志,维护人员就能很快地定位出问题发生的原因.但现实情况,许多错误日志打印模凌两可,更多地描述了出错时的现象(比如"could not open file","connect to XXX time

Linux调试工具strace和gdb常用命令小结

strace和gdb是Linux环境下的两个常用调试工具,这里是个人在使用过程中对这两个工具常用参数的总结,留作日后查看使用. strace调试工具 strace工具用于跟踪进程执行时的系统调用和所接收的信号,包括参数.返回值.执行时间.在Linux中,用户程序要访问系统设备,必须由用户态切换到内核态,这是通过系统调用发起并完成的. strace常用参数: -c 统计每种系统调用执行的时间.调用次数.出错次数,程序退出时给出报告 -p pid 跟踪指定的进程,可以使用多个-p同时跟踪多个进程 -