summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/siggen.py
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2023-08-05 11:04:17 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2023-08-09 13:23:33 +0100
commit84a7485025dd4473403b8da36a0c979a3afd5e93 (patch)
tree16369d28048dfd6ad59b95c632bd1495dcb291de /bitbake/lib/bb/siggen.py
parentafcd4b9cbcda5a631679a962a0a5479101539e29 (diff)
downloadpoky-84a7485025dd4473403b8da36a0c979a3afd5e93.tar.gz
bitbake: siggen: Improve runtaskdeps data to fix sstate debugging
The runtaskdep data in siginfo files was written out with full paths to the bb files, matching bitbake's internal "unique key" ID for recipes/tasks. When originally implemented this made sense. Over time, the main use for the data in siginfo files has become to match against other siginfo files to debug changes of hash calcuations. The recipename data is not useful for this as the siginfo filenames use PN instead which can often be derived from the recipe filename but not always. It is time to throw away the 'tid' data format and switch over the use a hybrid PN form which includes the multiconfig. That can be easily stripped off in the find_siginfo code in oe-core. The other purpose of having a sortable dependency ID is retained and the multiconfig needs to be included to allow the taskhashes to be processed and calculated correctly. PN is meant to be unique between recipes, only one would ever be built so using PN in this location is fine. The one risk of this change is there isn't any compatibility to the old format. I'm not convinced we should spend time complicating the code with it. This change will change the taskhashes everywhere so the only mixing of old and new siginfo files will be either through hash equivalence or through users using the tool against old and new info files manually which will give some weird output but it should be clear they're in different formats as there would be large paths from the old files not present in the new ones. We have options to add backwards compatibility if some issue is found to need that. (Bitbake rev: 637933e2e5a59228a8d17aae4160551cab5f2f61) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/siggen.py')
-rw-r--r--bitbake/lib/bb/siggen.py72
1 files changed, 24 insertions, 48 deletions
diff --git a/bitbake/lib/bb/siggen.py b/bitbake/lib/bb/siggen.py
index c4ff9d8de1..d0a555654b 100644
--- a/bitbake/lib/bb/siggen.py
+++ b/bitbake/lib/bb/siggen.py
@@ -182,6 +182,11 @@ class SignatureGenerator(object):
182 def exit(self): 182 def exit(self):
183 return 183 return
184 184
185def build_pnid(mc, pn, taskname):
186 if mc:
187 return "mc:" + mc + ":" + pn + ":" + taskname
188 return pn + ":" + taskname
189
185class SignatureGeneratorBasic(SignatureGenerator): 190class SignatureGeneratorBasic(SignatureGenerator):
186 """ 191 """
187 """ 192 """
@@ -309,15 +314,19 @@ class SignatureGeneratorBasic(SignatureGenerator):
309 recipename = dataCaches[mc].pkg_fn[mcfn] 314 recipename = dataCaches[mc].pkg_fn[mcfn]
310 315
311 self.tidtopn[tid] = recipename 316 self.tidtopn[tid] = recipename
317 # save hashfn for deps into siginfo?
318 for dep in deps:
319 (depmc, _, deptask, depmcfn) = bb.runqueue.split_tid_mcfn(dep)
320 dep_pn = dataCaches[depmc].pkg_fn[depmcfn]
312 321
313 for dep in sorted(deps, key=clean_basepath): 322 if not self.rundep_check(mcfn, recipename, task, dep, dep_pn, dataCaches):
314 (depmc, _, _, depmcfn) = bb.runqueue.split_tid_mcfn(dep)
315 depname = dataCaches[depmc].pkg_fn[depmcfn]
316 if not self.rundep_check(mcfn, recipename, task, dep, depname, dataCaches):
317 continue 323 continue
324
318 if dep not in self.taskhash: 325 if dep not in self.taskhash:
319 bb.fatal("%s is not in taskhash, caller isn't calling in dependency order?" % dep) 326 bb.fatal("%s is not in taskhash, caller isn't calling in dependency order?" % dep)
320 self.runtaskdeps[tid].append(dep) 327
328 dep_pnid = build_pnid(depmc, dep_pn, deptask)
329 self.runtaskdeps[tid].append((dep_pnid, dep))
321 330
322 if task in dataCaches[mc].file_checksums[mcfn]: 331 if task in dataCaches[mc].file_checksums[mcfn]:
323 if self.checksum_cache: 332 if self.checksum_cache:
@@ -348,8 +357,8 @@ class SignatureGeneratorBasic(SignatureGenerator):
348 def get_taskhash(self, tid, deps, dataCaches): 357 def get_taskhash(self, tid, deps, dataCaches):
349 358
350 data = self.basehash[tid] 359 data = self.basehash[tid]
351 for dep in self.runtaskdeps[tid]: 360 for dep in sorted(self.runtaskdeps[tid]):
352 data += self.get_unihash(dep) 361 data += self.get_unihash(dep[1])
353 362
354 for (f, cs) in self.file_checksum_values[tid]: 363 for (f, cs) in self.file_checksum_values[tid]:
355 if cs: 364 if cs:
@@ -414,7 +423,7 @@ class SignatureGeneratorBasic(SignatureGenerator):
414 data['varvals'][dep] = self.datacaches[mc].siggen_varvals[mcfn][dep] 423 data['varvals'][dep] = self.datacaches[mc].siggen_varvals[mcfn][dep]
415 424
416 if runtime and tid in self.taskhash: 425 if runtime and tid in self.taskhash:
417 data['runtaskdeps'] = self.runtaskdeps[tid] 426 data['runtaskdeps'] = [dep[0] for dep in sorted(self.runtaskdeps[tid])]
418 data['file_checksum_values'] = [] 427 data['file_checksum_values'] = []
419 for f,cs in self.file_checksum_values[tid]: 428 for f,cs in self.file_checksum_values[tid]:
420 if "/./" in f: 429 if "/./" in f:
@@ -422,8 +431,8 @@ class SignatureGeneratorBasic(SignatureGenerator):
422 else: 431 else:
423 data['file_checksum_values'].append((os.path.basename(f), cs)) 432 data['file_checksum_values'].append((os.path.basename(f), cs))
424 data['runtaskhashes'] = {} 433 data['runtaskhashes'] = {}
425 for dep in data['runtaskdeps']: 434 for dep in self.runtaskdeps[tid]:
426 data['runtaskhashes'][dep] = self.get_unihash(dep) 435 data['runtaskhashes'][dep[0]] = self.get_unihash(dep[1])
427 data['taskhash'] = self.taskhash[tid] 436 data['taskhash'] = self.taskhash[tid]
428 data['unihash'] = self.get_unihash(tid) 437 data['unihash'] = self.get_unihash(tid)
429 438
@@ -793,39 +802,6 @@ def list_inline_diff(oldlist, newlist, colors=None):
793 ret.append(item) 802 ret.append(item)
794 return '[%s]' % (', '.join(ret)) 803 return '[%s]' % (', '.join(ret))
795 804
796def clean_basepath(basepath):
797 basepath, dir, recipe_task = basepath.rsplit("/", 2)
798 cleaned = dir + '/' + recipe_task
799
800 if basepath[0] == '/':
801 return cleaned
802
803 if basepath.startswith("mc:") and basepath.count(':') >= 2:
804 mc, mc_name, basepath = basepath.split(":", 2)
805 mc_suffix = ':mc:' + mc_name
806 else:
807 mc_suffix = ''
808
809 # mc stuff now removed from basepath. Whatever was next, if present will be the first
810 # suffix. ':/', recipe path start, marks the end of this. Something like
811 # 'virtual:a[:b[:c]]:/path...' (b and c being optional)
812 if basepath[0] != '/':
813 cleaned += ':' + basepath.split(':/', 1)[0]
814
815 return cleaned + mc_suffix
816
817def clean_basepaths(a):
818 b = {}
819 for x in a:
820 b[clean_basepath(x)] = a[x]
821 return b
822
823def clean_basepaths_list(a):
824 b = []
825 for x in a:
826 b.append(clean_basepath(x))
827 return b
828
829# Handled renamed fields 805# Handled renamed fields
830def handle_renames(data): 806def handle_renames(data):
831 if 'basewhitelist' in data: 807 if 'basewhitelist' in data:
@@ -994,11 +970,11 @@ def compare_sigfiles(a, b, recursecb=None, color=False, collapsed=False):
994 a = a_data['runtaskdeps'][idx] 970 a = a_data['runtaskdeps'][idx]
995 b = b_data['runtaskdeps'][idx] 971 b = b_data['runtaskdeps'][idx]
996 if a_data['runtaskhashes'][a] != b_data['runtaskhashes'][b] and not collapsed: 972 if a_data['runtaskhashes'][a] != b_data['runtaskhashes'][b] and not collapsed:
997 changed.append("%s with hash %s\n changed to\n%s with hash %s" % (clean_basepath(a), a_data['runtaskhashes'][a], clean_basepath(b), b_data['runtaskhashes'][b])) 973 changed.append("%s with hash %s\n changed to\n%s with hash %s" % (a, a_data['runtaskhashes'][a], b, b_data['runtaskhashes'][b]))
998 974
999 if changed: 975 if changed:
1000 clean_a = clean_basepaths_list(a_data['runtaskdeps']) 976 clean_a = a_data['runtaskdeps']
1001 clean_b = clean_basepaths_list(b_data['runtaskdeps']) 977 clean_b = b_data['runtaskdeps']
1002 if clean_a != clean_b: 978 if clean_a != clean_b:
1003 output.append(color_format("{color_title}runtaskdeps changed:{color_default}\n%s") % list_inline_diff(clean_a, clean_b, colors)) 979 output.append(color_format("{color_title}runtaskdeps changed:{color_default}\n%s") % list_inline_diff(clean_a, clean_b, colors))
1004 else: 980 else:
@@ -1007,8 +983,8 @@ def compare_sigfiles(a, b, recursecb=None, color=False, collapsed=False):
1007 983
1008 984
1009 if 'runtaskhashes' in a_data and 'runtaskhashes' in b_data: 985 if 'runtaskhashes' in a_data and 'runtaskhashes' in b_data:
1010 a = clean_basepaths(a_data['runtaskhashes']) 986 a = a_data['runtaskhashes']
1011 b = clean_basepaths(b_data['runtaskhashes']) 987 b = b_data['runtaskhashes']
1012 changed, added, removed = dict_diff(a, b) 988 changed, added, removed = dict_diff(a, b)
1013 if added: 989 if added:
1014 for dep in sorted(added): 990 for dep in sorted(added):