tracediff revision 3370:04aed9a69c6e
19665Sandreas.hansson@arm.com#! /usr/bin/env perl 29665Sandreas.hansson@arm.com# Copyright (c) 2003-2006 The Regents of The University of Michigan 39665Sandreas.hansson@arm.com# All rights reserved. 49665Sandreas.hansson@arm.com# 59665Sandreas.hansson@arm.com# Redistribution and use in source and binary forms, with or without 69665Sandreas.hansson@arm.com# modification, are permitted provided that the following conditions are 79665Sandreas.hansson@arm.com# met: redistributions of source code must retain the above copyright 89665Sandreas.hansson@arm.com# notice, this list of conditions and the following disclaimer; 99665Sandreas.hansson@arm.com# redistributions in binary form must reproduce the above copyright 109665Sandreas.hansson@arm.com# notice, this list of conditions and the following disclaimer in the 119665Sandreas.hansson@arm.com# documentation and/or other materials provided with the distribution; 129665Sandreas.hansson@arm.com# neither the name of the copyright holders nor the names of its 135353Svilas.sridharan@gmail.com# contributors may be used to endorse or promote products derived from 143395Shsul@eecs.umich.edu# this software without specific prior written permission. 153395Shsul@eecs.umich.edu# 163395Shsul@eecs.umich.edu# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 173395Shsul@eecs.umich.edu# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 183395Shsul@eecs.umich.edu# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 193395Shsul@eecs.umich.edu# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 203395Shsul@eecs.umich.edu# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 213395Shsul@eecs.umich.edu# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 223395Shsul@eecs.umich.edu# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 233395Shsul@eecs.umich.edu# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 243395Shsul@eecs.umich.edu# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 253395Shsul@eecs.umich.edu# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 263395Shsul@eecs.umich.edu# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 273395Shsul@eecs.umich.edu# 283395Shsul@eecs.umich.edu# Authors: Steve Reinhardt 293395Shsul@eecs.umich.edu 303395Shsul@eecs.umich.edu# Script to simplify using rundiff on trace outputs from two 313395Shsul@eecs.umich.edu# invocations of m5. 323395Shsul@eecs.umich.edu# 333395Shsul@eecs.umich.edu# ******Note that you need to enable some trace flags in the args in order 343395Shsul@eecs.umich.edu# to do anything useful!****** 353395Shsul@eecs.umich.edu# 363395Shsul@eecs.umich.edu# Script arguments are handled uniformly as follows: 373395Shsul@eecs.umich.edu# - If the argument does not contain a '|' character, it is appended 383395Shsul@eecs.umich.edu# to both command lines. 393395Shsul@eecs.umich.edu# - If the argument has a '|' character in it, the text on either side 403395Shsul@eecs.umich.edu# of the '|' is appended to the respective command lines. Note that 418920Snilay@cs.wisc.edu# you'll have to quote the arg or escape the '|' with a backslash 428920Snilay@cs.wisc.edu# so that the shell doesn't think you're doing a pipe. 438920Snilay@cs.wisc.edu# 448920Snilay@cs.wisc.edu# In other words, the arguments should look like the command line you 457025SBrad.Beckmann@amd.com# want to run, with "|" used to list the alternatives for the parts 469520SAndreas.Sandberg@ARM.com# that you want to differ between the two runs. 479665Sandreas.hansson@arm.com# 489520SAndreas.Sandberg@ARM.com# For example: 499520SAndreas.Sandberg@ARM.com# 509520SAndreas.Sandberg@ARM.com# % tracediff m5.opt --opt1 "--opt2|--opt3" --opt4 519520SAndreas.Sandberg@ARM.com# would compare these two runs: 529520SAndreas.Sandberg@ARM.com# m5.opt --opt1 --opt2 --opt4 539665Sandreas.hansson@arm.com# m5.opt --opt1 --opt3 --opt4 549665Sandreas.hansson@arm.com# 559665Sandreas.hansson@arm.com# If you want to compare two different simulator binaries, put a '|' 569665Sandreas.hansson@arm.com# in the first script argument ("path1/m5.opt|path2/m5.opt"). If you 578920Snilay@cs.wisc.edu# want to add arguments to one run only, just put a '|' in with text 588920Snilay@cs.wisc.edu# only on one side ("--onlyOn1|"). You can do this with multiple 599520SAndreas.Sandberg@ARM.com# arguments together too ("|-a -b -c" adds three args to the second 609520SAndreas.Sandberg@ARM.com# run only). 619520SAndreas.Sandberg@ARM.com# 628920Snilay@cs.wisc.edu 639520SAndreas.Sandberg@ARM.comif (@ARGV < 2) { 648920Snilay@cs.wisc.edu die "Usage: tracediff \"sim1|sim2\" [common-arg \"arg1|arg2\" ...]\n"; 658920Snilay@cs.wisc.edu} 668920Snilay@cs.wisc.edu 679790Sakash.bagdia@arm.comforeach $arg (@ARGV) { 689790Sakash.bagdia@arm.com @pair = split('\|', $arg, -1); # -1 enables null trailing fields 699790Sakash.bagdia@arm.com if ($#pair > 0) { 709790Sakash.bagdia@arm.com push @cmd1, $pair[0]; 719789Sakash.bagdia@arm.com push @cmd2, $pair[1]; 729789Sakash.bagdia@arm.com } else { 739789Sakash.bagdia@arm.com push @cmd1, $arg; 749800Snilay@cs.wisc.edu push @cmd2, $arg; 759800Snilay@cs.wisc.edu } 769800Snilay@cs.wisc.edu} 779800Snilay@cs.wisc.edu 789800Snilay@cs.wisc.edu# First two args are the two simulator binaries to compare 799800Snilay@cs.wisc.edu$sim1 = shift @cmd1; 809800Snilay@cs.wisc.edu$sim2 = shift @cmd2; 819800Snilay@cs.wisc.edu 829800Snilay@cs.wisc.edu# Everything else is a simulator arg. 839800Snilay@cs.wisc.edu$args1 = join(' ', @cmd1); 849800Snilay@cs.wisc.edu$args2 = join(' ', @cmd2); 859800Snilay@cs.wisc.edu 869800Snilay@cs.wisc.edu# Common mistake: if you don't set any traceflags this often isn't 879800Snilay@cs.wisc.edu# doing what you want. 889800Snilay@cs.wisc.eduif ($args1 !~ /--trace-flags/) { 899800Snilay@cs.wisc.edu print "****\n"; 909800Snilay@cs.wisc.edu print "**** WARNING: no trace flags set... you may not be diffing much!\n"; 919800Snilay@cs.wisc.edu print "****\n"; 929800Snilay@cs.wisc.edu} 939800Snilay@cs.wisc.edu 949800Snilay@cs.wisc.edu# Run individual invocations in separate dirs so output and intermediate 958920Snilay@cs.wisc.edu# files (particularly config.py and config.ini) don't conflict. 968920Snilay@cs.wisc.edu$dir1 = "tracediff-$$-1"; 978920Snilay@cs.wisc.edu$dir2 = "tracediff-$$-2"; 988920Snilay@cs.wisc.edumkdir($dir1) or die "Can't create dir $dir1\n"; 998920Snilay@cs.wisc.edumkdir($dir2) or die "Can't create dir $dir2\n"; 1008920Snilay@cs.wisc.edu 1018920Snilay@cs.wisc.edu$cmd1 = "$sim1 -d $dir1 $args1 2>&1 |"; 1028920Snilay@cs.wisc.edu$cmd2 = "$sim2 -d $dir2 $args2 2>&1 |"; 1038920Snilay@cs.wisc.edu 1048920Snilay@cs.wisc.edu# This only works if you have rundiff in your path. I just edit it 1058920Snilay@cs.wisc.edu# with an explicit path if necessary. 1068920Snilay@cs.wisc.edu$fullcmd = "rundiff '$cmd1' '$cmd2' 2>&1 > tracediff-$$.out"; 1079800Snilay@cs.wisc.edu 1089800Snilay@cs.wisc.eduprint "Executing $fullcmd\n"; 1098920Snilay@cs.wisc.edusystem($fullcmd); 1103395Shsul@eecs.umich.edu 1118920Snilay@cs.wisc.edu 1129816Sjthestness@gmail.com 1139816Sjthestness@gmail.com