Skip to content

Commit

Permalink
edit strace style a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
srsudar committed Nov 15, 2021
1 parent 96302c4 commit 58b87c1
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions eg/examples/strace.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,39 +12,52 @@ Trace syscalls of a command:

strace <command>


See the syscalls of an already-running process:

strace -p <pid>

See only `network` type syscalls (and/or `file`,`stat`, `process`, or any specific syscall, comma separated)

See only `network` type syscalls (and/or `file`,`stat`, `process`, or any
specific syscall, comma separated):

strace -e trace=%network <command>

See only system calls accessing <path>

See only system calls accessing a specific path:

strace -P <path> <command>

Increase default preview string size to 256

Increase default preview string size to 256:

strace -s 256 <command>

Show timestamps

Show timestamps:

strace -t <command>

Show time spent in syscalls

Show time spent in syscalls:

strace -T <command>

Only show a summary of syscalls

strace --summary-only/-c
Only show a summary of syscalls (equivalent to `-c`):

strace --summary-only <command>

# Attach to a running process to see time spent in calls

Attach to a running process with the id of 1234 (`-p 1234`), follow child
processes (`-f`), print 256 string characters (`-s 256`), and show the time
spent in calls (`-T`):

$ strace -f -s 256 -p <pid> -T

This attached to a process (-p) with the pid of <pid>, following child processes (-f) and printing 256 string characters (-s), showing time spent in calls (-T). Example:

Run the command `echo "hi"`, follow child processes (`-f`), print 256 string
characters (`-s 256`), and show the time spent in calls (`-T`):

$ strace -f -s 256 -T echo "hi"
execve("/usr/bin/echo", ["echo", "hi"], 0x7fff519c2db8 /* 57 vars */) = 0 <0.003416>
Expand Down

0 comments on commit 58b87c1

Please sign in to comment.