From: Richard Purdie <richard.purdie@linuxfoundation.org>
To: bitbake-devel <bitbake-devel@lists.openembedded.org>
Subject: [PATCH] utils.py: Try harder to extract good traceback information by querying the datastore
Date: Wed, 22 Aug 2012 20:01:12 +0100 [thread overview]
Message-ID: <1345662072.3907.127.camel@ted> (raw)
Currently as soon as execution passes outside the code fragment being
executed by better_exec, we don't get any good traceback information,
just a likely obscure reference to some function name which may
or may not be identifiable.
This patch adds code to query the datastore if present, allowing a more
meaningful back trace to be displayed in many cases.
[YOCTO #2981]
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py
index 44a42a0..e0ef63c 100644
--- a/bitbake/lib/bb/utils.py
+++ b/bitbake/lib/bb/utils.py
@@ -218,7 +218,7 @@ def better_compile(text, file, realfile, mode = "exec"):
raise
-def better_exec(code, context, text = None, realfile = "<code>", data = None):
+def better_exec(code, context, text = None, realfile = "<code>"):
"""
Similiar to better_compile, better_exec will
print the lines that are responsible for the
@@ -256,16 +256,25 @@ def better_exec(code, context, text = None, realfile = "<code>", data = None):
logger.error("The code that was being executed was:")
_print_trace(textarray, linefailed)
- logger.error("(file: '%s', lineno: %s, function: %s)", tbextract[0][0], tbextract[0][1], tbextract[0][2])
+ logger.error("[From 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:
+ while nexttb is not None and (level+1) < len(tbextract):
if tbextract[level][0] == tbextract[level+1][0] and tbextract[level+1][2] == tbextract[level][0]:
_print_trace(textarray, tbextract[level+1][1])
- logger.error("(file: '%s', lineno: %s, function: %s)", tbextract[level+1][0], tbextract[level+1][1], tbextract[level+1][2])
+ logger.error("[From file: '%s', lineno: %s, function: %s]", tbextract[level+1][0], tbextract[level+1][1], tbextract[level+1][2])
+ elif "d" in context and tbextract[level+1][2]:
+ d = context["d"]
+ functionname = tbextract[level+1][2]
+ text = d.getVar(functionname, True)
+ if text:
+ _print_trace(text.split('\n'), tbextract[level+1][1])
+ logger.error("[From file: '%s', lineno: %s, function: %s]", tbextract[level+1][0], tbextract[level+1][1], tbextract[level+1][2])
+ else:
+ break
else:
break
nexttb = tb.tb_next
reply other threads:[~2012-08-22 19:13 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1345662072.3907.127.camel@ted \
--to=richard.purdie@linuxfoundation.org \
--cc=bitbake-devel@lists.openembedded.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.