Issue
I want to count how many times systemcall was called. I make wrapping function in C that hook "open" system call. first I do was override open.c with openHooking.c In that code, I added a code that changes shell variable to the original open.c content. I thought that I could do it by declare environment variable in shell, and change it in C script. But I realized it is impossible because child process can't change parent process. I want to know how many times the system call was called How can I do it?
Solution
strace
can do this for you with either --summary
, --summary-only
, or doing the accounting yourself by analyzing its output!
https://man7.org/linux/man-pages/man1/strace.1.html
there are many flags, but perhaps simply
strace --follow-forks --summary ./a.out
Answered By - ti7