Commit 2c005a5f authored by Andrea Gussoni's avatar Andrea Gussoni
Browse files

Add revng-c decompiled parser driver

parent 9f45c26a
#!/bin/bash
if [ $# -eq 0 ]; then
echo "No arguments supplied"
exit 1
fi
arch=$1
basepath=$(pwd)
workdir=$basepath/workdir-$arch
revng_sources=$workdir/revng-sources
metrics_dir=$workdir/revng-cyclomatic
if [ ! -d $metrics_dir ]; then
mkdir $metrics_dir;
fi
cd $revng_sources
tmp_dir=$basepath/scripting/revng-extraction-scripts/tmp/
if [ ! -d $tmp_dir ]; then
mkdir $tmp_dir;
fi
for binary in *
do
echo "Parsing with clang input: $source"
metrics_subdir=$metrics_dir/$binary/triple-metrics/
if [ ! -d $metrics_subdir ]; then
mkdir -p $metrics_subdir;
fi
cd $binary
for function_source in *
do
echo "Parsing with clang function: $function_source"
cp $function_source $tmp_dir/
cd $tmp_dir
../revng-normalizer.sh $function_source
clang-7 -std=c11 -Wno-return-type -S -emit-llvm -O0 -femit-all-decls -Xclang -disable-O0-optnone -w $function_source.normalized.c
revng opt -cyclomatic -cyclomatic-output=$metrics_subdir/$function_source.csv -S -o /dev/null $function_source.normalized.opt.ll
rm $function_source $function_source.normalized.c $function_source.normalized.ll $function_source.normalized.opt.ll
cd $revng_sources/$binary
done;
cd $revng_sources
done;
#!/bin/bash
# Create the output file
cp $1 $1.purged.c
# Remove redefinition of struct `__fsid_t`
sed -i -e 's/extern void indirect_handler(...);/extern void indirect_handler(int p, ...);/g;' $1.purged.c
sed -i -e 's/#include <stdint.h>//g' $1.purged.c
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment