草稿札记

草稿笔记
sh addr2line.sh /hxapp/hxdata/bin/hxdata_sym hxdata.11259.11251



#!/bin/sh
##
bin=./hqserver/bin/hexincs64
file1=./hexincs64.24378.24352
file2=$file1"_bt"
##
if [ -f $file2 ];then
    rm $file2
fi

while read line
do
    ch1st=${line:0:1}
    if [ -z $ch1st ];then
	echo $line >> $file2
	continue
    fi
    if [ $ch1st=='#' ];then
	fields=($line)
	i=0
	newline=""
	for field in ${fields[@]}
	do
	    if [ $i -eq 1 ];then
		funcinfo=`addr2line $field -e $bin -f`
		newline=$newline$field" "
	    elif [ $i -eq 3 ];then
		newline=$newline$funcinfo" "
	    else
		newline=$newline$field" "
	    fi

	    ((i++))
	done
	echo $newline >> $file2
    else
	echo $line >> $file2
    fi
done < $file1