Monday, December 26, 2011

Session2 strace and ltrace Dec 21st, 2011 3.00 PM

     Second session was presided over by Mr.Vijay Guru and the complete session was video taped by Mr.Kamesh Jayachandran for future reference. The session covered the following topics:
  • strace
  • ltrace
Initially let us have a look into the UNIX system architecture.

Kernel
               It is an operating system software which is used to control the entire hardware.

System Calls
               It is like a bridge or interface between the kernel and the user.The build-in functions used for this purpose is called system calls.

Library Routines
               These are also build-in functions which are stored separately and accessed when ever necessary.

Shell
               Shell is a type of special application which is used to provide an interface for other applications to run.

strace
               It is a debugging utility used to trace all the system calls during a process. It can be used to find the actual working of a process.
               We can use many different options along with strace. Some of them are:
-c     it is used to tabulate all the errors and system call made by a process
        check, strace -c sort filename





-o     is used to save the output of strace to a file specified






-p     this option is used to strace based on the process-id

  1. open a new terminal B
  2. find the process id of the terminal by echo $$
  3. say 12345
  4. in terminal A type strace -p 12345
  5. now terminal A will  wait for input in terminal B
  6. once you enter some data in terminal B strace will show the system calls in process 12345
-f     this is used to trace child process

-ff    this option is used along with -o  option, it will create a file named filename.pid each time where .pid is the process id

-r     this is used to print the relative time-stamp for each process occurring concurrently

-t     prints the time-stamp for each and every process

-tt    prints the time-stamp for each and every process along with microseconds

-T    prints the time taken to complete each system call

-e trace=systemcall   is used to trace a specific system call

-s string-length is used to specify the size of the output string


ltrace:

     All the option in strace work pretty much same in ltrace. Some other options include:

-n indent-length    this option is used to indent all the sub calls by spaces of the given size(indent-length)
 


-S    used to display both system calls and library calls


Also while using LINUX commands the options can be combined together as follows:

      sort -nr filename instead of sort -n -r filename

     where -n indicates numeric field and -r indicates reverse order sort(descending order)

Thats it and we'll meet after some other session.... bye....

No comments:

Post a Comment