views:

139

answers:

3

Hi all,

I wanted to know how can i use strace function to trace system calls in my C program and also use it for debugging my code.

regs adi

+5  A: 

By running your program through strace:

strace path/to/your/executable

e.g. strace ./myapp

ThiefMaster
+3  A: 

Run strace [arguments to strace] your_program [arguments to your program]. See man strace or just strace without arguments for the possible arguments.

Arkku
A: 

Strace is great to see system calls. Once you understand how it works, be sure to check out ltrace as well, which shows calls to dynamically linked libraries.

Together, they give you a very good understanding of what any given program is doing (unless statically linked, of course).

Tim Post