tracediff revision 1442
16157Snate@binkert.org#! /usr/bin/env perl
26157Snate@binkert.org# Copyright (c) 2003-2005 The Regents of The University of Michigan
36157Snate@binkert.org# All rights reserved.
46157Snate@binkert.org#
56157Snate@binkert.org# Redistribution and use in source and binary forms, with or without
66157Snate@binkert.org# modification, are permitted provided that the following conditions are
76157Snate@binkert.org# met: redistributions of source code must retain the above copyright
86157Snate@binkert.org# notice, this list of conditions and the following disclaimer;
96157Snate@binkert.org# redistributions in binary form must reproduce the above copyright
106157Snate@binkert.org# notice, this list of conditions and the following disclaimer in the
116157Snate@binkert.org# documentation and/or other materials provided with the distribution;
126157Snate@binkert.org# neither the name of the copyright holders nor the names of its
136157Snate@binkert.org# contributors may be used to endorse or promote products derived from
146157Snate@binkert.org# this software without specific prior written permission.
156157Snate@binkert.org#
166157Snate@binkert.org# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
176157Snate@binkert.org# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
186157Snate@binkert.org# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
196157Snate@binkert.org# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
206157Snate@binkert.org# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
216157Snate@binkert.org# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
226157Snate@binkert.org# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
236157Snate@binkert.org# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
246157Snate@binkert.org# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
256157Snate@binkert.org# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
266157Snate@binkert.org# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
276157Snate@binkert.org#
286157Snate@binkert.org# Authors: Steve Reinhardt
296157Snate@binkert.org
306157Snate@binkert.org# Script to simplify using rundiff on trace outputs from two
316157Snate@binkert.org# invocations of m5.
326157Snate@binkert.org#
336157Snate@binkert.org# Note that you need to enable some trace flags in the args in order
346157Snate@binkert.org# to do anything useful!
356157Snate@binkert.org#
366157Snate@binkert.org# If you want to pass different arguments to the two instances of m5,
376157Snate@binkert.org# you can embed them in the simulator arguments like this:
386157Snate@binkert.org#
396157Snate@binkert.org# % tracediff "m5.opt --foo:bar=1" "m5.opt --foo:bar=2" [common args]
407768SAli.Saidi@ARM.com#
417768SAli.Saidi@ARM.com
427768SAli.Saidi@ARM.comif (@ARGV < 2) {
438492Snilay@cs.wisc.edu    die "Usage: tracediff sim1 sim2 [--trace:flags=X args...]\n";
446168Snate@binkert.org}
456168Snate@binkert.org
466157Snate@binkert.org# First two args are the two simulator binaries to compare
476157Snate@binkert.org$sim1 = shift;
486157Snate@binkert.org$sim2 = shift;
496157Snate@binkert.org
506157Snate@binkert.org# Everything else on the command line is taken to be an m5 argument to
516157Snate@binkert.org# be given to both invocations
526157Snate@binkert.org$simargs = '"' . join('" "', @ARGV) . '"';
536157Snate@binkert.org
546157Snate@binkert.org# Run individual invocations in separate dirs so output and intermediate
556157Snate@binkert.org# files (particularly config.py and config.ini) don't conflict.
566157Snate@binkert.org$dir1 = "tracediff-$$-1";
576157Snate@binkert.org$dir2 = "tracediff-$$-2";
586157Snate@binkert.orgmkdir($dir1) or die "Can't create dir $dir1\n";
596157Snate@binkert.orgmkdir($dir2) or die "Can't create dir $dir2\n";
606157Snate@binkert.org
616157Snate@binkert.org$cmd1 = "$sim1 $simargs -d $dir1 2>&1 |";
626157Snate@binkert.org$cmd2 = "$sim2 $simargs -d $dir2 2>&1 |";
636157Snate@binkert.org
646157Snate@binkert.org# This only works if you have rundiff in your path.  I just edit it
656157Snate@binkert.org# with an explicit path if necessary.
666157Snate@binkert.org$fullcmd = "rundiff '$cmd1' '$cmd2' 2>&1 > tracediff-$$.out";
676157Snate@binkert.org
686157Snate@binkert.orgprint "Executing $fullcmd\n";
696157Snate@binkert.orgsystem($fullcmd);
706157Snate@binkert.org
716157Snate@binkert.org
726157Snate@binkert.org
736157Snate@binkert.org