Created
March 4, 2013 11:52
-
-
Save spiculator/5081789 to your computer and use it in GitHub Desktop.
resolve kernel trace with system map
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl -w | |
use strict; | |
use FindBin; | |
1 == @ARGV or die "Usage: cat kernel-call-trace.txt |$FindBin::Script <system-map-file>\n"; | |
my $map = shift @ARGV; | |
my (@address, @type, @name); | |
open MAP, "<", $map or die $!; | |
while(<MAP>) { | |
/^([\da-f]{16}) (\w) ([\w\.]+)$/ or die "Bad line from $map: $_\n"; | |
{ | |
no warnings "portable"; | |
push @address, hex $1; | |
} | |
push @type, $2; | |
push @name, $3; | |
} | |
close MAP or die $!; | |
sub mapfind($) { | |
my $in; | |
{ | |
no warnings "portable"; | |
$in = hex shift; | |
} | |
my $i = 0; | |
for( $i = 1; $i <= @address; ++$i ) { | |
last if $i == @address or $address[$i] > $in; | |
} | |
--$i; | |
return sprintf "%s %s (+%s)", $type[$i], $name[$i], $in - $address[$i]; | |
} | |
while(<>) { | |
s/\<([\da-f]{16})\>/mapfind($1)/ge; | |
print; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment