Live data from Hacker News

The Magic of strace

chadfowler.com

81–90 of 105 posts

Re: The Magic of strace

#81
Don't forget that sometimes strace is overkill, and similar more easily parsed things can be used instead, for example, /usr/bin/time (vs bash time) has been coming in more and more handy for me.

Re: The Magic of strace

#82
I’ve used strace before to help diagnose issues with buggy software I was using and I thought this was a great article.

I just thought I’d let people know that it can be a lot easier to read strace’s output if you read the output log file using Vim as it contains a syntax file which can highlight PIDs, function names, constants, strings, etc. Alternatively, if you don’t want to create an strace log file, you could pipe the output to Vim and it will automatically detect it as being strace output, e.g.

  strace program_name 2>&1 | vim  -

Re: The Magic of strace

#83
post #4

Small, somewhat nit-picky critique: the man pages for system calls are in section 2. If you want to see the docs for the "read()" syscall, and not the bash builtin "read", saying "man read" w̶o̶n̶'̶t̶ may not (see follow-up) do what you expect. Instead, you should say man 2 read This should probably be mentioned somewhere. Otherwise, great writeup. Thanks for sharing! (edited)

There's a manpage bash-builtins in section 7, but I've never seen a system that had manpages for the individual builtins, let alone having them in section 1. "man read" on every system I've used opens the read manpage in section 2.

[deleted]

Re: The Magic of strace

#84

Please see ftp://86.0.252.89/pub/release/website/tools/trace-20140126-x86_64-b95.tar.gz This is a tool called ptrace - which does everything that strace does and a lot more. You have working binaries in there, and most of the source - I havent extricated the full build dependencies so it all builds, but this includes extra facilities like reporting summaries of process trees, showing only connections or files, and sh…

Why do you link directly to the download file? A link to the tool's man page[1] would be sufficient. [1] http://linux.die.net/man/2/ptrace

His blog is here: http://crtags.blogspot.com/2013/12/ptrace-now-available.html

Re: The Magic of strace

#87
post #4

Small, somewhat nit-picky critique: the man pages for system calls are in section 2. If you want to see the docs for the "read()" syscall, and not the bash builtin "read", saying "man read" w̶o̶n̶'̶t̶ may not (see follow-up) do what you expect. Instead, you should say man 2 read This should probably be mentioned somewhere. Otherwise, great writeup. Thanks for sharing! (edited)

You can change the section search order with the SECTION directive in /etc/man_db.conf, or you can override that global setting with the MANSECT environment variable. I just learned this from "man man". :) I'm personally tempted to put "2 3" ahead of the rest, because most of the time I'm just trying to refresh my memory on function parameters.

Re: The Magic of strace

#88
post #76
post #63

Earlier quoted context omitted.

Still doesn't tell me what dtrace does.

It's like awk, except that you match entry/exit of syscalls, function calls, method invocations (in ObjC/Java), and give code to execute with access to arguments, return values, stack trace, etc. It can be used to write tools like strace (see "dtruss" on OSX), iotop, topsyscall, etc.

On Mac OS X, the way to get an idea of what dtrace can do is "apropos dtrace". That shows you the dtrace scripts that the OS ships with.

Re: The Magic of strace

#89
post #52
post #20

If you think strace is useful, wait until you try dtrace.

I was thinking that too. It is my humble opinion that dtrace will knock strace out of its socks.

I find that strace (or dtruss) is more useful when you know less about what exactly you're trying to find. A log of syscalls is often exactly the right granularity to find out the gist of what a process you didn't write is trying (and failing) to do.

So I think the comparison, despite the superficial similarity and similar mechanism of action, isn't really fair.

Re: The Magic of strace

#90
my favorite use of strace to learn which files (especially config files) are being open by a new daemon/tool: strace -f -s1024 2>&1|grep open

also remember also useful 'ltrace' - libraries tracing

Post reply on HN