<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Aug 24, 2015 at 3:32 PM, Christopher Larson <span dir="ltr"><<a href="mailto:kergoth@gmail.com" target="_blank">kergoth@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div id=":yi" class="" style="overflow:hidden">From: Christopher Larson <<a href="mailto:chris_larson@mentor.com">chris_larson@mentor.com</a>><br>
<br>
Show the user only the portion of the traceback which was from the metadata,<br>
nothing from bitbake's internal calls.<br>
<br>
Signed-off-by: Christopher Larson <<a href="mailto:chris_larson@mentor.com">chris_larson@mentor.com</a>><br>
---<br>
lib/bb/cookerdata.py | 11 ++++++++++-<br>
1 file changed, 10 insertions(+), 1 deletion(-)<br>
<br>
diff --git a/lib/bb/cookerdata.py b/lib/bb/cookerdata.py<br>
index 57fc6bb..a033266 100644<br>
--- a/lib/bb/cookerdata.py<br>
+++ b/lib/bb/cookerdata.py<br>
@@ -179,7 +179,16 @@ def catch_parse_error(func):<br>
parselog.critical("Unable to parse %s: %s" % (fn, exc))<br>
sys.exit(1)<br>
except (bb.parse.ParseError, bb.data_smart.ExpansionError) as exc:<br>
- parselog.critical("Unable to parse %s: %s" % (fn, exc))<br>
+ import traceback<br>
+<br>
+ bbdir = os.path.dirname(__file__) + os.sep<br>
+ exc_class, exc, tb = sys.exc_info()<br>
+ for tb in iter(lambda: tb.tb_next, None):<br>
+ # Skip frames in bitbake itself, we only want the metadata<br>
+ fn, _, _, _ = traceback.extract_tb(tb, 1)[0]<br>
+ if not fn.startswith(bbdir):<br>
+ break<br>
+ parselog.critical("Unable to parse %s", fn, exc_info=(exc_class, exc, tb))<br>
sys.exit(1)<br>
return wrapped</div></blockquote></div><br><div><div><br></div><div>Before:</div><div><br></div><div>$ bitbake -p</div><div>ERROR: Unable to parse conf/bitbake.conf: Failure expanding variable FOO[:=], expression was ${@foo(d)} which triggered exception NameError: global name 'sys' is not defined</div><div><br></div><div>After:</div><div><br></div><div>$ bitbake -p</div><div>ERROR: Unable to parse FOO[:=]</div><div>Traceback (most recent call last):</div><div> File "FOO[:=]", line 1, in <module></div><div> File "test.inc", line 2, in foo(d=<bb.data_smart.DataSmart object at 0x99ff6cc>)</div><div> File "test.inc", line 2, in bar(d=<bb.data_smart.DataSmart object at 0x99ff6cc>)</div><div>ExpansionError: Failure expanding variable FOO[:=], expression was ${@foo(d)} which triggered exception NameError: global name 'sys' is not defined</div></div><div><br></div><div>There's still room for improvement, obviously. I'd like those filenames and line numbers to be correct absolute paths with correct adjusted line numbers and something other than <module> for the "function" of a :=, possibly, but it's a start.</div>-- <br><div class="gmail_signature"><div dir="ltr">Christopher Larson<br>kergoth at gmail dot com<br>Founder - BitBake, OpenEmbedded, OpenZaurus<br>Maintainer - Tslib<br>Senior Software Engineer, Mentor Graphics</div></div>
</div></div>