#! /usr/bin/env perl

# Script to simplify using rundiff on trace outputs from two invocations of m5.

if (@ARGV < 2) {
    die "Usage: tracediff sim1 sim2 [args...]\n";
}

# First two args are the two simulator binaries to compare
$sim1 = shift;
$sim2 = shift;

# Everything else on the command line is taken to be an m5 argument to
# be given to both invocations
$simargs = '"' . join('" "', @ARGV) . '"';

$cmd1 = "$sim1 $simargs --stats:text_file=tracediff-$$-1.stats 2>&1 |";
$cmd2 = "$sim2 $simargs --stats:text_file=tracediff-$$-2.stats 2>&1 |";

# This only works if you have rundiff in your path.  I just edit it
# with an explicit path if necessary.
$fullcmd = "rundiff '$cmd1' '$cmd2' 2>&1 > tracediff-$$.out";

print "Executing $fullcmd\n";
system($fullcmd);



