rundiff (338:6cf264d111b4) rundiff (354:fbfbff4f09c3)
1#! /usr/bin/env perl
2
3# Copyright (c) 2003 The Regents of The University of Michigan
4# All rights reserved.
5#
6# Redistribution and use in source and binary forms, with or without
7# modification, are permitted provided that the following conditions are
8# met: redistributions of source code must retain the above copyright

--- 27 unchanged lines hidden (view full) ---

36# "filename" is a pipe (|). Thus to compare the instruction traces
37# from two versions of m5 (m5a and m5b), you can do this:
38#
39# rundiff 'm5a --trace:flags=InstExec |' 'm5b --trace:flags=InstExec |'
40#
41
42use strict;
43
1#! /usr/bin/env perl
2
3# Copyright (c) 2003 The Regents of The University of Michigan
4# All rights reserved.
5#
6# Redistribution and use in source and binary forms, with or without
7# modification, are permitted provided that the following conditions are
8# met: redistributions of source code must retain the above copyright

--- 27 unchanged lines hidden (view full) ---

36# "filename" is a pipe (|). Thus to compare the instruction traces
37# from two versions of m5 (m5a and m5b), you can do this:
38#
39# rundiff 'm5a --trace:flags=InstExec |' 'm5b --trace:flags=InstExec |'
40#
41
42use strict;
43
44use Getopt::Std;
45
44#
46#
47# Options:
48# -c <n> : print n lines of context before & after changes
49# -l <n> : use n lines of lookahead
50# -x : use "complex" diff from Algorithm::Diff (see below)
51#
52our ($opt_c, $opt_l, $opt_x);
53getopts('c:l:x');
54
55#
45# For the highest-quality (minimal) diffs, we can use the
56# For the highest-quality (minimal) diffs, we can use the
46# Algorithm::Diff package. If you don't have this installed, or want
47# the script to run faster (like 3-4x faster, based on informal
48# observation), set $use_complexdiff to 0; then a built-in, simple,
49# and generally quite adequate algorithm will be used instead.
50my $use_complexdiff = 0;
57# Algorithm::Diff package. By default, a built-in, simple, and
58# generally quite adequate algorithm will be used. If you have
59# Algorithm::Diff installed on your system, and don't mind having the
60# script go slower (like 3-4x slower, based on informal observation),
61# then specify '-x' on the command line to use it.
62my $use_complexdiff = defined($opt_x);
51
63
52#if ($use_complexdiff) {
53# use Algorithm::Diff qw(traverse_sequences);
54#};
64if ($use_complexdiff) {
65 # Don't use 'use', as that's a compile-time option and will fail
66 # on systems that don't have Algorithm::Diff installed even if
67 # $use_complexdiff is false. 'require' is evaluated at runtime,
68 # so it's OK.
69 require Algorithm::Diff;
70 import Algorithm::Diff qw(traverse_sequences);
71};
55
72
56my $lookahead_lines = 200;
57my $precontext_lines = 3;
58my $postcontext_lines = 3;
73my $lookahead_lines = $opt_l || 200;
59
74
75# in theory you could have different amounts of context before and
76# after a diff, but until someone needs that there's only one arg to
77# set both.
78my $precontext_lines = $opt_c || 3;
79my $postcontext_lines = $precontext_lines;
80
60my $file1 = $ARGV[0];
61my $file2 = $ARGV[1];
62
63die "Need two args." if (!(defined($file1) && defined($file2)));
64
65my ($fh1, $fh2);
66open($fh1, $file1) or die "Can't open $file1";
67open($fh2, $file2) or die "Can't open $file2";

--- 210 unchanged lines hidden ---
81my $file1 = $ARGV[0];
82my $file2 = $ARGV[1];
83
84die "Need two args." if (!(defined($file1) && defined($file2)));
85
86my ($fh1, $fh2);
87open($fh1, $file1) or die "Can't open $file1";
88open($fh2, $file2) or die "Can't open $file2";

--- 210 unchanged lines hidden ---