Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 199515
b: refs/heads/master
c: 52e13e2
h: refs/heads/master
i:
  199513: 5478f38
  199511: 1ecb21e
v: v3
  • Loading branch information
Hui Zhu authored and Michal Marek committed Feb 5, 2010
1 parent 6d5f711 commit 0065f69
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 14 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: d224a94ab988c01f2841dccd39a518424fd26336
refs/heads/master: 52e13e219d5930fb8fb774050e6ecffa244a60a9
49 changes: 36 additions & 13 deletions trunk/scripts/markup_oops.pl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use File::Basename;
use Math::BigInt;
use Getopt::Long;

# Copyright 2008, Intel Corporation
#
Expand All @@ -15,17 +16,26 @@
# Arjan van de Ven <arjan@linux.intel.com>


my $vmlinux_name = $ARGV[0];
my $cross_compile = "";
my $vmlinux_name = "";
my $modulefile = "";

# Get options
Getopt::Long::GetOptions(
'cross-compile|c=s' => \$cross_compile,
'module|m=s' => \$modulefile,
'help|h' => \&usage,
);
my $vmlinux_name = $ARGV[$#ARGV];
if (!defined($vmlinux_name)) {
my $kerver = `uname -r`;
chomp($kerver);
$vmlinux_name = "/lib/modules/$kerver/build/vmlinux";
print "No vmlinux specified, assuming $vmlinux_name\n";
}
my $filename = $vmlinux_name;
#
# Step 1: Parse the oops to find the EIP value
#

# Parse the oops to find the EIP value

my $target = "0";
my $function;
Expand Down Expand Up @@ -177,26 +187,26 @@ sub process_x86_regs
my $decodestop = Math::BigInt->from_hex("0x$target") + 8192;
if ($target eq "0") {
print "No oops found!\n";
print "Usage: \n";
print " dmesg | perl scripts/markup_oops.pl vmlinux\n";
exit;
usage();
}

# if it's a module, we need to find the .ko file and calculate a load offset
if ($module ne "") {
my $modulefile = `modinfo $module | grep '^filename:' | awk '{ print \$2 }'`;
chomp($modulefile);
if ($modulefile eq "") {
my $modulefile = `modinfo $module | grep '^filename:' | awk '{ print \$2 }'`;
chomp($modulefile);
}
$filename = $modulefile;
if ($filename eq "") {
print "Module .ko file for $module not found. Aborting\n";
exit;
}
# ok so we found the module, now we need to calculate the vma offset
open(FILE, "objdump -dS $filename |") || die "Cannot start objdump";
open(FILE, $cross_compile."objdump -dS $filename |") || die "Cannot start objdump";
while (<FILE>) {
if ($_ =~ /^([0-9a-f]+) \<$function\>\:/) {
my $fu = $1;
$vmaoffset = hex($target) - hex($fu) - hex($func_offset);
$vmaoffset = Math::BigInt->from_hex("0x$target") - Math::BigInt->from_hex("0x$fu") - Math::BigInt->from_hex("0x$func_offset");
}
}
close(FILE);
Expand All @@ -212,7 +222,7 @@ sub InRange {
my ($address, $target) = @_;
my $ad = "0x".$address;
my $ta = "0x".$target;
my $delta = hex($ad) - hex($ta);
my $delta = Math::BigInt->from_hex($ad) - Math::BigInt->from_hex($ta);

if (($delta > -4096) && ($delta < 4096)) {
return 1;
Expand All @@ -225,7 +235,7 @@ sub InRange {
# first, parse the input into the lines array, but to keep size down,
# we only do this for 4Kb around the sweet spot

open(FILE, "objdump -dS --adjust-vma=$vmaoffset --start-address=$decodestart --stop-address=$decodestop $filename |") || die "Cannot start objdump";
open(FILE, $cross_compile."objdump -dS --adjust-vma=$vmaoffset --start-address=$decodestart --stop-address=$decodestop $filename |") || die "Cannot start objdump";

while (<FILE>) {
my $line = $_;
Expand Down Expand Up @@ -345,3 +355,16 @@ sub InRange {
$i = $i +1;
}

sub usage {
print <<EOT;
Usage:
dmesg | perl $0 [OPTION] [VMLINUX]
OPTION:
-c, --cross-compile CROSS_COMPILE Specify the prefix used for toolchain.
-m, --module MODULE_DIRNAME Specify the module directory name.
-h, --help Help.
EOT
exit;
}

0 comments on commit 0065f69

Please sign in to comment.