#!/bin/bash
#ARGS 
# $1 name and path for vmlinux file or . for default of /boot/vmlinux-autobench
# $2 name and path for system map file or . for default of /boot/System.map-autobench 
# $3 event 0 or . for CPU_CLK_UNHALTED
# $4 count 0 or . for 600000
# [$5] event 1
# [$6] count 1

if [ "$1" == "" -o "$1" == "." ]; then
	kern='/boot/vmlinux-autobench'
else
	kern=$1
fi
if [ "$2" == "" -o "$2" == "." ]; then
	map='/boot/System.map-autobench'
else
	map=$1
fi
if [ "$3" == "" -o "$3" == "." ]; then
	ev0='CPU_CLK_UNHALTED'
else
	ev0=$1
fi
if [ "$4" == "" -o "$4" == "." ]; then
	count0=100000
else
	count0=$1
fi
ev1=$5
count1=$6
touch /root/.oprofile/daemonrc
if [ "$ev1" == "" ]; then
	echo "--vmlinux=$kern --map-file=$map --ctr0-event=$ev0 --ctr0-count=$count0" > oprofile
else
	echo "--vmlinux=$kern --map-file=$map --ctr0-event=$ev0 --ctr0-count=$count0 --ctr1-event=$ev1 --ctr1-count=$count1 " > oprofile
fi
