X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?p=palacios.git;a=blobdiff_plain;f=geekos%2Fscripts%2FeipToFunction;fp=geekos%2Fscripts%2FeipToFunction;h=98bffa6adb4b564fb22b57729a7f9017c46a692d;hp=0000000000000000000000000000000000000000;hb=ddc16b0737cf58f7aa90a69c6652cdf4090aec51;hpb=626595465a2c6987606a6bc697df65130ad8c2d3 diff --git a/geekos/scripts/eipToFunction b/geekos/scripts/eipToFunction new file mode 100755 index 0000000..98bffa6 --- /dev/null +++ b/geekos/scripts/eipToFunction @@ -0,0 +1,42 @@ +#! /usr/bin/perl + +# Find the function name from the value of the EIP (instruction pointer) +# register from a Bochs crash report. Uses the kernel symbol +# map (kernel.syms) produced by compiling the kernel. + +use strict qw(refs vars); +use FileHandle; + +if (scalar(@ARGV) != 2){ + print STDERR "Usage: eipToFunction kernel.syms \n"; + print STDERR " eip value should be in hex\n"; + exit 1; +} + +my $syms = shift @ARGV; +my $eip = hex(shift @ARGV); + +my @text = (); + +my $fh = new FileHandle("<$syms"); +(defined $fh) || die "Couldn't open $syms: $!\n"; +while (<$fh>) { + #print $_; + if (/^([0-9A-Fa-f]+)\s+[Tt]\s+(\S+)\s*$/) { + push @text, [hex($1), $2]; + } +} +$fh->close(); +#print scalar(@text),"\n"; + +@text = sort { $a->[0] <=> $b->[0] } @text; + +my $last = undef; + +foreach my $entry (@text) { + last if ($eip < $entry->[0]); + $last = $entry; +} +printf("%s\n",(defined $last) ? $last->[1] : "not found"); + +# vim:ts=4