csmith/check_gen_eh_frame: verbose mode

This commit is contained in:
Théophile Bastian 2019-04-02 18:40:47 +02:00
parent 30fe23b541
commit 2b2d44c18e
3 changed files with 52 additions and 15 deletions

View file

@ -1,4 +1,8 @@
#!/usr/bin/env python3
import sys import sys
import argparse
verbose = False
class NotFDE(Exception): class NotFDE(Exception):
@ -104,15 +108,15 @@ def match_segments(orig_eh, synth_eh):
matches[1][synth_id] = True # PLT -- fake match matches[1][synth_id] = True # PLT -- fake match
continue continue
if matches[1][synth_id]: if matches[1][synth_id]:
# print("Multiple matches (synth)") if verbose:
pass print("Multiple matches (synth)")
if matches[0][orig_id]: if matches[0][orig_id]:
pass if verbose:
# print( print(
# "Multiple matches (orig) {}--{}".format( "Multiple matches (orig) {}--{}".format(
# hex(orig_fde["beg"]), hex(orig_fde["end"]) hex(orig_fde["beg"]), hex(orig_fde["end"])
# ) )
# ) )
else: else:
matches[0][orig_id] = True matches[0][orig_id] = True
matches[1][synth_id] = True matches[1][synth_id] = True
@ -161,6 +165,7 @@ def match_fde(orig, synth):
rowchanges.append((typ, row)) rowchanges.append((typ, row))
rowchanges.sort(key=loc_of) rowchanges.sort(key=loc_of)
matching = True
for rowid, rowch in enumerate(rowchanges): for rowid, rowch in enumerate(rowchanges):
typ, row = rowch[0], rowch[1] typ, row = rowch[0], rowch[1]
cur_val[typ] = vals_of(row) cur_val[typ] = vals_of(row)
@ -169,10 +174,15 @@ def match_fde(orig, synth):
): ):
continue continue
if cur_val[0] != cur_val[1]: if cur_val[0] != cur_val[1]:
# print("Mis {} ; {}".format(cur_val[0], cur_val[1])) if verbose:
return False print(
"Mismatch {}: {} ; {}".format(
hex(row["LOC"]), cur_val[0], cur_val[1]
)
)
matching = False
return True return matching
def parse_sym_table(handle): def parse_sym_table(handle):
@ -190,10 +200,24 @@ def parse_sym_table(handle):
return out_map return out_map
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument(
"-v", "--verbose", action="store_true", help="Display verbose results"
)
parser.add_argument(
"test_name",
action="store",
help="Base path of the test case (eg. some_test/01)",
)
return parser.parse_args()
def main(): def main():
if len(sys.argv) < 2: global verbose
print("Missing argument: test_name", file=sys.stderr) parser_args = parse_args()
test_name = sys.argv[1] test_name = parser_args.test_name
verbose = parser_args.verbose
symtb = parse_sym_table(sys.stdin) symtb = parse_sym_table(sys.stdin)
orig_eh = parse_eh_frame(sys.stdin, symtb) orig_eh = parse_eh_frame(sys.stdin, symtb)
synth_eh = parse_eh_frame(sys.stdin, symtb) synth_eh = parse_eh_frame(sys.stdin, symtb)

View file

@ -22,4 +22,4 @@ fi
echo "===" ; \ echo "===" ; \
readelf -wF "$orig_path" ; \ readelf -wF "$orig_path" ; \
echo "===" ; \ echo "===" ; \
readelf -wF "$eh_path") | python $py_checker "$base_path" readelf -wF "$eh_path") | python $py_checker $*

View file

@ -9,6 +9,15 @@ fi
DIR=$1 DIR=$1
NB_TESTS=$2 NB_TESTS=$2
shift ; shift
check_gen_eh_frame=0
while [ "$#" -gt 0 ]; do
if [ "$1" = "--check-gen-eh-frame" ] ; then
check_gen_eh_frame=1
fi
shift
done
mkdir -p "$DIR" mkdir -p "$DIR"
echo -n ">>> " echo -n ">>> "
@ -24,6 +33,10 @@ for _num in $(seq 1 $NB_TESTS); do
"$path.orig.bin" "$path.bin" "$path.orig.bin" "$path.bin"
echo -ne "\r>>> $num.eh.bin " echo -ne "\r>>> $num.eh.bin "
../synthesize_dwarf.sh "$path.bin" "$path.eh.bin" ../synthesize_dwarf.sh "$path.bin" "$path.eh.bin"
if [ "$check_gen_eh_frame" -gt 0 ] ; then
./check_generated_eh_frame.sh "$path"
fi
done done
echo "" echo ""