#! /bin/bash if [ "$2" == "" ]; then echo "Usage: ooomapstack stackdump debuginfodir" echo "e.g. ooomapstack /tmp/crashdump /usr/lib/debug" exit fi while read line ; do if [ ${#line} -gt 2 ]; then if [ ${line:0:2} == "0x" ]; then words=($line) if [ ${words[2]} == "+" ]; then echo \# $line else dso=${words[2]} debugdso="$2""${words[2]}".debug reladdress=${words[4]} if [ -e $debugdso ]; then dynamic=${words[1]} dynamic=${dynamic/:/} dsoloadaddr=`readelf -l $debugdso|grep LOAD|head -n 1` dsoloadaddr=`echo $dsoloadaddr| cut -d" " -f 3` debugdynamic=`readelf -l $debugdso|grep DYNAMIC|head -n 1` debugdynamic=`echo $debugdynamic| cut -d" " -f 2` dsoloadaddr=`echo $dsoloadaddr | sed -e 's:^0[bBxX]::' | tr '[a-f]' '[A-F]'` reladdress=`echo $reladdress | sed -e 's:^0[bBxX]::' | tr '[a-f]' '[A-F]'` debugdynamic=`echo $debugdynamic | sed -e 's:^0[bBxX]::' | tr '[a-f]' '[A-F]'` dynamic=`echo $dynamic | sed -e 's:^0[bBxX]::' | tr '[a-f]' '[A-F]'` offlineaddress=`echo "ibase=16;obase=10;$dsoloadaddr+$reladdress+$debugdynamic-$dynamic" | bc` echo $dso : 0x$offlineaddress while read debug; do echo " "$debug done < <(addr2line -C -e $debugdso -f 0x$offlineaddress) else echo $dso : $reladdress echo " "$debugdso missing echo " "`echo $line | cut -d " " -f 3-` fi fi fi fi done < <(cat $1)