3 # Copyright 2008, Intel Corporation
5 # This file is part of the Linux kernel
7 # This program file is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by the
9 # Free Software Foundation; version 2 of the License.
12 # Arjan van de Ven <arjan@linux.intel.com>
15 my $vmlinux_name = $ARGV[0];
18 # Step 1: Parse the oops to find the EIP value
23 if ($_ =~ /EIP: 0060:\[\<([a-z0-9]+)\>\]/) {
28 if ($target =~ /^f8/) {
29 print "This script does not work on modules ... \n";
34 print "No oops found!\n";
36 print " dmesg | perl scripts/markup_oops.pl vmlinux\n";
46 my ($address, $target) = @_;
47 my $ad = "0x".$address;
48 my $ta = "0x".$target;
49 my $delta = hex($ad) - hex($ta);
51 if (($delta > -4096) && ($delta < 4096)) {
59 # first, parse the input into the lines array, but to keep size down,
60 # we only do this for 4Kb around the sweet spot
64 open(FILE
, "objdump -dS $vmlinux_name |") || die "Cannot start objdump";
70 if ($line =~ /^([a-f0-9]+)\:/) {
71 if (InRange
($1, $target)) {
76 if ($line =~ /^([a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9]+)\:/) {
78 if (!InRange
($val, $target)) {
81 if ($val eq $target) {
85 $lines[$counter] = $line;
87 $counter = $counter + 1;
94 print "No matching code found \n";
99 print "No matching code found \n";
107 # now we go up and down in the array to find how much we want to print
113 my $line = $lines[$start];
114 if ($line =~ /^([a-f0-9]+)\:/) {
115 $binarylines = $binarylines + 1;
117 $codelines = $codelines + 1;
119 if ($codelines > 10) {
122 if ($binarylines > 20) {
131 while ($finish < $counter) {
132 $finish = $finish + 1;
133 my $line = $lines[$finish];
134 if ($line =~ /^([a-f0-9]+)\:/) {
135 $binarylines = $binarylines + 1;
137 $codelines = $codelines + 1;
139 if ($codelines > 10) {
142 if ($binarylines > 20) {
152 while ($i < $finish) {
154 $fulltext = $fulltext . "*$lines[$i] <----- faulting instruction\n";
156 $fulltext = $fulltext . " $lines[$i]\n";