Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


Release 1.0
[palacios.git] / geekos / scripts / eipToFunction
diff --git a/geekos/scripts/eipToFunction b/geekos/scripts/eipToFunction
new file mode 100755 (executable)
index 0000000..98bffa6
--- /dev/null
@@ -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 <eip value>\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