diff options
Diffstat (limited to 'bitbake/lib/bb/cooker.py')
| -rw-r--r-- | bitbake/lib/bb/cooker.py | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py index a8e0a81dc9..ca37cfea95 100644 --- a/bitbake/lib/bb/cooker.py +++ b/bitbake/lib/bb/cooker.py | |||
| @@ -17,7 +17,7 @@ import threading | |||
| 17 | from io import StringIO, UnsupportedOperation | 17 | from io import StringIO, UnsupportedOperation |
| 18 | from contextlib import closing | 18 | from contextlib import closing |
| 19 | from collections import defaultdict, namedtuple | 19 | from collections import defaultdict, namedtuple |
| 20 | import bb, bb.exceptions, bb.command | 20 | import bb, bb.command |
| 21 | from bb import utils, data, parse, event, cache, providers, taskdata, runqueue, build | 21 | from bb import utils, data, parse, event, cache, providers, taskdata, runqueue, build |
| 22 | import queue | 22 | import queue |
| 23 | import signal | 23 | import signal |
| @@ -2096,7 +2096,6 @@ class Parser(multiprocessing.Process): | |||
| 2096 | except Exception as exc: | 2096 | except Exception as exc: |
| 2097 | tb = sys.exc_info()[2] | 2097 | tb = sys.exc_info()[2] |
| 2098 | exc.recipe = filename | 2098 | exc.recipe = filename |
| 2099 | exc.traceback = list(bb.exceptions.extract_traceback(tb, context=3)) | ||
| 2100 | return True, None, exc | 2099 | return True, None, exc |
| 2101 | # Need to turn BaseExceptions into Exceptions here so we gracefully shutdown | 2100 | # Need to turn BaseExceptions into Exceptions here so we gracefully shutdown |
| 2102 | # and for example a worker thread doesn't just exit on its own in response to | 2101 | # and for example a worker thread doesn't just exit on its own in response to |
| @@ -2297,8 +2296,12 @@ class CookerParser(object): | |||
| 2297 | return False | 2296 | return False |
| 2298 | except ParsingFailure as exc: | 2297 | except ParsingFailure as exc: |
| 2299 | self.error += 1 | 2298 | self.error += 1 |
| 2300 | logger.error('Unable to parse %s: %s' % | 2299 | |
| 2301 | (exc.recipe, bb.exceptions.to_string(exc.realexception))) | 2300 | exc_desc = str(exc) |
| 2301 | if isinstance(exc, SystemExit) and not isinstance(exc.code, str): | ||
| 2302 | exc_desc = 'Exited with "%d"' % exc.code | ||
| 2303 | |||
| 2304 | logger.error('Unable to parse %s: %s' % (exc.recipe, exc_desc)) | ||
| 2302 | self.shutdown(clean=False) | 2305 | self.shutdown(clean=False) |
| 2303 | return False | 2306 | return False |
| 2304 | except bb.parse.ParseError as exc: | 2307 | except bb.parse.ParseError as exc: |
| @@ -2307,20 +2310,33 @@ class CookerParser(object): | |||
| 2307 | self.shutdown(clean=False, eventmsg=str(exc)) | 2310 | self.shutdown(clean=False, eventmsg=str(exc)) |
| 2308 | return False | 2311 | return False |
| 2309 | except bb.data_smart.ExpansionError as exc: | 2312 | except bb.data_smart.ExpansionError as exc: |
| 2313 | def skip_frames(f, fn_prefix): | ||
| 2314 | while f and f.tb_frame.f_code.co_filename.startswith(fn_prefix): | ||
| 2315 | f = f.tb_next | ||
| 2316 | return f | ||
| 2317 | |||
| 2310 | self.error += 1 | 2318 | self.error += 1 |
| 2311 | bbdir = os.path.dirname(__file__) + os.sep | 2319 | bbdir = os.path.dirname(__file__) + os.sep |
| 2312 | etype, value, _ = sys.exc_info() | 2320 | etype, value, tb = sys.exc_info() |
| 2313 | tb = list(itertools.dropwhile(lambda e: e.filename.startswith(bbdir), exc.traceback)) | 2321 | |
| 2322 | # Remove any frames where the code comes from bitbake. This | ||
| 2323 | # prevents deep (and pretty useless) backtraces for expansion error | ||
| 2324 | tb = skip_frames(tb, bbdir) | ||
| 2325 | cur = tb | ||
| 2326 | while cur: | ||
| 2327 | cur.tb_next = skip_frames(cur.tb_next, bbdir) | ||
| 2328 | cur = cur.tb_next | ||
| 2329 | |||
| 2314 | logger.error('ExpansionError during parsing %s', value.recipe, | 2330 | logger.error('ExpansionError during parsing %s', value.recipe, |
| 2315 | exc_info=(etype, value, tb)) | 2331 | exc_info=(etype, value, tb)) |
| 2316 | self.shutdown(clean=False) | 2332 | self.shutdown(clean=False) |
| 2317 | return False | 2333 | return False |
| 2318 | except Exception as exc: | 2334 | except Exception as exc: |
| 2319 | self.error += 1 | 2335 | self.error += 1 |
| 2320 | etype, value, tb = sys.exc_info() | 2336 | _, value, _ = sys.exc_info() |
| 2321 | if hasattr(value, "recipe"): | 2337 | if hasattr(value, "recipe"): |
| 2322 | logger.error('Unable to parse %s' % value.recipe, | 2338 | logger.error('Unable to parse %s' % value.recipe, |
| 2323 | exc_info=(etype, value, exc.traceback)) | 2339 | exc_info=sys.exc_info()) |
| 2324 | else: | 2340 | else: |
| 2325 | # Most likely, an exception occurred during raising an exception | 2341 | # Most likely, an exception occurred during raising an exception |
| 2326 | import traceback | 2342 | import traceback |
