Generates Foundry-style call trace for LLVM targets (C/C++).
export ICWD=`pwd`
# Change paths based on your LLVM installation locations
./env.sh
First time build:
mkdir build
cd build
cmake ..
make
cd ..
Rebuild:
cd build
make
cd ..
Simple way:
$CC -fpass-plugin=`build/instrumentation/InstrPass.so` test.c hooks.c -g3
CMake Project:
# Compile the hook to so
$CC -shared -fPIC hooks.c -o libhooks.so
CXXFLAGS="-fpass-plugin=$ICWD/build/instrumentation/InstrPass.so" CFLAGS="-fpass-plugin=$ICWD/build/instrumentation/InstrPass.so" LDFLAGS="-L$ICWD -lhooks" LD_LIBRARY_PATH=$ICWD cmake ..
CXXFLAGS="-fpass-plugin=$ICWD/build/instrumentation/InstrPass.so" CFLAGS="-fpass-plugin=$ICWD/build/instrumentation/InstrPass.so" LDFLAGS="-L$ICWD -lhooks" LD_LIBRARY_PATH=$ICWD make
PHP:
$CC -shared -fPIC hooks.c -o libhooks.so
git clone https://github.com/php/php-src
cd php-src
./buildconf
CXXFLAGS="-fpass-plugin=$ICWD/build/instrumentation/InstrPass.so" CFLAGS="-fpass-plugin=$ICWD/build/instrumentation/InstrPass.so" LDFLAGS="-L$ICWD -lhooks" LD_LIBRARY_PATH=$ICWD ./configure
CXXFLAGS="-fpass-plugin=$ICWD/build/instrumentation/InstrPass.so" CFLAGS="-fpass-plugin=$ICWD/build/instrumentation/InstrPass.so" LDFLAGS="-L$ICWD -lhooks" LD_LIBRARY_PATH=$ICWD make -j100
PHP:
# dump calls
LD_LIBRARY_PATH=$ICWD ./sapi/cli/php -r 'echo "Hello World\n";' | python3 ../parser_1.py > callgraph.txt