diff options
| author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2012-08-22 20:01:12 +0100 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2012-08-23 09:22:42 +0100 |
| commit | 64c002875fe0a153760f174b868dc702227c00af (patch) | |
| tree | a6d2335ee39d48113f62470bdd0f73213c32868a /bitbake/lib | |
| parent | fddc16989ddb181800eb6ec383b431e00d79f286 (diff) | |
| download | poky-64c002875fe0a153760f174b868dc702227c00af.tar.gz | |
bitbake: utils.py: Try harder to extract good traceback information by querying the datastore
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]
(Bitbake rev: 0edf8431f9ff52581afe0d3ef525c59909af02ba)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib')
| -rw-r--r-- | bitbake/lib/bb/utils.py | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py index 44a42a0136..e0ef63cd03 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"): | |||
| 218 | 218 | ||
| 219 | raise | 219 | raise |
| 220 | 220 | ||
| 221 | def better_exec(code, context, text = None, realfile = "<code>", data = None): | 221 | def better_exec(code, context, text = None, realfile = "<code>"): |
| 222 | """ | 222 | """ |
| 223 | Similiar to better_compile, better_exec will | 223 | Similiar to better_compile, better_exec will |
| 224 | print the lines that are responsible for the | 224 | print the lines that are responsible for the |
| @@ -256,16 +256,25 @@ def better_exec(code, context, text = None, realfile = "<code>", data = None): | |||
| 256 | 256 | ||
| 257 | logger.error("The code that was being executed was:") | 257 | logger.error("The code that was being executed was:") |
| 258 | _print_trace(textarray, linefailed) | 258 | _print_trace(textarray, linefailed) |
| 259 | logger.error("(file: '%s', lineno: %s, function: %s)", tbextract[0][0], tbextract[0][1], tbextract[0][2]) | 259 | logger.error("[From file: '%s', lineno: %s, function: %s]", tbextract[0][0], tbextract[0][1], tbextract[0][2]) |
| 260 | 260 | ||
| 261 | # See if this is a function we constructed and has calls back into other functions in | 261 | # See if this is a function we constructed and has calls back into other functions in |
| 262 | # "text". If so, try and improve the context of the error by diving down the trace | 262 | # "text". If so, try and improve the context of the error by diving down the trace |
| 263 | level = 0 | 263 | level = 0 |
| 264 | nexttb = tb.tb_next | 264 | nexttb = tb.tb_next |
| 265 | while nexttb is not None: | 265 | while nexttb is not None and (level+1) < len(tbextract): |
| 266 | if tbextract[level][0] == tbextract[level+1][0] and tbextract[level+1][2] == tbextract[level][0]: | 266 | if tbextract[level][0] == tbextract[level+1][0] and tbextract[level+1][2] == tbextract[level][0]: |
| 267 | _print_trace(textarray, tbextract[level+1][1]) | 267 | _print_trace(textarray, tbextract[level+1][1]) |
| 268 | logger.error("(file: '%s', lineno: %s, function: %s)", tbextract[level+1][0], tbextract[level+1][1], tbextract[level+1][2]) | 268 | logger.error("[From file: '%s', lineno: %s, function: %s]", tbextract[level+1][0], tbextract[level+1][1], tbextract[level+1][2]) |
| 269 | elif "d" in context and tbextract[level+1][2]: | ||
| 270 | d = context["d"] | ||
| 271 | functionname = tbextract[level+1][2] | ||
| 272 | text = d.getVar(functionname, True) | ||
| 273 | if text: | ||
| 274 | _print_trace(text.split('\n'), tbextract[level+1][1]) | ||
| 275 | logger.error("[From file: '%s', lineno: %s, function: %s]", tbextract[level+1][0], tbextract[level+1][1], tbextract[level+1][2]) | ||
| 276 | else: | ||
| 277 | break | ||
| 269 | else: | 278 | else: |
| 270 | break | 279 | break |
| 271 | nexttb = tb.tb_next | 280 | nexttb = tb.tb_next |
