Skip to content

Commit

Permalink
scripts: add x86 64 bit support to the markup_oops.pl script
Browse files Browse the repository at this point in the history
Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
  • Loading branch information
fenrus75 authored and sravnborg committed Feb 15, 2009
1 parent c19ef7f commit 11df65c
Showing 1 changed file with 55 additions and 4 deletions.
59 changes: 55 additions & 4 deletions scripts/markup_oops.pl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/perl -w
#!/usr/bin/perl

use File::Basename;

Expand Down Expand Up @@ -29,7 +29,7 @@
my $target = "0";
my $function;
my $module = "";
my $func_offset;
my $func_offset = 0;
my $vmaoffset = 0;

my %regs;
Expand All @@ -49,6 +49,39 @@ sub parse_x86_regs
$regs{"%edi"} = $2;
$regs{"%esp"} = $4;
}
if ($line =~ /RAX: ([0-9a-f]+) RBX: ([0-9a-f]+) RCX: ([0-9a-f]+)/) {
$regs{"%eax"} = $1;
$regs{"%ebx"} = $2;
$regs{"%ecx"} = $3;
}
if ($line =~ /RDX: ([0-9a-f]+) RSI: ([0-9a-f]+) RDI: ([0-9a-f]+)/) {
$regs{"%edx"} = $1;
$regs{"%esi"} = $2;
$regs{"%edi"} = $3;
}
if ($line =~ /RBP: ([0-9a-f]+) R08: ([0-9a-f]+) R09: ([0-9a-f]+)/) {
$regs{"%r08"} = $2;
$regs{"%r09"} = $3;
}
if ($line =~ /R10: ([0-9a-f]+) R11: ([0-9a-f]+) R12: ([0-9a-f]+)/) {
$regs{"%r10"} = $1;
$regs{"%r11"} = $2;
$regs{"%r12"} = $3;
}
if ($line =~ /R13: ([0-9a-f]+) R14: ([0-9a-f]+) R15: ([0-9a-f]+)/) {
$regs{"%r13"} = $1;
$regs{"%r14"} = $2;
$regs{"%r15"} = $3;
}
}

sub reg_name
{
my ($reg) = @_;
$reg =~ s/r(.)x/e\1x/;
$reg =~ s/r(.)i/e\1i/;
$reg =~ s/r(.)p/e\1p/;
return $reg;
}

sub process_x86_regs
Expand Down Expand Up @@ -83,18 +116,26 @@ sub process_x86_regs
}

foreach $reg (keys(%regs)) {
my $clobberprime = reg_name($clobber);
my $lastwordprime = reg_name($lastword);
my $val = $regs{$reg};
if ($val =~ /^[0]+$/) {
$val = "0";
} else {
$val =~ s/^0*//;
}

# first check if we're clobbering this register; if we do
# we print it with a =>, and then delete its value
if ($clobber =~ /$reg/) {
if ($clobber =~ /$reg/ || $clobberprime =~ /$reg/) {
if (length($val) > 0) {
$str = $str . " $reg => $val ";
}
$regs{$reg} = "";
$val = "";
}
# now check if we're reading this register
if ($lastword =~ /$reg/) {
if ($lastword =~ /$reg/ || $lastwordprime =~ /$reg/) {
if (length($val) > 0) {
$str = $str . " $reg = $val ";
}
Expand All @@ -109,15 +150,25 @@ sub process_x86_regs
if ($line =~ /EIP: 0060:\[\<([a-z0-9]+)\>\]/) {
$target = $1;
}
if ($line =~ /RIP: 0010:\[\<([a-z0-9]+)\>\]/) {
$target = $1;
}
if ($line =~ /EIP is at ([a-zA-Z0-9\_]+)\+(0x[0-9a-f]+)\/0x[a-f0-9]/) {
$function = $1;
$func_offset = $2;
}
if ($line =~ /RIP: 0010:\[\<[0-9a-f]+\>\] \[\<[0-9a-f]+\>\] ([a-zA-Z0-9\_]+)\+(0x[0-9a-f]+)\/0x[a-f0-9]/) {
$function = $1;
$func_offset = $2;
}

# check if it's a module
if ($line =~ /EIP is at ([a-zA-Z0-9\_]+)\+(0x[0-9a-f]+)\/0x[a-f0-9]+\W\[([a-zA-Z0-9\_\-]+)\]/) {
$module = $3;
}
if ($line =~ /RIP: 0010:\[\<[0-9a-f]+\>\] \[\<[0-9a-f]+\>\] ([a-zA-Z0-9\_]+)\+(0x[0-9a-f]+)\/0x[a-f0-9]+\W\[([a-zA-Z0-9\_\-]+)\]/) {
$module = $3;
}
parse_x86_regs($line);
}

Expand Down

0 comments on commit 11df65c

Please sign in to comment.