akaros/scripts/bt-akaros.sh
<<
>>
Prefs
   1#!/bin/bash
   2# Barret Rhoden (brho@cs.berkeley.edu)
   3#
   4# Resolves functions from an Akaros user backtrace.
   5# Pipe a backtrace (echo "huge-copy-paste" | ./thisfile.sh) to it.
   6#
   7# Be sure to set your environment paths for the SOLIBS and BIN, or use the
   8# defaults, which require AKAROS_ROOT.
   9
  10: ${SOLIBS_PREFIX:=$AKAROS_ROOT/kern/kfs/lib/}
  11: ${SO_REGEX:=.*so$}
  12: ${BIN_PREFIX:=$AKAROS_ROOT/kern/kfs/bin/}
  13
  14# takes the path to the binary and offset (offset in hex), prints name of the
  15# function where the offset is in the binary.  basically a wrapper for
  16# addr2line.
  17function print_func()
  18{
  19        addr2line -e $1 -fC $2 | xargs
  20}
  21
  22while read line
  23do
  24        binary=`echo $line | cut -f 6 -d ' '`
  25        lib_off=`echo $line | cut -f 9 -d ' '`
  26        app_off=`echo $line | cut -f 3 -d ' '`
  27        if [[ $binary == "" ]]
  28        then
  29                break
  30        fi
  31        echo -n $line " "
  32        if [[ $binary =~ $SO_REGEX ]]
  33        then
  34                # could also do addr=$(print_func $lib $off)
  35                print_func $SOLIBS_PREFIX/$binary $lib_off
  36        else
  37                print_func $BIN_PREFIX/$binary $app_off
  38        fi
  39done
  40