Skip to content

Commit

Permalink
Add debug variable.
Browse files Browse the repository at this point in the history
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9188 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
Brian Gaeke committed Oct 16, 2003
1 parent 45f0b6d commit fb1a996
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions utils/codegen-diff
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
#!/usr/bin/perl

use Getopt::Std;
$DEBUG = 0;

sub parse_objdump_file {
my ($filename) = @_;
my @result;
open (INPUT, $filename) or die "$filename: $!\n";
print "opened objdump output file $filename\n" if $DEBUG;
while (<INPUT>) {
if (/\s*([0-9a-f]*):\t(([0-9a-f]{2} )+) *\t(.*)$/) {
my ($addr, $bytes, $instr) = ($1, $2, $4);
$addr = "0x" . $addr;
$bytes =~ s/\s*(.*\S)\s*/$1/; # trim any remaining whitespace
$instr =~ s/\s*(.*\S)\s*/$1/;
push (@result, {'addr' => $addr, 'bytes' => $bytes, 'instr' => $instr});
print "addr=$addr bytes='$bytes' instr='$instr'\n" if $DEBUG;
}
}
close INPUT;
Expand All @@ -24,6 +27,7 @@ sub parse_gdb_file {
my @result;
my $got_addr;
open (INPUT, $filename) or die "$filename: $!\n";
print "opened gdb output file $filename\n" if $DEBUG;
while (<INPUT>) {
if (/^(0x[0-9a-f]*):\t([^\t]*)\t[^:]*:\t((0x[0-9a-f]{2}\s*)+)\s*$/) {
my ($addr, $bytes, $instr) = ($1, $3, $2);
Expand All @@ -32,6 +36,7 @@ sub parse_gdb_file {
$bytes =~ s/\s*(.*\S)\s*/$1/; # trim any remaining whitespace
$instr =~ s/\s*(.*\S)\s*/$1/;
push (@result, {'addr' => $addr, 'bytes' => $bytes, 'instr' => $instr});
print "addr=$addr bytes='$bytes' instr='$instr'\n" if $DEBUG;
} elsif (/^(0x[0-9a-f]*):\t$/) { # deal with gdb's line breaker
$got_addr = $1;
} elsif ($got_addr && /^ ([^\t]*)\t[^:]*:\t((0x[0-9a-f]{2}\s*)+)\s*$/) {
Expand All @@ -41,6 +46,7 @@ sub parse_gdb_file {
$bytes =~ s/\s*(.*\S)\s*/$1/; # trim any remaining whitespace
$instr =~ s/\s*(.*\S)\s*/$1/;
push (@result, {'addr' => $addr, 'bytes' => $bytes, 'instr' => $instr});
print "addr=$addr bytes='$bytes' instr='$instr'\n" if $DEBUG;
undef $got_addr;
}
}
Expand Down

0 comments on commit fb1a996

Please sign in to comment.