scripts: size_report: Fix tree build for symbol copies

Fix the memory footprint tree build for symbols with copies,
e.g. static inline functions which are local per each compilation
unit. Copies have the same path and symbol name, but different
memory blocks associated, so they have to have separate nodes.
Before the fix, these copies were merged into one node, with
summary size and memory address of one of the symbols.

Signed-off-by: Dmitrii Golovanov <dmitrii.golovanov@intel.com>
This commit is contained in:
Dmitrii Golovanov 2024-05-04 16:22:55 +02:00 committed by Anas Nashif
commit 2005deddb4

View file

@ -641,16 +641,27 @@ def generate_any_tree(symbol_dict, total_size, path_prefix):
results = findall_by_attr(root, cur, name="_identifier")
if results:
item = results[0]
item._size += size
parent = item
if not hasattr(item, 'address'):
# Passing down through a non-terminal parent node.
parent = item
parent._size += size
else:
# Another symbol node here with the same name; stick to its parent as well.
parent = item.parent
node = TreeNode(name=str(part), identifier=cur, size=size, parent=parent)
else:
# There is no such terminal symbol in the tree yet; let's add it.
if node:
parent = node
node = TreeNode(name=str(part), identifier=cur, size=size, parent=parent)
# Set memory block address and section only on terminal symbol nodes.
# Don't do it on file and directory level nodes.
node.address = addr
node.section = section
if node:
# Set memory block address and section name properties only for terminal symbol nodes.
# Don't do it on file- and directory- level parent nodes.
node.address = addr
node.section = section
else:
# normally this shouldn't happen; just to detect data or logic errors.
print(f"ERROR: no end node created for {root}, {path}, 0x{addr:08x}+{size}@{section}")
#
# Mapping paths to tree nodes