Commit 7f0d807f authored by Archit Tamarapu's avatar Archit Tamarapu
Browse files

add set -x and -e to prepare_instrumentation.sh

parent 8366c22e
Loading
Loading
Loading
Loading
+35 −36
Original line number Diff line number Diff line
@@ -40,7 +40,6 @@ function usage {
    exit
}


# default values
MODE="FULL"
PROJECT="FLOAT"
@@ -66,24 +65,22 @@ while getopts "m:p:h" OPTIONS; do
done
shift $((OPTIND - 1))


wmc_opt=""
if [ "$MODE" = "MEM_ONLY" ]; then
    wmc_opt="-s"
fi


system=`uname -s`
if [[ ($system = "Linux") && (`uname -a` =~ (microsoft|Microsoft|wsl|WSL) ) ]]; then
system=$(uname -s)
if [[ ($system = "Linux") && ($(uname -a) =~ (microsoft|Microsoft|wsl|WSL)) ]]; then
    system="Linux"
fi

coan_exists() {
  type coan &> /dev/null ;
    type coan &>/dev/null
}

cppp_exists() {
  type cppp/cppp.pl &> /dev/null ;
    type cppp/cppp.pl &>/dev/null
}

if ! (coan_exists || cppp_exists); then
@@ -93,10 +90,11 @@ if ! (coan_exists || cppp_exists); then
    exit -1
fi

set -x
targetdir=c-code_instrument

currdir=`pwd`
scriptdir=`dirname $0`
currdir=$(pwd)
scriptdir=$(dirname $0)
ifdef_list=ifdef_instrument.list
sourcedir=$scriptdir/..
cd $scriptdir
@@ -129,9 +127,8 @@ if [ "$PROJECT" = "FLOAT" ]; then

    # Filter defines that come from outside of the header lib_lc3plus/defines.h
    lc3plus_defines_filtered=""
    while IFS=' \n' read -r line;
    do
       line=`echo $line | tr -d '\n'`
    while IFS=' \n' read -r line; do
        line=$(echo $line | tr -d '\n')
        if grep -wqF "$line" "$targetdir/lib_lc3plus/defines.h"; then
            lc3plus_defines_filtered+=$line$'\n'
        fi
@@ -192,6 +189,7 @@ shopt -u extglob
# patch code before wmc_tool: replace hexadecimal unsigned long constants (0x...UL) by regular integer constant + cast to unsigned long
find $targetdir -name "*.[ch]" -exec sed -i.bak -e "s/\(0x[0-9a-fA-F]*\)UL/\(\(unsigned long\)\1\)/" \{\} \;

set -e
# run wmc_tool
"tools/$system/wmc_tool" $wmc_opt -m "$targetdir/apps/encoder.c" "$targetdir/lib_enc/*.c" "$targetdir/lib_com/*.c" >>output.txt 2>&1
"tools/$system/wmc_tool" $wmc_opt -m "$targetdir/apps/decoder.c" "$targetdir/lib_dec/*.c" "$targetdir/lib_rend/*.c" >>output.txt 2>&1
@@ -208,6 +206,7 @@ else
    for bak_file in $targetdir/lib_rend/*.bak; do mv "$bak_file" "${bak_file%.*}"; done # restore fresh .c files to avoid time-consuming des-instrumentation of files by the WMC tool
    "tools/$system/wmc_tool" $wmc_opt -m "$targetdir/apps/renderer.c" "$targetdir/lib_rend/*.c" >>output.txt 2>&1
fi
set +e

# automatically enable #define WMOPS in options.h
sed -i.bak -e "s/\/\*[[:space:]]*\(#define[[:space:]]*WMOPS\)[[:space:]]*\*\//\1/g" $targetdir/lib_com/options.h