Monday 26 December 2011

ltrace and strace

Kernel
The kernel of UNIX is the hub of the operating system: it allocates time and memory to programs and handles the filestore and communications in response to system calls.
As an illustration of the way that the shell and the kernel work together, suppose a user types sleep 10 (which has the effect of sleeping without returning unix prompt ,for 10 seconds). The shell searches the filestore for the file containing the program sleep, and then requests the kernel, through system calls, to execute the program sleep on myfile. When the process sleep myfile has finished running, the shell then returns the UNIX prompt % to the user, indicating that it is waiting for further commands.


Shell :
The shell acts as an interface between the user and the kernel. When a user logs in, the login program checks the username and password, and then starts another program called the shell. The shell is a command line interpreter (CLI). It interprets the commands the user types in and arranges for them to be carried out. The commands are themselves programs: when they terminate, the shell gives the user another prompt ($ on our systems).


the diagram shows how a kernel and shell are related :



Now lets look at the commands that are used to record library calls and system calls .

ltrace : is a program that simply runs the specified command until it exits. It intercepts and records the dynamic library calls which are called by the executed process and the signals which are received by that process

strace: runs the specified commanduntil it exits. It intercepts and records the system calls which are called by a process and the signals which are received by a process. The name of each system call, its arguments and its return value are printed on standard error or to the file specified with the -o option.programmers will find that since system calls and signals are events that happen at the user/kernel interface, a close examination of this boundary is very useful for bug isolation.

No comments:

Post a Comment