1#!/bin/bash
2
3set -e
4set -u
5
6get_asm() {
7  grep __tsan_$1.: -A 10000 libtsan.objdump | \
8    awk "/[^:]$/ {print;} />:/ {c++; if (c == 2) {exit}}"
9}
10
11list="write1 \
12      write2 \
13      write4 \
14      write8 \
15      read1 \
16      read2 \
17      read4 \
18      read8 \
19      func_entry \
20      func_exit"
21
22BIN=`dirname $0`/tsan_test
23objdump -d $BIN  > libtsan.objdump
24nm -S $BIN | grep "__tsan_" > libtsan.nm
25
26for f in $list; do
27  file=asm_$f.s
28  get_asm $f > $file
29  tot=$(wc -l < $file)
30  size=$(grep __tsan_$f$ libtsan.nm | awk --non-decimal-data '{print ("0x"$2)+0}')
31  rsp=$(grep '(%rsp)' $file | wc -l)
32  push=$(grep 'push' $file | wc -l)
33  pop=$(grep 'pop' $file | wc -l)
34  call=$(grep 'call' $file | wc -l)
35  load=$(egrep 'mov .*\,.*\(.*\)|cmp .*\,.*\(.*\)' $file | wc -l)
36  store=$(egrep 'mov .*\(.*\),' $file | wc -l)
37  mov=$(grep 'mov' $file | wc -l)
38  lea=$(grep 'lea' $file | wc -l)
39  sh=$(grep 'shr\|shl' $file | wc -l)
40  cmp=$(grep 'cmp\|test' $file | wc -l)
41  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" \
42    $f $tot $size $rsp $push $pop $call $load $store $sh $mov $lea $cmp;
43done
44