Multiple tools can be use to trace programs execution, gdb, valgrind,…

Strace

Using strace and some options I often use.

# trace a whole process
strace process 2>&1

# filter by system calls to $file
strace -e open process 2>&1 | grep "$file"
strace -e open,access 2>&1 | grep "$file"

# specify a pid
strace -p $pid

# print only a summary
strace --summary-only -p $pid

# tracing network process
# in this example `nc www.example.com 80`
strace -e poll,select,connect,recvfrom,sendto nc www.example.com 80

Valgrind

 valgrind -v $command

GDB

 gdb $command