Skip to content

Commit

Permalink
fix: stats_txt_file not considering persisting assembly differences
Browse files Browse the repository at this point in the history
  • Loading branch information
noseglasses committed Jan 23, 2024
1 parent 86f6611 commit 6679eb9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/elf_diff/pair_report_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,13 @@ def __init__(self):
"persisting",
Properties(Doc(None)),
Value("count", Doc("Number of symbols"), Type(int)),
Value(
"assembly_differs_count",
Doc(
"Number of persisting symbols with assembly differences"
),
Type(int),
),
Node(
"resource_consumption",
Properties(
Expand Down Expand Up @@ -989,13 +996,17 @@ def configureValueTree(self, value_tree_node: ValueTreeNode, **kwargs: Any) -> N
persisting_symbols_overall_size_difference = 0
persisting_symbols_overall_size_old = 0
persisting_symbols_overall_size_new = 0
persisting_symbols_assembly_differs_count = 0

for symbol_name in self.binary_pair.persisting_symbol_names:
old_symbol: ElfSymbol = old_binary.symbols[symbol_name]
new_symbol: ElfSymbol = new_binary.symbols[symbol_name]

size_difference: int = new_symbol.size - old_symbol.size

if old_symbol.instructions != new_symbol.instructions:
persisting_symbols_assembly_differs_count += 1

if (size_difference == 0) and settings.consider_equal_sized_identical:
continue

Expand Down Expand Up @@ -1129,6 +1140,9 @@ def configureValueTree(self, value_tree_node: ValueTreeNode, **kwargs: Any) -> N
document.statistics.symbols.persisting.count = len(
self.binary_pair.persisting_symbol_names
)
document.statistics.symbols.persisting.assembly_differs_count = (
persisting_symbols_assembly_differs_count
)
document.statistics.symbols.persisting.resource_consumption.delta = (
persisting_symbols_overall_size_difference
)
Expand Down
3 changes: 3 additions & 0 deletions src/elf_diff/plugins/export/txt/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ def export(self, document: ValueTreeNode):
or (len(document.symbols.appeared) > 0)
or (len(document.symbols.similar) > 0)
or (len(document.symbols.migrated) > 0)
or (document.statistics.symbols.persisting.assembly_differs_count > 0)
)

with open(self.getConfigurationParameter("output_file"), "w") as f:
Expand All @@ -98,6 +99,8 @@ def export(self, document: ValueTreeNode):
old: {len(document.symbols.old)}
new: {len(document.symbols.new)}
persisting: {len(document.symbols.persisting)}
persisting with assembly differences:
{document.statistics.symbols.persisting.assembly_differs_count}
disappeared: {len(document.symbols.disappeared)}
appeared: {len(document.symbols.appeared)}
similar: {len(document.symbols.similar)}
Expand Down

0 comments on commit 6679eb9

Please sign in to comment.