Strace

Differences between revisions 4 and 5
Revision 4 as of 2007-04-25 18:03:43
Size: 2053
Editor: c80-217-109-182
Comment: Added "Already running programs - using htop"
Revision 5 as of 2007-11-05 20:39:50
Size: 1642
Editor: 75-144-175-202-NewEngland
Comment:
Deletions are marked like this. Additions are marked like this.
Line 32: Line 32:

= Already running programs - using htop =

This is an easy way to run strace on a running program. You will, however, not be able to store the output of the strace in a logfile.

 1. Make sure strace and htop is installed. {{{
apt-get install strace htop
}}}
 1. Start htop. {{{
htop
}}}
 1. Use arrow keys to choose desired process, then press "s" to display a strace of the process on-screen.

Sometimes, a program starts behaving errantly. It gives incorrect output on its input, it doesn't print anything at all, or even hangs. Under a Linux-based system, every userspace process has to interact with its environment through the kernel. And it does this by invoking system calls.

Strace is a utility that intercepts and logs these system calls. In this way, you can watch how a program interacts with the system, which is useful for tracking down behavioural issues.

Generation

  1. Make sure strace is installed.

    apt-get install strace
  2. Start the program under control of strace:

    strace -Ff -tt <program> <arguments> 2>&1 | tee strace-<program>.log
  3. The program will start. Perform any actions necessary to reproduce the crash
  4. Attach the complete output from strace, contained in strace-<program>.log, in your bug report.

Already running programs

You may want to run strace on an already running program. This could be because strace logs too many things before you can reproduce a crash. Or, it could be because you are trying to find out what a program is doing in an infinite loop.

  1. Make sure strace is installed.

    apt-get install strace
  2. Find the process ID of <program>:

    pidof <program>
  3. Start strace with the process ID:

    strace -Ff -tt -p <PID> 2>&1 | tee strace-<program>.log
  4. Perform any actions necessary to reproduce the bug.
  5. You may have to hit Control-C to get strace to detach from a running program.
  6. Attach the complete output from strace, contained in strace-<program>.log, in your bug report.

Strace (last edited 2008-08-06 17:00:03 by localhost)