Tracing dynamic library functions with ltrace
Knowing the user-space library functions being called is as useful as knowing the system functions being invoked. The ltrace command provides a similar function to strace; however, it tracks user-space library calls instead of system calls.
Getting ready
Have the ltrace command installed using the Developer tools.
How to do it...
To trace user-space dynamic library calls, invoke the strace command, followed by the command you want to trace:
$ ltrace myApplicationThe next example is a program with a subroutine:
$ cat test.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int print (char *str) {
printf("%s\n", str);
}
main () {
char *tmp;
tmp=malloc(100);
strcat(tmp, "testing");
print(tmp);
free(tmp);
exit(0);
}
$ gcc test.c
$ ltrace ./a.out
(0, 0, 603904, -1, 0x1f25bc2) = 0x3b0de21160
__libc_start_main(0x4005fe, 1, 0x7ffd334a95f8, 0x400660, 0x400650 <unfinished...