From cd9525e2adec215c084c14e09ae3a19aefd245b2 Mon Sep 17 00:00:00 2001 From: jdh8d <jdh8d@git.zephyr-software.com> Date: Thu, 22 Oct 2015 20:51:11 +0000 Subject: [PATCH] Updates to get large-only working, and fixes to cfar.sh and cfar_postgres setup to avoid raciness. Former-commit-id: c384e5e13a59626e47a6d527f22f073bb4859680 --- tools/cfar.sh | 30 +++++++++++++++++++++++++++--- tools/db/pdb_register.sh | 2 ++ tools/ps_analyze.sh | 27 +++++++++++---------------- 3 files changed, 40 insertions(+), 19 deletions(-) diff --git a/tools/cfar.sh b/tools/cfar.sh index d7796ed17..1036c5f64 100755 --- a/tools/cfar.sh +++ b/tools/cfar.sh @@ -1,5 +1,7 @@ #!/bin/sh + +# parse first 3 parameters as fixed position params. variants=$1 in=$2 out=$3 @@ -7,28 +9,49 @@ shift shift shift + +# init some variables. share_path=/tmp pids= + +# remove any old data xfers. rm -f $share_path/Barriers* + +# pick a random seed for this run. anyseed=$$ + +# create a copy of ps_analyze for each variant we want to create. for seq in $(seq 0 $(expr $variants - 1) ) do + # the path to the "shared memory" that cfar is using. sharepath_key="$seq:$variants:dir://$share_path " - zipr_env="ZIPR_VARID=$sharepath_key" + + # optoins for zipr's large_only plugin to help create non-overlapping code segments. + large_only_options="--step-option zipr:--large_only:on --step-option zipr:true --step-option zipr:--large_only:variant --step-option zipr:$sharepath_key" + + # optoins to p1 to create non-overlapping canary values. p1options=" --step-option p1transform:--canary_value --step-option p1transform:0xFF0${seq}${seq}0FF --step-option p1transform:--random_seed --step-option p1transform:$anyseed " - cmd=" PG_DATABASE=peasoup_`whoami`_$seq $zipr_env $PEASOUP_HOME/tools/ps_analyze.sh $in $out.v$seq $@ $p1options > peasoup.v$seq 2>&1 &" + + # invoke $PS. + cmd=" PGDATABASE=peasoup_${USER}_v$seq $zipr_env $PEASOUP_HOME/tools/ps_analyze.sh $in $out.v$seq $@ $p1options $large_only_options > variant_output.$seq 2>&1 &" echo $cmd eval $cmd + + # remember the pid. pids="$pids $!" done + +# mark that no one has detected a failure yet. ok=1 + +# wait for each child. detect failures. for i in $pids; do wait $i @@ -39,6 +62,8 @@ do fi done + +# report success/failures. if [ $ok = 1 ] ; then echo "Successfully generated $variants variants" exit 0 @@ -50,4 +75,3 @@ else echo exit 1 fi - diff --git a/tools/db/pdb_register.sh b/tools/db/pdb_register.sh index 898ef3e4d..9c056b106 100755 --- a/tools/db/pdb_register.sh +++ b/tools/db/pdb_register.sh @@ -81,6 +81,8 @@ MD5HASH=`$PS_MD5SUM $FILENAME| cut -f1 -d' '` # -c: run command + +echo PGDATABASE is $PGDATABASE PROGRAM_ID=`psql -q -t -c "INSERT INTO variant_info (schema_version_id,name) VALUES ('2', '$PROGRAM_NAME') RETURNING variant_id;" | sed "s/^[ \t]*//"` if [ ! $? -eq 0 ]; then diff --git a/tools/ps_analyze.sh b/tools/ps_analyze.sh index af0ee7da7..3363ddcd6 100755 --- a/tools/ps_analyze.sh +++ b/tools/ps_analyze.sh @@ -130,21 +130,16 @@ check_step_option() set_step_option() { - step=`echo $1 | sed 's/\(.*\):.*/\1/'` - option=`echo $1 | sed 's/.*:\(.*\)/\1/'` - - case "$step" in - *) - # - # this sets step_options_$step to have the new option - # you can now, when writing your step, just add $step_options_<stepname> where you want the options passed to your step. - # - var="step_options_$step" - old_value="${!var}" - eval "step_options_$step='$old_value $option'" - ;; - esac - + step=`echo $1 | cut -d: -f1` + option=`echo $1 | cut -d: -f2-` + + # + # this sets step_options_$step to have the new option + # you can now, when writing your step, just add $step_options_<stepname> where you want the options passed to your step. + # + var="step_options_$step" + old_value="${!var}" + eval "step_options_$step='$old_value $option'" } usage() @@ -1039,7 +1034,7 @@ perform_step get_pins spasm,fast_spri $PEASOUP_HOME/tools/get_pins.sh # zipr -perform_step zipr clone,fill_in_indtargs,fill_in_cfg,pdb_register $ZIPR_INSTALL/bin/zipr.exe --variant $cloneid --zipr:callbacks $ZIPR_INSTALL/bin/callbacks.exe --zipr:objcopy $PS_OBJCOPY +perform_step zipr clone,fill_in_indtargs,fill_in_cfg,pdb_register $ZIPR_INSTALL/bin/zipr.exe --variant $cloneid --zipr:callbacks $ZIPR_INSTALL/bin/callbacks.exe --zipr:objcopy $PS_OBJCOPY $step_options_zipr # copy TOCTOU tool here if it exists if [[ "$CONCURRENCY_HOME/toctou_tool" != "" && -d "$CONCURRENCY_HOME/toctou_tool" ]]; then -- GitLab