summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2007-09-26 23:49:01 +0000
committerMike Frysinger <vapier@gentoo.org>2007-09-26 23:49:01 +0000
commited719bfde96824a823b52f4ee8f8d0f1e42359a3 (patch)
tree1de58e3f6430459056e98c8c3e8845cdbd6356f0
parente48f0bc2010c028461647bb50a53632852a5508e (diff)
downloadportage-ed719bfde96824a823b52f4ee8f8d0f1e42359a3.tar.gz
portage-ed719bfde96824a823b52f4ee8f8d0f1e42359a3.tar.bz2
portage-ed719bfde96824a823b52f4ee8f8d0f1e42359a3.zip
align the filename and line numbers in the output of the stack dump so that it is much easier to read
svn path=/main/trunk/; revision=7842
-rwxr-xr-xbin/isolated-functions.sh34
1 files changed, 21 insertions, 13 deletions
diff --git a/bin/isolated-functions.sh b/bin/isolated-functions.sh
index 6ef635642..5fbaae15c 100755
--- a/bin/isolated-functions.sh
+++ b/bin/isolated-functions.sh
@@ -12,19 +12,16 @@ alias restore_IFS='if [ "${old_IFS:-unset}" != "unset" ]; then IFS="${old_IFS}";
shopt -s extdebug
-# usage- first arg is the number of funcs on the stack to ignore.
-# defaults to 1 (ignoring dump_trace)
+# dump_trace([number of funcs on stack to skip],
+# [whitespacing for filenames],
+# [whitespacing for line numbers])
dump_trace() {
local funcname="" sourcefile="" lineno="" n e s="yes"
-
- declare -i strip=1
-
- if [[ -n $1 ]]; then
- strip=$(( $1 ))
- fi
+ declare -i strip=${1:-1}
+ local filespacing=$2 linespacing=$3
eerror "Call stack:"
- for (( n = ${#FUNCNAME[@]} - 1, p = ${#BASH_ARGV[@]} ; n > $strip ; n-- )) ; do
+ 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]}
@@ -37,19 +34,30 @@ dump_trace() {
done
(( p -= ${BASH_ARGC[${n} - 1]} ))
fi
- eerror " ${sourcefile}, line ${lineno}: Called ${funcname}${args:+ ${args}}"
+ eerror " $(printf "%${filespacing}s" "${sourcefile}"), line $(printf "%${linespacing}s" "${lineno}"): Called ${funcname}${args:+ ${args}}"
done
}
diefunc() {
local funcname="$1" lineno="$2" exitcode="$3"
shift 3
+
+ local n filespacing=0 linespacing=0
+ # setup spacing to make output easier to read
+ for ((n = ${#FUNCNAME[@]} - 1; n >= 0; --n)); do
+ sourcefile=${BASH_SOURCE[${n}]} sourcefile=${sourcefile##*/}
+ lineno=${BASH_LINENO[${n}]}
+ ((filespacing < ${#sourcefile})) && filespacing=${#sourcefile}
+ ((linespacing < ${#lineno})) && linespacing=${#lineno}
+ done
+
eerror
eerror "ERROR: $CATEGORY/$PF failed."
- dump_trace 2
- eerror " ${BASH_SOURCE[1]##*/}, line ${BASH_LINENO[0]}: Called die"
+ dump_trace 2 ${filespacing} ${linespacing}
+ eerror " $(printf "%${filespacing}s" "${BASH_SOURCE[1]##*/}"), line $(printf "%${linespacing}s" "${BASH_LINENO[0]}"): Called die"
+ eerror
+ eerror " ${*:-(no error message)}"
eerror
- eerror "${*:-(no error message)}"
eerror "If you need support, post the topmost build error, and the call stack if relevant."
[[ -n ${PORTAGE_LOG_FILE} ]] \
&& eerror "A complete build log is located at '${PORTAGE_LOG_FILE}'."