#!/bin/sh
# Script to run the interface to the trace visualizer given a data file

# Check for args
if [ $# -ne 1 ]; then
	echo -n "Usage: ${0##*/} <input_file basename (without extension"
	if grep "version 2.6" /proc/version >/dev/null; then
		echo -n " or cpu numbers"
	fi
	echo ")>"
	exit 1
fi

# First check for per-cpu files (smp systems with relayfs, kernel 2.6)
cpunum=0
for file in `ls $1[0-9][0-9][0-9].trace 2>/dev/null` 
do
	[ -z "$file" ] && break
	echo "--> Analyzing: $file"
	if [ $cpunum -lt 10 ]; then
		pad=00
	else
		if [ $cpunum -lt 100 ]; then
			pad=0
		else
			pad=""
		fi
	fi
	tracevisualizer -a -s $file $1.proc  $1$pad$cpunum.data 
	let cpunum+=1
done

# If per-cpu files were not found, try basic filenames (this also fires
# for pre-2.6 and no relayfs systems)
if [ $cpunum -eq 0 ]; then
	tracevisualizer -a -s $1.trace $1.proc $1.data 
fi

