aboutsummaryrefslogtreecommitdiffstats
path: root/decoder/tests/auto-fdo/record.sh
blob: 16d4ba22db3c31525a1b0a6ee9db0d71e921fbad (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/sh

BUFFER_ETF_A53=ec802000.etf
BUFFER_ETF_A73=ed002000.etf
BUFFER_ETF_SYS=ec036000.etf
BUFFER_ETR=ec033000.etr

OUT_FILE=perf.data

STROBE=

while :; do
  case $1 in
    --strobe)
      STROBE=y
      WINDOW=$2
      PERIOD=$3
      shift 3
      ;;
    
    *)
      break ;;
  esac
done

case $1 in
  etr)
    BUFFER=$BUFFER_ETR
    ;;

  etf-sys)
    BUFFER=$BUFFER_ETF_SYS
    ;;

  "")
    BUFFER=$BUFFER_ETR
    ;;

  *)
    BUFFER=$1
    ;;
esac

shift 1

case $0 in 
 /*) F=$0 ;;
 *) F=$(pwd)/$0 ;;
esac

SCRIPT_DIR=$(dirname $F)

if [ "$STROBE" ]; then
  for e in /sys/bus/coresight/devices/*.etm/; do
    printf "%x" $WINDOW | sudo tee $e/strobe_window > /dev/null
    printf "%x" $PERIOD | sudo tee $e/strobe_period > /dev/null
  done
fi

PERF=$SCRIPT_DIR/perf

export LD_LIBRARY_PATH=$SCRIPT_DIR:$LD_LIBRARY_PATH

sudo LD_LIBRARY_PATH=$SCRIPT_DIR:$LD_LIBRARY_PATH $PERF record $PERF_ARGS -e cs_etm/@$BUFFER/u --per-thread "$@"

sudo chown $(id -u):$(id -g) $OUT_FILE