diff options
author | Yann E. MORIN" <yann.morin.1998@anciens.enib.fr> | 2011-04-08 00:08:57 +0200 |
---|---|---|
committer | Yann E. MORIN" <yann.morin.1998@anciens.enib.fr> | 2011-04-08 00:08:57 +0200 |
commit | 81862cd306875775ed7961657a3bcae4a0b458e7 (patch) | |
tree | de7a29ca382b87c9f8f49b8ea681a1e2cccb3f81 /scripts/functions | |
parent | 43850b301c4e8b22d7303d60c101d359c6b44932 (diff) | |
download | crosstool-ng-81862cd306875775ed7961657a3bcae4a0b458e7.tar.gz crosstool-ng-81862cd306875775ed7961657a3bcae4a0b458e7.tar.bz2 crosstool-ng-81862cd306875775ed7961657a3bcae4a0b458e7.zip |
functions: pretty print error messages
Reformat the error messages:
- strip ${CT_LIB_DIR} from scripts path names
- strip ${CT_TOP_DIR} from build.log path and docs path
- overall shorter lines
- point to the known-issues file
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Diffstat (limited to 'scripts/functions')
-rw-r--r-- | scripts/functions | 52 |
1 files changed, 43 insertions, 9 deletions
diff --git a/scripts/functions b/scripts/functions index 3261a800..94bca81a 100644 --- a/scripts/functions +++ b/scripts/functions @@ -4,19 +4,53 @@ # Prepare the fault handler CT_OnError() { - ret=$? + local ret=$? + local intro + local file + local line + local func + local step_depth + # Bail out early in subshell, the upper level shell will act accordingly. [ ${BASH_SUBSHELL} -eq 0 ] || exit $ret - CT_DoLog ERROR "Build failed in step '${CT_STEP_MESSAGE[${CT_STEP_COUNT}]}'" - for((step=(CT_STEP_COUNT-1); step>1; step--)); do - CT_DoLog ERROR " called in step '${CT_STEP_MESSAGE[${step}]}'" + + # Print steps backtrace + step_depth=${CT_STEP_COUNT} + CT_STEP_COUNT=2 + CT_DoLog ERROR "" + intro="Build failed" + for((step=step_depth; step>1; step--)); do + CT_DoLog ERROR ">> ${intro} in step '${CT_STEP_MESSAGE[${step}]}'" + intro=" called" done - CT_DoLog ERROR "Error happened in '${BASH_SOURCE[1]}' in function '${FUNCNAME[1]}' (line unknown, sorry)" - for((depth=2; ${BASH_LINENO[$((${depth}-1))]}>0; depth++)); do - CT_DoLog ERROR " called from '${BASH_SOURCE[${depth}]}' at line # ${BASH_LINENO[${depth}-1]} in function '${FUNCNAME[${depth}]}'" + + # Print functions backtrace + intro="Error happened in" + offset=1 + CT_DoLog ERROR ">>" + for((depth=1; ${BASH_LINENO[$((${depth}-1))]}>0; depth++)); do + file="${BASH_SOURCE[${depth}]#${CT_LIB_DIR}/}" + case "${depth}" in + 1) line="";; + *) line="@${BASH_LINENO[${depth}-1]}" + esac + func="${FUNCNAME[${depth}]}" + CT_DoLog ERROR ">> ${intro}: ${func}[${file}${line}]" + intro=" called from" done - [ "${CT_LOG_TO_FILE}" = "y" ] && CT_DoLog ERROR "Look at '${tmp_log_file}' for more info on this error." - CT_STEP_COUNT=1 + + # Help diagnose the error + CT_DoLog ERROR ">>" + if [ "${CT_LOG_TO_FILE}" = "y" ]; then + CT_DoLog ERROR ">> For more info on this error, look at the file: '${tmp_log_file#${CT_TOP_DIR}/}'" + fi + CT_DoLog ERROR ">> There is a list of known issues, some with workarounds, in:" + CT_DoLog ERROR ">> '${CT_DOC_DIR#${CT_TOP_DIR}/}/B - Known issues.txt'" + + CT_DoLog ERROR "" + CT_DoLog ERROR "Build failed in step '${CT_STEP_MESSAGE[${CT_STEP_COUNT}]}'" + + CT_DoLog ERROR "" CT_DoEnd ERROR exit $ret } |