From f72cd6a6a6818625477cdb3dbbef7b730144e160 Mon Sep 17 00:00:00 2001 From: Angie Date: Thu, 18 Jul 2024 22:54:20 -0400 Subject: [PATCH] Check if the file is the same on SymbolComparisonInfo to figure out if it should do an offset diff or an absolute --- src/mapfile_parser/mapfile.py | 9 +++++++-- src/rs/symbol_comparison_info.rs | 14 ++++++++++---- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/mapfile_parser/mapfile.py b/src/mapfile_parser/mapfile.py index f2cfc1a..8a35cba 100644 --- a/src/mapfile_parser/mapfile.py +++ b/src/mapfile_parser/mapfile.py @@ -61,9 +61,14 @@ def diff(self) -> int|None: buildAddress = self.buildAddress expectedAddress = self.expectedAddress + # If both symbols are present in the same file then we do a diff + # between their offsets into their respectives file. + # This is done as a way to avoid too much noise in case an earlier file + # did shift. if self.buildFile is not None and self.expectedFile is not None: - buildAddress = buildAddress - self.buildFile.vram - expectedAddress = expectedAddress - self.expectedFile.vram + if self.buildFile.filepath == self.expectedFile.filepath: + buildAddress -= self.buildFile.vram + expectedAddress -= self.expectedFile.vram return buildAddress - expectedAddress diff --git a/src/rs/symbol_comparison_info.rs b/src/rs/symbol_comparison_info.rs index 9acd556..a7ecb13 100644 --- a/src/rs/symbol_comparison_info.rs +++ b/src/rs/symbol_comparison_info.rs @@ -48,11 +48,17 @@ impl SymbolComparisonInfo { let mut build_address = self.build_address; let mut expected_address = self.expected_address; + // If both symbols are present in the same file then we do a diff + // between their offsets into their respectives file. + // This is done as a way to avoid too much noise in case an earlier file + // did shift. if let Some(build_file) = &self.build_file { - build_address -= build_file.vram; - } - if let Some(expected_file) = &self.expected_file { - expected_address -= expected_file.vram; + if let Some(expected_file) = &self.expected_file { + if build_file.filepath == expected_file.filepath { + build_address -= build_file.vram; + expected_address -= expected_file.vram; + } + } } Some(build_address as i64 - expected_address as i64)