<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">&lt;<a href="mailto:kergoth@gmail.com" target="_blank">kergoth@gmail.com</a>&gt;</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 &lt;<a href="mailto:chris_larson@mentor.com">chris_larson@mentor.com</a>&gt;<br>
<br>
Show the user only the portion of the traceback which was from the metadata,<br>
nothing from bitbake&#39;s internal calls.<br>
<br>
Signed-off-by: Christopher Larson &lt;<a href="mailto:chris_larson@mentor.com">chris_larson@mentor.com</a>&gt;<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(&quot;Unable to parse %s: %s&quot; % (fn, exc))<br>
             sys.exit(1)<br>
         except (bb.parse.ParseError, bb.data_smart.ExpansionError) as exc:<br>
-            parselog.critical(&quot;Unable to parse %s: %s&quot; % (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(&quot;Unable to parse %s&quot;, 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 &#39;sys&#39; 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 &quot;FOO[:=]&quot;, line 1, in &lt;module&gt;</div><div>  File &quot;test.inc&quot;, line 2, in foo(d=&lt;bb.data_smart.DataSmart object at 0x99ff6cc&gt;)</div><div>  File &quot;test.inc&quot;, line 2, in bar(d=&lt;bb.data_smart.DataSmart object at 0x99ff6cc&gt;)</div><div>ExpansionError: Failure expanding variable FOO[:=], expression was ${@foo(d)} which triggered exception NameError: global name &#39;sys&#39; is not defined</div></div><div><br></div><div>There&#39;s still room for improvement, obviously. I&#39;d like those filenames and line numbers to be correct absolute paths with correct adjusted line numbers and something other than &lt;module&gt; for the &quot;function&quot; of a :=, possibly, but it&#39;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>