2006-08-26 11:35:28 +00:00
|
|
|
: # -*-Mode: perl;-*- use perl, wherever it is
|
|
|
|
eval 'exec perl -wS $0 ${1+"$@"}'
|
|
|
|
if 0;
|
|
|
|
######################################################################
|
|
|
|
#
|
2008-01-15 14:29:08 +00:00
|
|
|
# Copyright 2005-2008 by Wilson Snyder <wsnyder@wsnyder.org>. This
|
2006-08-26 11:35:28 +00:00
|
|
|
# program is free software; you can redistribute it and/or modify it under
|
|
|
|
# the terms of either the GNU Lesser General Public License or the Perl
|
|
|
|
# Artistic License.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
######################################################################
|
|
|
|
|
|
|
|
require 5.006_001;
|
|
|
|
use warnings;
|
|
|
|
use Getopt::Long;
|
|
|
|
use IO::File;
|
|
|
|
use Pod::Usage;
|
|
|
|
use strict;
|
|
|
|
use vars qw ($Debug);
|
|
|
|
|
|
|
|
#======================================================================
|
|
|
|
|
|
|
|
|
|
|
|
#======================================================================
|
|
|
|
# main
|
|
|
|
|
|
|
|
$Debug = 0;
|
|
|
|
my $Opt_A;
|
|
|
|
my $Opt_B;
|
|
|
|
autoflush STDOUT 1;
|
|
|
|
autoflush STDERR 1;
|
2007-05-18 18:48:22 +00:00
|
|
|
Getopt::Long::config ("no_auto_abbrev");
|
2006-08-26 11:35:28 +00:00
|
|
|
if (! GetOptions (
|
|
|
|
"help" => \&usage,
|
|
|
|
"debug" => \&debug,
|
|
|
|
"<>" => \¶meter,
|
|
|
|
)) {
|
2007-05-18 18:48:22 +00:00
|
|
|
die "%Error: Bad usage, try 'verilator_difftree --help'\n";
|
2006-08-26 11:35:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
defined $Opt_A or die "%Error: No old diff filename\n";
|
|
|
|
defined $Opt_B or die "%Error: No new diff filename\n";
|
|
|
|
|
2006-12-21 14:35:19 +00:00
|
|
|
-e $Opt_A or die "%Error: No old diff filename found: $Opt_A\n";
|
|
|
|
-e $Opt_B or die "%Error: No new diff filename found: $Opt_B\n";
|
|
|
|
|
2006-08-26 11:35:28 +00:00
|
|
|
if (-d $Opt_A && -d $Opt_B) {
|
|
|
|
diff_dir ($Opt_A, $Opt_B);
|
|
|
|
} elsif (-f $Opt_A && -f $Opt_B) {
|
|
|
|
diff_file ($Opt_A, $Opt_B);
|
|
|
|
} else {
|
|
|
|
die "%Error: Mix of files and dirs\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
sub diff_dir {
|
|
|
|
my $a = shift;
|
|
|
|
my $b = shift;
|
|
|
|
# Diff all files under two directories
|
|
|
|
my %files;
|
|
|
|
|
|
|
|
foreach my $fn (glob("$a/*.tree")) {
|
|
|
|
(my $base = $fn) =~ s!.*/!!;
|
|
|
|
$files{$base}{a} = $fn;
|
|
|
|
}
|
|
|
|
foreach my $fn (glob("$b/*.tree")) {
|
|
|
|
(my $base = $fn) =~ s!.*/!!;
|
|
|
|
$files{$base}{b} = $fn;
|
|
|
|
}
|
|
|
|
foreach my $base (sort (keys %files)) {
|
|
|
|
my $a = $files{$base}{a};
|
|
|
|
my $b = $files{$base}{b};
|
|
|
|
next if !$a || !$b;
|
|
|
|
print "="x70,"\n";
|
|
|
|
print "= $a <-> $b\n";
|
|
|
|
diff_file($a,$b);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sub diff_file {
|
|
|
|
my $a = shift;
|
|
|
|
my $b = shift;
|
|
|
|
# Compare the two tree files
|
|
|
|
my $tmp_a = "/tmp/$$.a";
|
|
|
|
my $tmp_b = "/tmp/$$.b";
|
|
|
|
|
|
|
|
filter ($a, $tmp_a);
|
|
|
|
filter ($b, $tmp_b);
|
|
|
|
system("diff $tmp_a $tmp_b");
|
|
|
|
unlink $tmp_a;
|
|
|
|
unlink $tmp_b;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub filter {
|
|
|
|
my $fn1 = shift;
|
|
|
|
my $fn2 = shift;
|
|
|
|
# Remove hex numbers before diffing
|
|
|
|
my $f1 = IO::File->new ($fn1) or die "%Error: $! $fn1,";
|
|
|
|
my $f2 = IO::File->new ($fn2,"w") or die "%Error: $! $fn2,";
|
|
|
|
while (defined (my $line=$f1->getline())) {
|
|
|
|
next if $line =~ / This=/;
|
|
|
|
$line =~ s/0x[a-f0-9]+/0x/g;
|
|
|
|
$line =~ s/<e[0-9]+\#?>/<e>/g;
|
|
|
|
print $f2 $line;
|
|
|
|
}
|
|
|
|
$f1->close;
|
|
|
|
$f2->close;
|
|
|
|
}
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
|
|
|
sub usage {
|
|
|
|
pod2usage(-verbose=>2, -exitval => 2);
|
|
|
|
exit (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
sub debug {
|
|
|
|
$Debug = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub parameter {
|
|
|
|
my $param = shift;
|
|
|
|
if (!defined $Opt_A) {
|
|
|
|
$Opt_A = $param;
|
|
|
|
} elsif (!defined $Opt_B) {
|
|
|
|
$Opt_B = $param;
|
2008-06-10 01:25:10 +00:00
|
|
|
} else {
|
2006-08-26 11:35:28 +00:00
|
|
|
die "%Error: Unknown parameter: $param\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#######################################################################
|
|
|
|
|
|
|
|
sub run {
|
|
|
|
# Run a system command, check errors
|
|
|
|
my $command = shift;
|
|
|
|
print "\t$command\n";
|
|
|
|
system "$command";
|
|
|
|
my $status = $?;
|
|
|
|
($status == 0) or die "%Error: Command Failed $command, $status, stopped";
|
|
|
|
}
|
|
|
|
|
|
|
|
#######################################################################
|
|
|
|
__END__
|
|
|
|
|
|
|
|
=pod
|
|
|
|
|
|
|
|
=head1 NAME
|
|
|
|
|
|
|
|
verilator_difftree - Compare two Verilator debugging trees
|
|
|
|
|
|
|
|
=head1 SYNOPSIS
|
|
|
|
|
|
|
|
verilator_difftree .../a/a.tree .../b/a.tree
|
|
|
|
verilator_difftree .../a .../b
|
|
|
|
|
|
|
|
=head1 DESCRIPTION
|
|
|
|
|
|
|
|
Verilator_difftree is used for debugging Verilator tree output files. It
|
|
|
|
performs a diff between two files, or all files common between two
|
|
|
|
directories, ignoring irrelevant pointer differences.
|
|
|
|
|
|
|
|
=head1 ARGUMENTS
|
|
|
|
|
|
|
|
=over 4
|
|
|
|
|
|
|
|
=item --help
|
|
|
|
|
|
|
|
Displays this message and program version and exits.
|
|
|
|
|
|
|
|
=back
|
|
|
|
|
|
|
|
=head1 DISTRIBUTION
|
|
|
|
|
2008-04-25 12:16:55 +00:00
|
|
|
The latest version is available from L<http://www.veripool.org/verilator>.
|
2006-08-26 11:35:28 +00:00
|
|
|
|
2008-01-15 14:29:08 +00:00
|
|
|
Copyright 2005-2008 by Wilson Snyder. This package is free software; you
|
2006-08-26 11:35:28 +00:00
|
|
|
can redistribute it and/or modify it under the terms of either the GNU
|
|
|
|
Lesser General Public License or the Perl Artistic License.
|
|
|
|
|
|
|
|
=head1 AUTHORS
|
|
|
|
|
|
|
|
Wilson Snyder <wsnyder@wsnyder.org>
|
|
|
|
|
|
|
|
=head1 SEE ALSO
|
|
|
|
|
|
|
|
C<verilator>
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
######################################################################
|
|
|
|
### Local Variables:
|
2006-10-06 16:08:46 +00:00
|
|
|
### compile-command: "$V4/bin/verilator_difftree $V4/test_c/obj_dir/V*_03_*.tree $V4N/test_c/obj_dir/V*_03_*.tree"
|
2006-08-26 11:35:28 +00:00
|
|
|
### End:
|