Thursday, September 1, 2016

Trace the system calls of a program execution using strace on linux

You can use strace to trace the system calls of execution of any executables. For example:

      strace  mkdir test
      strace java -jar MyProgram.jar

It is a very powerful debug tool for it allows you to see the details of each system calls.

1. Direct the output to a file

      strace -o <output file name> java -jar MyProgram.jar
      or
      strace java -jar MyProgram.jar > <output file name>

2. Trace one or more particular system calls

      strace -e read java -jar MyProgram.jar

      strace -e trace=read,open java -jar MyProgram.jar //It is important that there is no blank space between 'read,' and 'open'.

3. Trace an executing process

      //Find the pid of the process
      ps -ef | grep <your process name>

      //Trace the process
      sudo strace -p <pid> -e open -o processExecute.txt

---------------------------------------------------------------------------------------------------

                        

If you have ever asked yourself these questions, this is the book for you. What is the meaning of life? Why do people suffer? What is in control of my life? Why is life the way it is? How can I stop suffering and be happy? How can I have a successful life? How can I have a life I like to have? How can I be the person I like to be? How can I be wiser and smarter? How can I have good and harmonious relations with others? Why do people meditate to achieve enlightenment? What is the true meaning of spiritual practice? Why all beings are one? Read the book free here.

No comments:

Post a Comment