[bitbake-devel,3/3] WIP
Details
Commit Message
@@ -315,24 +315,30 @@ bb_sh_exit_handler() {
bb_bash_err_handler() {
ret=$?
echo "WARNING: ${BASH_SOURCE[0]}:${BASH_LINENO[0]} exit $ret from '$BASH_COMMAND'"
-
- # Determine the line on which the failing shell function is declared
- shopt -s extdebug
- function_line=$(declare -F "${FUNCNAME[1]}" | awk '{print $2}')
- shopt -u extdebug
-
- # Grab the special comment that precedes the function declaration - this comment contains the filename and lineno
- # that BitBake tracked as being the original location for the emitted shell function.
- prev_line=$((function_line - 1))
- function_location=$(sed "${prev_line}q;d" "${BASH_SOURCE[0]}")
- pattern='# line: ([[:digit:]]+), file: (.+)'
- if [[ $function_location =~ $pattern ]]; then
- relative_line=$((BASH_LINENO[0] - function_line))
- # TODO: handle 'autogenerated' (e.g. from _append) by walking up the call chain to the nearest real file?
- # TODO: actually just fix BitBake to include filename/lineno information when _append is encountered, maybe as
- # separate varflags.
- echo "INFO: ${BASH_REMATCH[2]}:$((BASH_REMATCH[1] + relative_line)) is where original shell function '${FUNCNAME[1]}' is declared"
- fi
+
+ frame=1
+ while [ $frame -lt 6 ]; do
+ # Determine the line on which the failing shell function is declared
+ shopt -s extdebug
+ function_line=$(declare -F "${FUNCNAME[$frame]}" | awk '{print $2}')
+ echo ${FUNCNAME[$frame]}
+ shopt -u extdebug
+ frame=$((frame + 1))
+ continue
+
+ # Grab the special comment that precedes the function declaration - this comment contains the filename and lineno
+ # that BitBake tracked as being the original location for the emitted shell function.
+ prev_line=$((function_line - 1))
+ function_location=$(sed "${prev_line}q;d" "${BASH_SOURCE[0]}")
+ pattern='# line: ([[:digit:]]+), file: (.+)'
+ if [[ $function_location =~ $pattern ]]; then
+ relative_line=$((BASH_LINENO[0] - function_line))
+ # TODO: handle 'autogenerated' (e.g. from _append) by walking up the call chain to the nearest real file?
+ # TODO: actually just fix BitBake to include filename/lineno information when _append is encountered, maybe as
+ # separate varflags.
+ echo "INFO: ${BASH_REMATCH[2]}:$((BASH_REMATCH[1] + relative_line)) is where original shell function '${FUNCNAME[1]}' is declared"
+ fi
+ done
exit $ret
}