Monday 26 December 2011

session on ltrace and strace in linux


We had a very nice session about these ltrace and strace in linux commands by mr.vijay guru..
let me share certain things on those topics here..

Before we getting in to the topic.we first see the unix architecture..


This architecture helps us to know how the system and library calls reach the kernel and get the response..
as we are going deep in to the topic the question nudges our mind how the calls from our application reaches the kernel of the os and respond back to us..


This is how the directions of calls have requested and responded to the commands..


ltrace- A library call tracer.
strace-A system call tracer.

ltrace is a debugging utility in linux to monitor the library calls used by a program and all the signals it receives. It can also show system calls, used by a program.
ltrace [-CdfhiLrStttV] [-a column] [-e expr] [-l filename] [-n nr] [-o filename] [-p pid] ... [-s strsize] [-u username] [-X extern] [-x extern] ... [--align=column] [--debug] [--demangle] [--help] [--indent=nr] [--library=filename] [--output=filename] [--version] [command [arg ...]]


starce is a tool which enables tracing the System calls made by a process during its execution. It also reports the signals that are recieved by the process.

According to the Linux manual page, in the simplest case 'strace runs the specified command until it exits. It intercepts and records the system calls which are called by a process and the signals which are received by a process. .


$strace
usage: strace [-dffhiqrtttTvVxx] [-a column] [-e expr] ... [-o file] [-p pid] ... [-s strsize] [-u username] [-E var=val] ... [command [arg ...]] or: strace -c [-e expr] ... [-O overhead] [-S sortby] [-E var=val] ... [command [arg ...]] -c -- count time, calls, and errors for each syscall and report summary

here i just show u screenshot of strace..





No comments:

Post a Comment