The two tasks are in their respective directories.
Running make all
inside each of task1 and task2, quickly shows results.
For task2 the required pdf will be generated inside in the directory.
The rest of the README is just info on my implementation
malloc\_intercept.c
contains a wrapper around original_malloc
.
I use the <dlfcn>
library to dynamically read the address of the original malloc fucntion.
The bytes allocated is tracked and printed during calls to original_malloc
.
make
generates malloc_intercept.so
which can be used with LD_PRELOAD
.
The make file uses the same program seq 1 5
as in the example.
Inside the directory, make llvm_pass
prints the number of functions and blocks, as well as generating data for gnuplot.
make plot_histogram
will create Basic Blocks Histogram.pdf
The program being used can be changed by changing the Makefile variable and copying the <program>.c
into the directory.
Dependencies: Clang and LLVM (with header files) and gnuplot.
I've made a shared object, which opt
can use to make an analyze
(no mutation) pass.
I've decided to subclass FunctionPass
, with state stored in the members.
The pass is registed as info
. In each function, it iterates through the basic blocks and updating a map. The map is given by x->y
where there are y
basic blocks with x
instructions each. The total block and functions count is also getting incremented.
doFinalization
is overriden to write the outputs using the information collected.
(I had tried to subclass ModulePass
(but that included #include
s which was problematic).
It is also more granular than necessary)
Also I can share ssh access to my DoC virtual machine (which I tested everything on) given a username.