strace alternative for Mac OS X

dtruss [ -p <pid> | -n <pname> ]
Usefull tool for debug process.
Sample Output
	PID/THRD  RELATIVE  ELAPSD    CPU SYSCALL(args) 		 = return
18831/0x151a01:   7205192     331      4 read(0x4, "a\0", 0x4000)		 = 1 0
18831/0x151a01:   7205215      14      4 select(0x7, 0x100115850, 0x100118FC0, 0x0, 0x0)		 = 1 0

0
By: Zulu
2013-02-22 11:09:55

These Might Interest You

  • How to figure out what a program is doing. -tt detailed timestamps -f also strace any child processes -v be very verbose, even with common structures -o write output to file -s N capture up to N characters of strings, rather than abbreviating with ...


    0
    strace -ttvfo /tmp/logfile -s 1024 program
    ryanchapman · 2013-07-06 08:19:29 0
  • Sometimes a program refuses to read a file and you're not sure why. You may have display_errors turned off for PHP or something. In this example, fopen('/var/www/test/foo.txt') was called but doesn't have read access to foo.txt. Strace can tell you what went wrong. E.g., if php doesn't have read access to the file, strace will say "EACCESS (Permission denied)". Or, if the file path you gave doesn't exist, strace will say "ENOENT (No such file or directory)", etc. This works for any program you can run from the command-line, e.g., strace python myapp.py -e open,access... Note: the above command uses php-cli, not mod_php, which is a different SAPI with diff configs, etc. Show Sample Output


    7
    strace php tias.php -e open,access 2>&1 | grep foo.txt
    rkulla · 2010-04-20 19:42:42 0
  • This one-liner will use strace to attach to all of the currently running apache processes output and piped from the initial "ps auxw" command into some awk. Show Sample Output


    7
    ps auxw | grep sbin/apache | awk '{print"-p " $2}' | xargs strace
    px · 2011-03-14 21:45:22 7
  • It sits there in a loop waiting for a proccess from that user to spawn. When it does it will attach strace to it Show Sample Output


    4
    x=1; while [ $x = 1 ]; do process=`pgrep -u username`; if [ $process ]; then x=0; fi; done; strace -vvtf -s 256 -p $process
    dimentox · 2009-09-22 16:46:27 1

What Others Think

Welcome to my Taobao shop ! Daily update: Discover amazing stuff, collect the things you love, buy it all in one place. novel style, varieties, low price and good quality, and the low sale price ==== ( http://www.fullmalls.com ) ===== ==== ( http://www.fullmalls.com ) ===== New to Hong Kong : Winter Dress Best quality, Best reputation , Best services ---**** NHL Jersey Woman $ 40 ---**** NFL Jersey $ 35 ---**** NBA Jersey $ 34 ---**** MLB Jersey $ 35 ---**** Jordan Six Ring_m $ 36 ---**** Air Yeezy_m $ 45 ---**** T-Shirt_m $ 25 ---**** Jacket_m $ 36 ---**** Hoody_m $ 50 ---**** Manicure Set $ 20 ---**** handbag $ 37 ---**** ugg boot $ 43 ---**** give you the unexpected harvest ==== ( http://www.fullmalls.com ) ===== ==== ( http://www.fullmalls.com ) ===== ==== ( http://www.fullmalls.com ) ===== ==== ( http://www.fullmalls.com ) ===== ==== ( http://www.scnshop.com ) =====
wesdfwiusdf · 277 weeks and 1 day ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: