From 783001ec079bac46e51ab2ce7969d117f8af05fc Mon Sep 17 00:00:00 2001 From: Alec Warner Date: Thu, 8 Feb 2007 04:38:21 +0000 Subject: [PATCH] die requires diefunc and dump_trace too; duh; also move extdebug into isolated-functions.sh svn path=/main/trunk/; revision=5930 --- bin/ebuild.sh | 66 --------------------------------------- bin/isolated-functions.sh | 31 ++++++++++++++++++ 2 files changed, 31 insertions(+), 66 deletions(-) diff --git a/bin/ebuild.sh b/bin/ebuild.sh index db8193ae2..6004242ea 100755 --- a/bin/ebuild.sh +++ b/bin/ebuild.sh @@ -265,72 +265,6 @@ register_die_hook() { export EBUILD_DEATH_HOOKS="${EBUILD_DEATH_HOOKS} $*" } -diefunc() { - local funcname="$1" lineno="$2" exitcode="$3" - shift 3 - echo >&2 - echo "!!! ERROR: $CATEGORY/$PF failed." >&2 - dump_trace 2 1>&2 - echo " $(basename "${BASH_SOURCE[1]}"), line ${BASH_LINENO[0]}: Called die" 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 "!!! A complete build log is located at '${PORTAGE_LOG_FILE}'." >&2 - echo >&2 - if [ -n "${EBUILD_OVERLAY_ECLASSES}" ] ; then - echo "This ebuild used the following eclasses from overlays:" >&2 - echo >&2 - for x in ${EBUILD_OVERLAY_ECLASSES} ; do - echo " ${x}" >&2 - done - echo >&2 - fi - - if [ "${EBUILD_PHASE/depend}" == "${EBUILD_PHASE}" ]; then - local x - for x in $EBUILD_DEATH_HOOKS; do - ${x} "$@" >&2 1>&2 - done - fi - - # subshell die support - kill -s SIGTERM ${EBUILD_MASTER_PID} - exit 1 -} - -shopt -s extdebug &> /dev/null - -# usage- first arg is the number of funcs on the stack to ignore. -# defaults to 1 (ignoring dump_trace) -dump_trace() { - local funcname="" sourcefile="" lineno="" n e s="yes" - - declare -i strip=1 - - if [[ -n $1 ]]; then - strip=$(( $1 )) - fi - - echo "Call stack:" - 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 = 1 ; 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 diff --git a/bin/isolated-functions.sh b/bin/isolated-functions.sh index d9fafbcb6..41595ea30 100755 --- a/bin/isolated-functions.sh +++ b/bin/isolated-functions.sh @@ -10,6 +10,37 @@ alias assert='_pipestatus="${PIPESTATUS[*]}"; [[ "${_pipestatus// /}" -eq 0 ]] | alias save_IFS='[ "${IFS:-unset}" != "unset" ] && old_IFS="${IFS}"' alias restore_IFS='if [ "${old_IFS:-unset}" != "unset" ]; then IFS="${old_IFS}"; unset old_IFS; else unset IFS; fi' +shopt -s extdebug + +# usage- first arg is the number of funcs on the stack to ignore. +# defaults to 1 (ignoring dump_trace) +dump_trace() { + local funcname="" sourcefile="" lineno="" n e s="yes" + + declare -i strip=1 + + if [[ -n $1 ]]; then + strip=$(( $1 )) + fi + + echo "Call stack:" + 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 = 1 ; 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 +} + diefunc() { local funcname="$1" lineno="$2" exitcode="$3" shift 3 -- 2.26.2