I want to write a good callgraph program in python and for that reason I use pycparser.
Pycparser needs to preprocess c files in order to create an abstract syntax tree correctly.
My first approach was to use only the -E
option of gcc on the files and then pass it to pycparser.
But with different projects I get "No such file or directory
" errors because gcc doesn't find the specific headers. If I try to preprocess the linux kernel with gcc -E `find | grep "\.c"\`
it misses some header files like those with a Linux/ prefix as there is no such folder. It seems to me that I need some additional flags for gcc to pass the location of the header files and preprocess correctly. Is there a general way to preprocess arbitrary C projects?
Additionally I guess if I get it to preprocess correctly there are multiple copies of the same function in different files. Is there a way to determine the original file of a function?