diff options
author | Peter Seebach <peter.seebach@windriver.com> | 2013-01-18 11:47:34 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2013-01-18 12:35:19 +0000 |
commit | fe30cbc2cb0719092f19cba3b06a37e93260994c (patch) | |
tree | 715c87a0c77aa75255395b3e70796811ddce3859 /bitbake/lib/bb/parse | |
parent | 4dd6d9139cb77f2b0ff7ab9482e853108efad5aa (diff) | |
download | poky-fe30cbc2cb0719092f19cba3b06a37e93260994c.tar.gz |
bitbake: bitbake: data_smart.py and friends: Track variable history
This patch adds tracking of the history of variable assignments.
The changes are predominantly localized to data_smart.py and
parse/ast.py. cooker.py and data.py are altered to display the
recorded data, and turn tracking on for the bitbake -e case.
The data.py update_data() function warns DataSmart.finalize()
to report the caller one further back up the tree.
In general, d.setVar() does what it used to do. Optionally,
arguments describing an operation may be appended; if none
are present, the operation is implicitly ignored. If it's
not ignored, it will attempt to infer missing information
(name of variable, value assigned, file and line) by examining
the traceback. This slightly elaborate process eliminates a
category of problems in which the 'var' member of the keyword
arguments dict is set, and a positional argument corresponding
to 'var' is also set. It also makes calling much simpler for
the common cases.
The resulting output gives you a pretty good picture of what
values got set, and how they got set.
RP Modifications:
a) Split from IncludeHistory to separate VariableHistory
b) Add dedicated copy function instead of deepcopy
c) Use COW for variables dict
d) Remove 'value' loginfo value and just use 'details'
e) Desensitise code for calling order (set 'op' before/after
infer_caller_details was error prone)
f) Fix bug where ?= "" wasn't shown correctly
g) Log more set operations as some variables mysteriously acquired
values previously
h) Standardise infer_caller_details to be triggered from .record()
where at all possible to reduce overhead in non-enabled cases
i) Rename variable parameter names to match inference code
j) Add VariableHistory emit() function to match IncludeHistory
k) Fix handling of appendVar, prependVar and matching flag ops
l) Use ignored=True to stop logging further events where appropriate
(Bitbake rev: f00524a3729000cbcb3317fee933ac448fae5e2d)
Signed-off-by: Peter Seebach <peter.seebach@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/parse')
-rw-r--r-- | bitbake/lib/bb/parse/ast.py | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/bitbake/lib/bb/parse/ast.py b/bitbake/lib/bb/parse/ast.py index 79e9f7e170..b2657f8044 100644 --- a/bitbake/lib/bb/parse/ast.py +++ b/bitbake/lib/bb/parse/ast.py | |||
@@ -68,7 +68,7 @@ class ExportNode(AstNode): | |||
68 | self.var = var | 68 | self.var = var |
69 | 69 | ||
70 | def eval(self, data): | 70 | def eval(self, data): |
71 | data.setVarFlag(self.var, "export", 1) | 71 | data.setVarFlag(self.var, "export", 1, op = 'exported') |
72 | 72 | ||
73 | class DataNode(AstNode): | 73 | class DataNode(AstNode): |
74 | """ | 74 | """ |
@@ -90,33 +90,53 @@ class DataNode(AstNode): | |||
90 | def eval(self, data): | 90 | def eval(self, data): |
91 | groupd = self.groupd | 91 | groupd = self.groupd |
92 | key = groupd["var"] | 92 | key = groupd["var"] |
93 | loginfo = { | ||
94 | 'variable': key, | ||
95 | 'file': self.filename, | ||
96 | 'line': self.lineno, | ||
97 | } | ||
93 | if "exp" in groupd and groupd["exp"] != None: | 98 | if "exp" in groupd and groupd["exp"] != None: |
94 | data.setVarFlag(key, "export", 1) | 99 | data.setVarFlag(key, "export", 1, op = 'exported', **loginfo) |
100 | |||
101 | op = "set" | ||
95 | if "ques" in groupd and groupd["ques"] != None: | 102 | if "ques" in groupd and groupd["ques"] != None: |
96 | val = self.getFunc(key, data) | 103 | val = self.getFunc(key, data) |
104 | op = "set?" | ||
97 | if val == None: | 105 | if val == None: |
98 | val = groupd["value"] | 106 | val = groupd["value"] |
99 | elif "colon" in groupd and groupd["colon"] != None: | 107 | elif "colon" in groupd and groupd["colon"] != None: |
100 | e = data.createCopy() | 108 | e = data.createCopy() |
101 | bb.data.update_data(e) | 109 | bb.data.update_data(e) |
110 | op = "immediate" | ||
102 | val = e.expand(groupd["value"], key + "[:=]") | 111 | val = e.expand(groupd["value"], key + "[:=]") |
103 | elif "append" in groupd and groupd["append"] != None: | 112 | elif "append" in groupd and groupd["append"] != None: |
113 | op = "append" | ||
104 | val = "%s %s" % ((self.getFunc(key, data) or ""), groupd["value"]) | 114 | val = "%s %s" % ((self.getFunc(key, data) or ""), groupd["value"]) |
105 | elif "prepend" in groupd and groupd["prepend"] != None: | 115 | elif "prepend" in groupd and groupd["prepend"] != None: |
116 | op = "prepend" | ||
106 | val = "%s %s" % (groupd["value"], (self.getFunc(key, data) or "")) | 117 | val = "%s %s" % (groupd["value"], (self.getFunc(key, data) or "")) |
107 | elif "postdot" in groupd and groupd["postdot"] != None: | 118 | elif "postdot" in groupd and groupd["postdot"] != None: |
119 | op = "postdot" | ||
108 | val = "%s%s" % ((self.getFunc(key, data) or ""), groupd["value"]) | 120 | val = "%s%s" % ((self.getFunc(key, data) or ""), groupd["value"]) |
109 | elif "predot" in groupd and groupd["predot"] != None: | 121 | elif "predot" in groupd and groupd["predot"] != None: |
122 | op = "predot" | ||
110 | val = "%s%s" % (groupd["value"], (self.getFunc(key, data) or "")) | 123 | val = "%s%s" % (groupd["value"], (self.getFunc(key, data) or "")) |
111 | else: | 124 | else: |
112 | val = groupd["value"] | 125 | val = groupd["value"] |
113 | 126 | ||
127 | flag = None | ||
114 | if 'flag' in groupd and groupd['flag'] != None: | 128 | if 'flag' in groupd and groupd['flag'] != None: |
115 | data.setVarFlag(key, groupd['flag'], val) | 129 | flag = groupd['flag'] |
116 | elif groupd["lazyques"]: | 130 | elif groupd["lazyques"]: |
117 | data.setVarFlag(key, "defaultval", val) | 131 | flag = "defaultval" |
132 | |||
133 | loginfo['op'] = op | ||
134 | loginfo['detail'] = groupd["value"] | ||
135 | |||
136 | if flag: | ||
137 | data.setVarFlag(key, flag, val, **loginfo) | ||
118 | else: | 138 | else: |
119 | data.setVar(key, val) | 139 | data.setVar(key, val, **loginfo) |
120 | 140 | ||
121 | class MethodNode(AstNode): | 141 | class MethodNode(AstNode): |
122 | def __init__(self, filename, lineno, func_name, body): | 142 | def __init__(self, filename, lineno, func_name, body): |