--- xtrace.sh.org Wed Apr 17 04:05:25 2002 +++ xtrace.sh Fri May 3 05:18:23 2002 @@ -60,7 +60,7 @@ exit 0 } -# Print out function name, file, and line number is a nice formatted way. +# Print out function name, file, and line number in a nice formatted way. format_line() { fct=$1 file=${2%%:*} @@ -158,21 +158,26 @@ fi done else - fifo=$(mktemp -u ${TMPDIR:-/tmp}/xprof.XXXXXX) + fifo=$(mktemp -u ${TMPDIR:-/tmp}/xtrace.XXXXXX) mkfifo -m 0600 $fifo || exit 1 + trap 'rm $fifo; exit 1' SIGINT SIGTERM SIGPIPE + # Now start the program and let it write to the FIFO. - $TERMINAL_PROG -T "xtrace - $program $*" -e /bin/sh -c "LD_PRELOAD=$pcprofileso PCPROFILE_OUTPUT=$fifo $program $*; read $fifo" & + $TERMINAL_PROG -T "xtrace - $program $*" -e /bin/sh -c "LD_PRELOAD=$pcprofileso PCPROFILE_OUTPUT=$fifo $program $*; read < $fifo" & termpid=$! - $pcprofiledump $fifo | - sed 's/this = \([^,]*\).*/\1/' | - addr2line -fC -e $program | + $pcprofiledump -u $fifo | + while read line; do + echo $line | + sed 's/this = \([^,]*\).*/\1/' | + addr2line -fC -e $program + done | while read fct; do read file if test "$fct" != '??' -a "$file" != '??:0'; then format_line $fct $file fi done - read -p "Press return to end the program." + read -p "Press return here to close $TERMINAL_PROG($program)." echo > $fifo rm $fifo fi