3 # Find the function name from the value of the EIP (instruction pointer)
4 # register from a Bochs crash report. Uses the kernel symbol
5 # map (kernel.syms) produced by compiling the kernel.
7 use strict qw(refs vars);
10 if (scalar(@ARGV) != 2){
11 print STDERR "Usage: eipToFunction kernel.syms <eip value>\n";
12 print STDERR " eip value should be in hex\n";
16 my $syms = shift @ARGV;
17 my $eip = hex(shift @ARGV);
21 my $fh = new FileHandle("<$syms");
22 (defined $fh) || die "Couldn't open $syms: $!\n";
25 if (/^([0-9A-Fa-f]+)\s+[Tt]\s+(\S+)\s*$/) {
26 push @text, [hex($1), $2];
30 #print scalar(@text),"\n";
32 @text = sort { $a->[0] <=> $b->[0] } @text;
36 foreach my $entry (@text) {
37 last if ($eip < $entry->[0]);
40 printf("%s\n",(defined $last) ? $last->[1] : "not found");