[bitbake-devel,3/3] WIP

Submitted by Chris Laplante via lists.openembedded.org on Aug. 7, 2020, 2:23 p.m. | Patch ID: 175133

Details

Message ID 20200807142343.8648-4-chris.laplante@agilent.com
State New
Headers show

Commit Message

---
 lib/bb/build.py | 42 ++++++++++++++++++++++++------------------
 1 file changed, 24 insertions(+), 18 deletions(-)

Patch hide | download patch | download mbox

diff --git a/lib/bb/build.py b/lib/bb/build.py
index bbea20c6..c424519d 100644
--- a/lib/bb/build.py
+++ b/lib/bb/build.py
@@ -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
 }