diff options
author | Brian Harring <ferringb@gentoo.org> | 2006-01-23 10:58:16 +0000 |
---|---|---|
committer | Brian Harring <ferringb@gentoo.org> | 2006-01-23 10:58:16 +0000 |
commit | 1173699ee506de28463c11668d688679381b2128 (patch) | |
tree | eeb1b957d770675b21ef82e0a5547f6adb000893 | |
parent | 1838327ba2c4f0da99fbfda8c3b01420022f4d1a (diff) | |
download | portage-1173699ee506de28463c11668d688679381b2128.tar.gz portage-1173699ee506de28463c11668d688679381b2128.tar.bz2 portage-1173699ee506de28463c11668d688679381b2128.zip |
fixed up dump_trace, courtesy of spyderous
svn path=/main/trunk/; revision=2575
-rwxr-xr-x | bin/ebuild.sh | 39 |
1 files changed, 27 insertions, 12 deletions
diff --git a/bin/ebuild.sh b/bin/ebuild.sh index 467e796db..022b5df39 100755 --- a/bin/ebuild.sh +++ b/bin/ebuild.sh @@ -273,6 +273,7 @@ diefunc() { echo >&2 echo "!!! ERROR: $CATEGORY/$PF failed." >&2 dump_trace 2 1>&2 + echo >&2 echo "!!! ${*:-(no error message)}" >&2 echo "!!! If you need support, post the topmost build error, and the call stack if relevant." >&2 echo >&2 @@ -284,25 +285,39 @@ diefunc() { exit 1 } +shopt -s extdebug + +# usage- first arg is the number of funcs on the stack to ignore. +# defaults to 1 (ignoring dump_trace) dump_trace() { - # usage- first arg is the number of funcs on the stack to ignore. - # defaults to 1 (ignoring dump_trace) - # pulled from eselect. - local skip funcname sourcefile lineno + local funcname="" sourcefile="" lineno="" n e s="yes" + + declare -i strip=1 + if [[ -n $1 ]]; then - declare -i skip=$1 - else - skip=1 + strip=$(( $1 )) fi + echo "Call stack:" - for (( n = $skip ; n < ${#FUNCNAME[@]} ; ++n )) ; do - funcname=${FUNCNAME[${n}]} - sourcefile=$(basename ${BASH_SOURCE[$(( n - 1 ))]}) - lineno=${BASH_LINENO[$(( n - 1 ))]} - echo " File ${sourcefile}, line ${lineno}, in ${funcname}" + for (( n = ${#FUNCNAME[@]} - 1, p = ${#BASH_ARGV[@]} ; n > $strip ; n-- )) ; do + funcname=${FUNCNAME[${n} - 1]} + sourcefile=$(basename ${BASH_SOURCE[${n}]}) + lineno=${BASH_LINENO[${n} - 1]} + # Display function arguments + args= + if [[ -n "${BASH_ARGV[@]}" ]]; then + for (( j = 0 ; j < ${BASH_ARGC[${n} - 1]} ; ++j )); do + newarg=${BASH_ARGV[$(( p - j - 1 ))]} + args="${args:+${args} }'${newarg}'" + done + (( p -= ${BASH_ARGC[${n} - 1]} )) + fi + echo " ${sourcefile}, line ${lineno}: Called ${funcname}${args:+ ${args}}" done } + + #if no perms are specified, dirs/files will have decent defaults #(not secretive, but not stupid) umask 022 |