GNU/Linux Command – LTRACE

ltrace — Library call TRACEr


ltrace is a program that simply runs the specified command until it exits and intercepts, records the library/system calls, which are called by the executed process, and the signals, which are received by that process. It can used study the internal flow of a program.

$ ltrace sleep 1 -- Trace all Lib call of 'sleep' command. $ ltrace ls -- Trace all Lib call of 'ls' command. $ ltrace -d sleep 1 -- Print more detailed info. $ ltrace -i sleep 1 -- Print the value of the Instruction Pointer at every lib call. $ ltrace -S sleep 1 -- Show System Call trace also. $ ltrace -S -L sleep 1 -- Show only System calls. $ ltrace -r sleep 1 -- Print a relative time-stamp with each line of the trace. $ ltrace -t sleep 1 -- Prefix each line of the trace with the time of day. $ ltrace -o file sleep 1 -- Redirect the output to a file. $ sleep 60 & -- Dummy background Job. $ ltrace -p 1234 -- Attach to the process with the PID 1234 (use dummy job's Pid) and trace. $ ltrace -n 3 sleep 1 -- Indent each new nested call by 3 Spaces.
Read: man ltrace

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: