Here is a project source code folder for c/c++, I want to write a small and fast tool/script to get the filename, line number, and function name for all source files .
For example, I want it will output like below:
./src/a.c line 1500 call func1(); ./src/a.c line 1600 call func1();
./src/a.c line 1700 call func2(); ./src/b.c line 1700 call func3();
...
for example,here is tmp.c's context,I want it to analyze the file,
#include <stdio.h>
#include <string.h>
int main (){
char dest1[4];
char dest2[4];
char *src="Sample string";
strcpy (dest2,strcpy(dest1,src));
printf ("src1: %s\ndest: %s\n",src,dest1);
return 0;
}
and output like :
./tmp.c line 7 call strcpy
./tmp.c line 8 call printf
How to do it with any tools or language? best with gcc.
What I have tried:
get function call's name,and line number for a file.