* [PATCH 1/2] data: emit filename/lineno information for shell functions
@ 2020-07-31 22:34 Chris Laplante
2020-07-31 22:34 ` [PATCH 2/2] build: report correct line number for failing Bash shell tasks Chris Laplante
0 siblings, 1 reply; 2+ messages in thread
From: Chris Laplante @ 2020-07-31 22:34 UTC (permalink / raw)
To: bitbake-devel; +Cc: Chris Laplante
Make it easier for users to debug shell task failure by including
some breadcrumbs in the emitted .run file that (hopefully) points
to the .bb/.bbclass file where the shell function was defined.
Unfortunately this won't work with functions with _append
or _prepends, since BitBake wipes the filename/lineno information.
This shouldn't be too hard to fix; for now, you'll just see
comments like this for such functions:
[YOCTO #7877]
Signed-off-by: Chris Laplante <chris.laplante@agilent.com>
---
lib/bb/data.py | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/lib/bb/data.py b/lib/bb/data.py
index b0683c51..d71e2fb4 100644
--- a/lib/bb/data.py
+++ b/lib/bb/data.py
@@ -161,6 +161,12 @@ def emit_var(var, o=sys.__stdout__, d = init(), all=False):
return True
if func:
+ # Write a comment indicating where the shell function came from (line number and filename) to make it easier
+ # for the user to diagnose task failures. This comment is also used by the shell trap that build.py generates
+ # so that shell tasks can report better line numbers in case of errors.
+ o.write("# line: {0}, file: {1}\n".format(
+ d.getVarFlag(var, "lineno", False),
+ d.getVarFlag(var, "filename", False)))
# NOTE: should probably check for unbalanced {} within the var
val = val.rstrip('\n')
o.write("%s() {\n%s\n}\n" % (varExpanded, val))
--
2.17.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [PATCH 2/2] build: report correct line number for failing Bash shell tasks
2020-07-31 22:34 [PATCH 1/2] data: emit filename/lineno information for shell functions Chris Laplante
@ 2020-07-31 22:34 ` Chris Laplante
0 siblings, 0 replies; 2+ messages in thread
From: Chris Laplante @ 2020-07-31 22:34 UTC (permalink / raw)
To: bitbake-devel; +Cc: Chris Laplante
For EXIT traps, ${BASH_LINENO[0]} gives the wrong line. We want
${BASH_LINENO[1]} here.
Before:
| install: cannot stat 'source': No such file or directory
| WARNING: /home/laplante/repos/oe-core/build/tmp-glibc/work/core2-64-oe-linux/libsolv/0.7.14-r0/temp/run.do_compile.101649:1 exit 1 from 'install -m 0644 source dest'
After:
| install: cannot stat 'source': No such file or directory
| WARNING: /home/laplante/repos/oe-core/build/tmp-glibc/work/core2-64-oe-linux/libsolv/0.7.14-r0/temp/run.do_compile.101649:115 exit 1 from 'install -m 0644 source dest'
Signed-off-by: Chris Laplante <chris.laplante@agilent.com>
---
lib/bb/build.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/bb/build.py b/lib/bb/build.py
index 977b02fc..6ad20ce7 100644
--- a/lib/bb/build.py
+++ b/lib/bb/build.py
@@ -310,7 +310,7 @@ bb_exit_handler() {
0) ;;
*) case $BASH_VERSION in
"") echo "WARNING: exit code $ret from a shell command.";;
- *) echo "WARNING: ${BASH_SOURCE[0]}:${BASH_LINENO[0]} exit $ret from '$BASH_COMMAND'";;
+ *) echo "WARNING: ${BASH_SOURCE[0]}:${BASH_LINENO[1]} exit $ret from '$BASH_COMMAND'";;
esac
exit $ret
esac
--
2.17.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-07-31 22:34 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-31 22:34 [PATCH 1/2] data: emit filename/lineno information for shell functions Chris Laplante
2020-07-31 22:34 ` [PATCH 2/2] build: report correct line number for failing Bash shell tasks Chris Laplante
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.