#!/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 " but *with* cpu number"
	fi
	echo ")>"
	exit 1
fi

# No per-cpu files, simple case
if [ -e $1.trace ] && [ -e $1.proc ]; then
	tracevisualizer -g $1.trace $1.proc &
	exit 0
fi

# Else, figure out basename of per-cpu filenames
basename=${1%%[0-9][0-9][0-9]}

# check for files
[ ! -e $basename.proc ] && echo "${0##*/}: can't find $basename.proc" && exit 1
[ ! -e $1.trace ] && echo "${0##*/}: can't find $1.trace" && exit 1

# all ok, run the visualiser
tracevisualizer -g $1.trace $basename.proc &

