]>
Commit | Line | Data |
---|---|---|
1a4d82fc | 1 | #!/bin/bash |
3157f602 XL |
2 | # |
3 | # Script that prints information about generated code in TSan runtime. | |
1a4d82fc JJ |
4 | |
5 | set -e | |
6 | set -u | |
7 | ||
3157f602 XL |
8 | if [[ "$#" != 1 ]]; then |
9 | echo "Usage: $0 /path/to/binary/built/with/tsan" | |
10 | exit 1 | |
11 | fi | |
12 | ||
1a4d82fc | 13 | get_asm() { |
3157f602 | 14 | grep __tsan_$1.: -A 10000 ${OBJDUMP_CONTENTS} | \ |
1a4d82fc JJ |
15 | awk "/[^:]$/ {print;} />:/ {c++; if (c == 2) {exit}}" |
16 | } | |
17 | ||
18 | list="write1 \ | |
19 | write2 \ | |
20 | write4 \ | |
21 | write8 \ | |
22 | read1 \ | |
23 | read2 \ | |
24 | read4 \ | |
25 | read8 \ | |
26 | func_entry \ | |
27 | func_exit" | |
28 | ||
3157f602 XL |
29 | BIN=$1 |
30 | OUTPUT_DIR=$(mktemp -t -d analyze_libtsan_out.XXXXXXXX) | |
31 | OBJDUMP_CONTENTS=${OUTPUT_DIR}/libtsan_objdump | |
32 | NM_CONTENTS=${OUTPUT_DIR}/libtsan_nm | |
33 | ||
34 | objdump -d $BIN > ${OBJDUMP_CONTENTS} | |
35 | nm -S $BIN | grep "__tsan_" > ${NM_CONTENTS} | |
1a4d82fc JJ |
36 | |
37 | for f in $list; do | |
3157f602 | 38 | file=${OUTPUT_DIR}/asm_$f.s |
1a4d82fc JJ |
39 | get_asm $f > $file |
40 | tot=$(wc -l < $file) | |
3157f602 | 41 | size=$(grep __tsan_$f$ ${NM_CONTENTS} | awk --non-decimal-data '{print ("0x"$2)+0}') |
1a4d82fc JJ |
42 | rsp=$(grep '(%rsp)' $file | wc -l) |
43 | push=$(grep 'push' $file | wc -l) | |
44 | pop=$(grep 'pop' $file | wc -l) | |
45 | call=$(grep 'call' $file | wc -l) | |
46 | load=$(egrep 'mov .*\,.*\(.*\)|cmp .*\,.*\(.*\)' $file | wc -l) | |
47 | store=$(egrep 'mov .*\(.*\),' $file | wc -l) | |
48 | mov=$(grep 'mov' $file | wc -l) | |
49 | lea=$(grep 'lea' $file | wc -l) | |
50 | sh=$(grep 'shr\|shl' $file | wc -l) | |
51 | cmp=$(grep 'cmp\|test' $file | wc -l) | |
52 | printf "%10s tot %3d; size %4d; rsp %d; push %d; pop %d; call %d; load %2d; store %2d; sh %3d; mov %3d; lea %3d; cmp %3d\n" \ | |
53 | $f $tot $size $rsp $push $pop $call $load $store $sh $mov $lea $cmp; | |
54 | done |