Zet - What are Dave’s handy tips for strace?

What are Dave’s handy tips for strace?

My usual execution from my snippets is

strace -rt -s2000 -T -y -yy -C -p <process_id>

(or replace the -p arg with just the command to run if you want strace to start it and trace from the very beginning)

  • -rt gets you the proper time and relative timestamps;
  • -s2000 sets the max length of string args to print (the default of 32 is often too short and loses useful info)
  • -y and -yy get you some more detailed/helpful info on file paths for fds and protocol-specific info;
  • -C gets you a summary at the end of which syscalls time was spent in
  • If the process forks, adding a -f lets it follow forks,
  • -e can be used to limit what you see, e.g. if you only want to know what files it’s interacting with, -e trace=%file will limit to file-related syscalls

#strace