1#!/bin/bash 2 3WINDOW=$1 4PERIOD=$2 5 6if [[ -z $WINDOW ]] || [[ -z $PERIOD ]]; then 7 echo "Window or Period not specified!" 8 echo "Example usage: ./set_strobing.sh <WINDOW VALUE> <PERIOD VALUE>" 9 echo "Example usage: ./set_strobing.sh 5000 10000" 10 exit -1 11fi 12 13 14if [[ $EUID != 0 ]]; then 15 echo "Please run as root" 16 exit -1 17fi 18 19for e in /sys/bus/coresight/devices/etm*/; do 20 printf "%x" $WINDOW | tee $e/strobe_window > /dev/null 21 printf "%x" $PERIOD | tee $e/strobe_period > /dev/null 22 echo "Strobing period for $e set to $((`cat $e/strobe_period`))" 23 echo "Strobing window for $e set to $((`cat $e/strobe_window`))" 24done 25 26## Shows the user a simple usage example 27echo ">> Done! <<" 28echo "You can now run perf to trace your application, for example:" 29echo "perf record -e cs_etm/@tmc_etr0/u -- <your app>" 30