Commit b539d234 authored by Oliver Horst's avatar Oliver Horst
Browse files

[add] toki-debug class to assist in debugging bitbake issues

parent da09ab6e
# This code is adapted from the Python Cookbook section "Getting More Information from Tracebacks" by Bryn Keller
# https://www.oreilly.com/library/view/python-cookbook/0596001673/ch14s05.html
def debug_yocto(d)
import inspect
import traceback
tb = traceback.extract_stack()
bb.warn('\n'.join(traceback.format_list(tb)))
bb.warn("Locals by frame, innermost last")
stack = inspect.stack()
for frameinfo in stack:
frame = frameinfo.frame
bb.warn("")
bb.warn("Frame %s in %s at line %s" % (frame.f_code.co_name,
frame.f_code.co_filename,
frame.f_lineno))
for key, value in frame.f_locals.items():
# We have to be VERY careful not to cause a new error in our error
# printer! Calling str() on an unknown object could cause an
# error we don't want, so we must use try/except to catch it --
# we can't stop it from happening, but we can and should
# stop it from propagating if it does happen!
try:
bb.warn("\t%20s = %s" % (key, str(value)))
except:
bb.warn("\t%20s = <ERROR WHILE PRINTING VALUE>" % key,)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment