scripts/footprint: Avoid fpdiff failure when data changes lots

Bounds check the array access in case the input data changes so that the
number of entries in the 'children' array is not the same. The tool output
with this change isn't terribly useful, but at least it doesn't crash.

Signed-off-by: Keith Packard <keithp@keithp.com>
This commit is contained in:
Keith Packard 2023-11-27 16:57:56 -08:00 committed by Anas Nashif
parent 29a4e04143
commit 97f8b8b6ee

View file

@ -15,7 +15,7 @@
# ./scripts/footprint/fpdiff.py ram1.json ram2.json
from anytree.importer import DictImporter
from anytree import PreOrderIter
from anytree import PreOrderIter, AnyNode
from anytree.search import find
import colorama
@ -46,7 +46,10 @@ def main():
for idx, ch in enumerate(data1['symbols']['children']):
root1 = importer.import_(ch)
root2 = importer.import_(data2['symbols']['children'][idx])
if idx >= len(data2['symbols']['children']):
root2 = AnyNode(identifier=None)
else:
root2 = importer.import_(data2['symbols']['children'][idx])
print(f"{root1.name}\n+++++++++++++++++++++")
for node in PreOrderIter(root1):