Stubs for SPARC's tlbs
[gem5.git] / util / tracediff
index 87210f1ed260c1ef49fe03d97fa2731472489a65..b25efe9b2309160d39c64e273edb40119b385772 100755 (executable)
@@ -1,5 +1,5 @@
 #! /usr/bin/env perl
-# Copyright (c) 2003-2005 The Regents of The University of Michigan
+# Copyright (c) 2003-2006 The Regents of The University of Michigan
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
 # Script to simplify using rundiff on trace outputs from two
 # invocations of m5.
 #
-# Note that you need to enable some trace flags in the args in order
-# to do anything useful!
+# ******Note that you need to enable some trace flags in the args in order
+# to do anything useful!******
 #
-# If you want to pass different arguments to the two instances of m5,
-# you can embed them in the simulator arguments like this:
+# Script arguments are handled uniformly as follows:
+# - If the argument does not contain a '|' character, it is appended
+#   to both command lines.
+# - If the argument has a '|' character in it, the text on either side
+#   of the '|' is appended to the respective command lines.  Note that
+#   you'll have to quote the arg or escape the '|' with a backslash
+#   so that the shell doesn't think you're doing a pipe.
 #
-# % tracediff "m5.opt --foo:bar=1" "m5.opt --foo:bar=2" [common args]
+# In other words, the arguments should look like the command line you
+# want to run, with "|" used to list the alternatives for the parts
+# that you want to differ between the two runs.
+#
+# For example:
+#
+# % tracediff m5.opt --opt1 "--opt2|--opt3" --opt4
+# would compare these two runs:
+# m5.opt --opt1 --opt2 --opt4
+# m5.opt --opt1 --opt3 --opt4
+#
+# If you want to compare two different simulator binaries, put a '|'
+# in the first script argument ("path1/m5.opt|path2/m5.opt").  If you
+# want to add arguments to one run only, just put a '|' in with text
+# only on one side ("--onlyOn1|").  You can do this with multiple
+# arguments together too ("|-a -b -c" adds three args to the second
+# run only).
 #
 
 if (@ARGV < 2) {
-    die "Usage: tracediff sim1 sim2 [--trace:flags=X args...]\n";
+    die "Usage: tracediff \"sim1|sim2\" [common-arg \"arg1|arg2\" ...]\n";
+}
+
+foreach $arg (@ARGV) {
+    @pair = split('\|', $arg, -1); # -1 enables null trailing fields
+    if ($#pair > 0) {
+       push @cmd1, $pair[0];
+       push @cmd2, $pair[1];
+    } else {
+       push @cmd1, $arg;
+       push @cmd2, $arg;
+    }
 }
 
 # First two args are the two simulator binaries to compare
-$sim1 = shift;
-$sim2 = shift;
+$sim1 = shift @cmd1;
+$sim2 = shift @cmd2;
+
+# Everything else is a simulator arg.
+$args1 = join(' ', @cmd1);
+$args2 = join(' ', @cmd2);
 
-# Everything else on the command line is taken to be an m5 argument to
-# be given to both invocations
-$simargs = '"' . join('" "', @ARGV) . '"';
+# Common mistake: if you don't set any traceflags this often isn't
+# doing what you want.
+if ($args1 !~ /--trace-flags/) {
+    print "****\n";
+    print "**** WARNING: no trace flags set... you may not be diffing much!\n";
+    print "****\n";
+}
 
 # Run individual invocations in separate dirs so output and intermediate
 # files (particularly config.py and config.ini) don't conflict.
@@ -58,8 +98,8 @@ $dir2 = "tracediff-$$-2";
 mkdir($dir1) or die "Can't create dir $dir1\n";
 mkdir($dir2) or die "Can't create dir $dir2\n";
 
-$cmd1 = "$sim1 $simargs -d $dir1 2>&1 |";
-$cmd2 = "$sim2 $simargs -d $dir2 2>&1 |";
+$cmd1 = "$sim1 -d $dir1 $args1 2>&1 |";
+$cmd2 = "$sim2 -d $dir2 $args2 2>&1 |";
 
 # This only works if you have rundiff in your path.  I just edit it
 # with an explicit path if necessary.