C Linux Track all function calls, including a function inside a library

I have a program like

int main()
{
  char *ptr = malloc(2);
  free(ptr);
}

So, I just want to keep track of all the function calls occurring inside the program, before the system call

like

malloc
   |____ libc( sme_fn)
           |
           |__sme_system_call

Could you talk about this?

+3
source share
2 answers

As you know, “system calls” come in two flavors:

  • Call directly to the operating system ("open", "close", "fork", "exec", "exit", etc.)

  • Standard C execution functions for the platform ("printf ()", "malloc ()", "free (), etc.)

You can view the first with strace ".

( , ) gdb.

:

, "malloc()", " valgrind" ( ) .

+2

gcc, -pg, gprof.

, Linux, oprofile, - .

, .

+1

All Articles