mirror of
https://git.yoctoproject.org/poky
synced 2026-09-29 07:36:20 +02:00
bitbake/utils.py: Improve traceback to be more helpful/clear to users
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
This commit is contained in:
@@ -350,22 +350,38 @@ def better_exec(code, context, text, realfile):
|
|||||||
raise
|
raise
|
||||||
|
|
||||||
# print the Header of the Error Message
|
# print the Header of the Error Message
|
||||||
bb.msg.error(bb.msg.domain.Util, "Error in executing python function in: %s" % realfile)
|
bb.msg.error(bb.msg.domain.Util, "There was an error when executing a python function in: %s" % realfile)
|
||||||
bb.msg.error(bb.msg.domain.Util, "Exception:%s Message:%s" % (t, value))
|
bb.msg.error(bb.msg.domain.Util, "Exception:%s Message:%s" % (t, value))
|
||||||
|
|
||||||
# Strip 'us' from the stack (better_exec call)
|
# Strip 'us' from the stack (better_exec call)
|
||||||
tb = tb.tb_next
|
tb = tb.tb_next
|
||||||
|
|
||||||
import traceback
|
import traceback
|
||||||
|
textarray = text.split('\n')
|
||||||
|
linefailed = traceback.tb_lineno(tb)
|
||||||
|
|
||||||
tbextract = traceback.extract_tb(tb)
|
tbextract = traceback.extract_tb(tb)
|
||||||
tbextract = "\n".join(traceback.format_list(tbextract))
|
tbformat = "\n".join(traceback.format_list(tbextract))
|
||||||
bb.msg.error(bb.msg.domain.Util, "Traceback:")
|
bb.msg.error(bb.msg.domain.Util, "The stack trace of python calls that resulted in thie exception/failure was:")
|
||||||
for line in tbextract.split('\n'):
|
for line in tbformat.split('\n'):
|
||||||
bb.msg.error(bb.msg.domain.Util, line)
|
bb.msg.error(bb.msg.domain.Util, line)
|
||||||
|
|
||||||
line = traceback.tb_lineno(tb)
|
bb.msg.error(bb.msg.domain.Util, "The code that was being executed was:")
|
||||||
bb.msg.error(bb.msg.domain.Util, "The lines leading to this error were:")
|
_print_trace(textarray, linefailed)
|
||||||
_print_trace( text.split('\n'), line )
|
bb.msg.error(bb.msg.domain.Util, "(file: '%s', lineno: %s, function: %s)" % (tbextract[0][0], tbextract[0][1], tbextract[0][2]))
|
||||||
|
|
||||||
|
# See if this is a function we constructed and has calls back into other functions in
|
||||||
|
# "text". If so, try and improve the context of the error by diving down the trace
|
||||||
|
level = 0
|
||||||
|
nexttb = tb.tb_next
|
||||||
|
while nexttb is not None:
|
||||||
|
if tbextract[level][0] == tbextract[level+1][0] and tbextract[level+1][2] == tbextract[level][0]:
|
||||||
|
_print_trace(textarray, tbextract[level+1][1])
|
||||||
|
bb.msg.error(bb.msg.domain.Util, "(file: '%s', lineno: %s, function: %s)" % (tbextract[level+1][0], tbextract[level+1][1], tbextract[level+1][2]))
|
||||||
|
else:
|
||||||
|
break
|
||||||
|
nexttb = tb.tb_next
|
||||||
|
level = level + 1
|
||||||
|
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user