summaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
authorRichard Purdie <rpurdie@linux.intel.com>2010-12-05 22:52:44 +0000
committerRichard Purdie <rpurdie@linux.intel.com>2010-12-05 22:52:44 +0000
commita0033b622eef8ec2135b81e702719795b9f66b74 (patch)
treeb8cbb9e451a6763bf157171abe88da6739813f33 /bitbake
parent1a0c39e05067aa1b3c70de08380b8032227bf690 (diff)
downloadpoky-a0033b622eef8ec2135b81e702719795b9f66b74.tar.gz
bitbake/utils.py: Improve traceback to be more helpful/clear to users
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
Diffstat (limited to 'bitbake')
-rw-r--r--bitbake/lib/bb/utils.py30
1 files changed, 23 insertions, 7 deletions
diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py
index ed28f86c4b..5419af6246 100644
--- a/bitbake/lib/bb/utils.py
+++ b/bitbake/lib/bb/utils.py
@@ -350,22 +350,38 @@ def better_exec(code, context, text, realfile):
350 raise 350 raise
351 351
352 # print the Header of the Error Message 352 # print the Header of the Error Message
353 bb.msg.error(bb.msg.domain.Util, "Error in executing python function in: %s" % realfile) 353 bb.msg.error(bb.msg.domain.Util, "There was an error when executing a python function in: %s" % realfile)
354 bb.msg.error(bb.msg.domain.Util, "Exception:%s Message:%s" % (t, value)) 354 bb.msg.error(bb.msg.domain.Util, "Exception:%s Message:%s" % (t, value))
355 355
356 # Strip 'us' from the stack (better_exec call) 356 # Strip 'us' from the stack (better_exec call)
357 tb = tb.tb_next 357 tb = tb.tb_next
358 358
359 import traceback 359 import traceback
360 textarray = text.split('\n')
361 linefailed = traceback.tb_lineno(tb)
362
360 tbextract = traceback.extract_tb(tb) 363 tbextract = traceback.extract_tb(tb)
361 tbextract = "\n".join(traceback.format_list(tbextract)) 364 tbformat = "\n".join(traceback.format_list(tbextract))
362 bb.msg.error(bb.msg.domain.Util, "Traceback:") 365 bb.msg.error(bb.msg.domain.Util, "The stack trace of python calls that resulted in thie exception/failure was:")
363 for line in tbextract.split('\n'): 366 for line in tbformat.split('\n'):
364 bb.msg.error(bb.msg.domain.Util, line) 367 bb.msg.error(bb.msg.domain.Util, line)
365 368
366 line = traceback.tb_lineno(tb) 369 bb.msg.error(bb.msg.domain.Util, "The code that was being executed was:")
367 bb.msg.error(bb.msg.domain.Util, "The lines leading to this error were:") 370 _print_trace(textarray, linefailed)
368 _print_trace( text.split('\n'), line ) 371 bb.msg.error(bb.msg.domain.Util, "(file: '%s', lineno: %s, function: %s)" % (tbextract[0][0], tbextract[0][1], tbextract[0][2]))
372
373 # See if this is a function we constructed and has calls back into other functions in
374 # "text". If so, try and improve the context of the error by diving down the trace
375 level = 0
376 nexttb = tb.tb_next
377 while nexttb is not None:
378 if tbextract[level][0] == tbextract[level+1][0] and tbextract[level+1][2] == tbextract[level][0]:
379 _print_trace(textarray, tbextract[level+1][1])
380 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]))
381 else:
382 break
383 nexttb = tb.tb_next
384 level = level + 1
369 385
370 raise 386 raise
371 387