# [whitespacing for filenames],
# [whitespacing for line numbers])
dump_trace() {
- local funcname="" sourcefile="" lineno="" n e s="yes"
+ local funcname="" sourcefile="" lineno="" s="yes" n p
declare -i strip=${1:-1}
local filespacing=$2 linespacing=$3
# that the user will not be interested in. Therefore, the stack trace
# should only show calls that come after qa_call().
(( n = ${#FUNCNAME[@]} - 1 ))
+ (( p = ${#BASH_ARGV[@]} ))
while (( n > 0 )) ; do
[ "${FUNCNAME[${n}]}" == "qa_call" ] && break
+ (( p -= ${BASH_ARGC[${n}]} ))
(( n-- ))
done
- (( n == 0 )) && (( n = ${#FUNCNAME[@]} - 1 ))
+ if (( n == 0 )) ; then
+ (( n = ${#FUNCNAME[@]} - 1 ))
+ (( p = ${#BASH_ARGV[@]} ))
+ fi
eerror "Call stack:"
- for (( p = ${#BASH_ARGV[@]} ; n > ${strip} ; n-- )) ; do
+ while (( n > ${strip} )) ; do
funcname=${FUNCNAME[${n} - 1]}
sourcefile=$(basename ${BASH_SOURCE[${n}]})
lineno=${BASH_LINENO[${n} - 1]}
(( p -= ${BASH_ARGC[${n} - 1]} ))
fi
eerror " $(printf "%${filespacing}s" "${sourcefile}"), line $(printf "%${linespacing}s" "${lineno}"): Called ${funcname}${args:+ ${args}}"
+ (( n-- ))
done
}