backtrace utility
authorBen Pfaff <blp@cs.stanford.edu>
Thu, 16 Sep 2004 00:53:41 +0000 (00:53 +0000)
committerBen Pfaff <blp@cs.stanford.edu>
Thu, 16 Sep 2004 00:53:41 +0000 (00:53 +0000)
src/utils/backtrace [new file with mode: 0755]

diff --git a/src/utils/backtrace b/src/utils/backtrace
new file mode 100755 (executable)
index 0000000..18ff195
--- /dev/null
@@ -0,0 +1,19 @@
+#! /usr/bin/perl
+$a2l = search_path ("i386-elf-addr2line") || search_path ("addr2line");
+$bin = shift @ARGV;
+open (A2L, "$a2l -fe $bin " . join (' ', @ARGV) . "|");
+while ($function = <A2L>) {
+    $line = <A2L>;
+    chomp $function;
+    chomp $line;
+    print "$function ($line)\n";
+}
+   
+sub search_path {
+    my ($target) = @_;
+    for $dir (split (':', $ENV{PATH})) {
+       my ($file = "$dir/$target";
+       return $file if -e $file;
+    }
+    return 0;
+}