From 1d1758073b215b82b50fb346c6c36cb82db61a3c Mon Sep 17 00:00:00 2001 From: Angie Date: Thu, 18 Jul 2024 18:36:30 -0400 Subject: [PATCH 01/14] Tweak symbol comparison logic a bit --- CHANGELOG.md | 6 ++++++ Cargo.toml | 2 +- pyproject.toml | 2 +- src/mapfile_parser/__init__.py | 4 ++-- src/mapfile_parser/mapfile.py | 24 ++++++++++++++++++++---- 5 files changed, 30 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 96dca4c..f923a04 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Changed + +- Tweak symbol comparison logic a bit. + - Symbol shifting (due to different sizes or extra/missing symbols) should + not affect comparing non shifted files. + ## [2.4.0] - 2024-03-25 ### Added diff --git a/Cargo.toml b/Cargo.toml index 2956fa0..b603165 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ [package] name = "mapfile_parser" -version = "2.4.0" +version = "2.4.1-dev0" edition = "2021" authors = ["Anghelo Carvajal "] description = "Map file parser library focusing decompilation projects" diff --git a/pyproject.toml b/pyproject.toml index 526aedc..39df286 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ [project] name = "mapfile_parser" -version = "2.4.0" +version = "2.4.1-dev0" description = "Map file parser library focusing decompilation projects" readme = "README.md" requires-python = ">=3.8" diff --git a/src/mapfile_parser/__init__.py b/src/mapfile_parser/__init__.py index 0042ee5..6b104a7 100644 --- a/src/mapfile_parser/__init__.py +++ b/src/mapfile_parser/__init__.py @@ -5,8 +5,8 @@ from __future__ import annotations -__version_info__ = (2, 4, 0) -__version__ = ".".join(map(str, __version_info__)) +__version_info__ = (2, 4, 1) +__version__ = ".".join(map(str, __version_info__)) + "-dev0" __author__ = "Decompollaborate" from . import utils as utils diff --git a/src/mapfile_parser/mapfile.py b/src/mapfile_parser/mapfile.py index b9aa284..f2cfc1a 100644 --- a/src/mapfile_parser/mapfile.py +++ b/src/mapfile_parser/mapfile.py @@ -50,7 +50,23 @@ class SymbolComparisonInfo: buildFile: File|None expectedAddress: int expectedFile: File|None - diff: int|None + + @property + def diff(self) -> int|None: + if self.buildAddress < 0: + return None + if self.expectedAddress < 0: + return None + + buildAddress = self.buildAddress + expectedAddress = self.expectedAddress + + if self.buildFile is not None and self.expectedFile is not None: + buildAddress = buildAddress - self.buildFile.vram + expectedAddress = expectedAddress - self.expectedFile.vram + + return buildAddress - expectedAddress + class MapsComparisonInfo: def __init__(self): @@ -695,13 +711,13 @@ def compareFilesAndSymbols(self, otherMapFile: MapFile, *, checkOtherOnSelf: boo for symbol in file: foundSymInfo = otherMapFile.findSymbolByName(symbol.name) if foundSymInfo is not None: - comp = SymbolComparisonInfo(symbol, symbol.vram, file, foundSymInfo.symbol.vram, foundSymInfo.file, symbol.vram - foundSymInfo.symbol.vram) + comp = SymbolComparisonInfo(symbol, symbol.vram, file, foundSymInfo.symbol.vram, foundSymInfo.file) compInfo.comparedList.append(comp) if comp.diff != 0: compInfo.badFiles.add(file) else: compInfo.missingFiles.add(file) - compInfo.comparedList.append(SymbolComparisonInfo(symbol, symbol.vram, file, -1, None, None)) + compInfo.comparedList.append(SymbolComparisonInfo(symbol, symbol.vram, file, -1, None)) if checkOtherOnSelf: for segment in otherMapFile: @@ -710,7 +726,7 @@ def compareFilesAndSymbols(self, otherMapFile: MapFile, *, checkOtherOnSelf: boo foundSymInfo = self.findSymbolByName(symbol.name) if foundSymInfo is None: compInfo.missingFiles.add(file) - compInfo.comparedList.append(SymbolComparisonInfo(symbol, -1, None, symbol.vram, file, None)) + compInfo.comparedList.append(SymbolComparisonInfo(symbol, -1, None, symbol.vram, file)) return compInfo From 517b94b94625a58c09363231b9dfafb48bce962b Mon Sep 17 00:00:00 2001 From: Angie Date: Thu, 18 Jul 2024 21:10:33 -0400 Subject: [PATCH 02/14] Set MSRV --- .github/workflows/publish_crate.yml | 13 +++++++++++++ CHANGELOG.md | 4 ++++ Cargo.toml | 1 + 3 files changed, 18 insertions(+) diff --git a/.github/workflows/publish_crate.yml b/.github/workflows/publish_crate.yml index 0acd914..8bcf1ca 100644 --- a/.github/workflows/publish_crate.yml +++ b/.github/workflows/publish_crate.yml @@ -58,6 +58,19 @@ jobs: - name: Run tests run: cargo test --workspace + msrv: + runs-on: ubuntu-latest + steps: + - name: Checkout reposistory + uses: actions/checkout@v4 + + - name: Setup MSRV checker + uses: taiki-e/install-action@cargo-hack + + - name: Run MSRV checker + run: cargo hack check --rust-version --workspace --all-targets --ignore-private + + publish: name: Publish runs-on: ubuntu-latest diff --git a/CHANGELOG.md b/CHANGELOG.md index f923a04..c721957 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- Add Minimal Supported Rust Version (MSRV) to Cargo.toml. + ### Changed - Tweak symbol comparison logic a bit. diff --git a/Cargo.toml b/Cargo.toml index b603165..29d27d1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,6 +5,7 @@ name = "mapfile_parser" version = "2.4.1-dev0" edition = "2021" +rust-version = "1.65.0" authors = ["Anghelo Carvajal "] description = "Map file parser library focusing decompilation projects" readme = "README.md" From f44fe7fc7873c23423079fc7256e29fa715e86e8 Mon Sep 17 00:00:00 2001 From: Angie Date: Thu, 18 Jul 2024 21:50:41 -0400 Subject: [PATCH 03/14] Forgot to implement symbol comparison change on Rust side --- src/mapfile_parser/mapfile_parser.pyi | 5 ++-- src/rs/mapfile.rs | 6 +--- src/rs/symbol_comparison_info.rs | 41 ++++++++++++++++----------- 3 files changed, 29 insertions(+), 23 deletions(-) diff --git a/src/mapfile_parser/mapfile_parser.pyi b/src/mapfile_parser/mapfile_parser.pyi index 39f0d68..5c3b1b1 100644 --- a/src/mapfile_parser/mapfile_parser.pyi +++ b/src/mapfile_parser/mapfile_parser.pyi @@ -26,9 +26,10 @@ class SymbolComparisonInfo: buildFile: File|None expectedAddress: int expectedFile: File|None - diff: int|None - def __init__(self, symbol: Symbol, buildAddress: int, buildFile: File|None, expectedAddress: int, expectedFile: File|None, diff: int|None): ... + def __init__(self, symbol: Symbol, buildAddress: int, buildFile: File|None, expectedAddress: int, expectedFile: File|None): ... + + def diff(self) -> int|None: ... class MapsComparisonInfo: badFiles: set[File] = set() diff --git a/src/rs/mapfile.rs b/src/rs/mapfile.rs index 77d415d..b55b85f 100644 --- a/src/rs/mapfile.rs +++ b/src/rs/mapfile.rs @@ -625,17 +625,15 @@ impl MapFile { for file in &segment.files_list { for symbol in &file.symbols { if let Some(found_sym_info) = other_map_file.find_symbol_by_name(&symbol.name) { - let diff = symbol.vram as i64 - found_sym_info.symbol.vram as i64; let comp = symbol_comparison_info::SymbolComparisonInfo::new( symbol.clone(), symbol.vram, Some(file.clone()), symbol.vram, Some(found_sym_info.file), - Some(diff), ); - if diff != 0 { + if comp.diff() != Some(0) { comp_info.bad_files.insert(file.clone()); } comp_info.compared_list.push(comp); @@ -648,7 +646,6 @@ impl MapFile { Some(file.clone()), u64::MAX, None, - None, ), ); } @@ -671,7 +668,6 @@ impl MapFile { None, symbol.vram, Some(file.clone()), - None, ), ); } diff --git a/src/rs/symbol_comparison_info.rs b/src/rs/symbol_comparison_info.rs index 8cef422..9acd556 100644 --- a/src/rs/symbol_comparison_info.rs +++ b/src/rs/symbol_comparison_info.rs @@ -18,8 +18,6 @@ pub struct SymbolComparisonInfo { pub expected_address: u64, pub expected_file: Option, - - pub diff: Option, } impl SymbolComparisonInfo { @@ -29,7 +27,6 @@ impl SymbolComparisonInfo { build_file: Option, expected_address: u64, expected_file: Option, - diff: Option, ) -> Self { Self { symbol, @@ -37,9 +34,29 @@ impl SymbolComparisonInfo { build_file, expected_address, expected_file, - diff, } } + + pub fn diff(&self) -> Option { + if self.build_address == u64::MAX { + return None; + } + if self.expected_address == u64::MAX { + return None; + } + + let mut build_address = self.build_address; + let mut expected_address = self.expected_address; + + 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; + } + + Some(build_address as i64 - expected_address as i64) + } } #[cfg(feature = "python_bindings")] @@ -52,14 +69,13 @@ pub(crate) mod python_bindings { #[pymethods] impl super::SymbolComparisonInfo { #[new] - #[pyo3(signature = (symbol, build_address, build_file, expected_address, expected_file, diff))] + #[pyo3(signature = (symbol, build_address, build_file, expected_address, expected_file))] pub fn py_new( symbol: symbol::Symbol, build_address: u64, build_file: Option, expected_address: u64, expected_file: Option, - diff: Option, ) -> Self { Self::new( symbol, @@ -67,7 +83,6 @@ pub(crate) mod python_bindings { build_file, expected_address, expected_file, - diff, ) } @@ -124,15 +139,9 @@ pub(crate) mod python_bindings { Ok(()) } - #[getter] - fn get_diff(&self) -> PyResult> { - Ok(self.diff) - } - - #[setter] - fn set_diff(&mut self, value: Option) -> PyResult<()> { - self.diff = value; - Ok(()) + #[pyo3(name = "diff")] + fn py_diff(&self) -> PyResult> { + Ok(self.diff()) } } } From b02f2501f2f05cd1a2065698d8e5d55bf95481eb Mon Sep 17 00:00:00 2001 From: Angie Date: Thu, 18 Jul 2024 21:53:16 -0400 Subject: [PATCH 04/14] Apply clippy suggestions --- src/rs/mapfile.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/rs/mapfile.rs b/src/rs/mapfile.rs index b55b85f..8d927a8 100644 --- a/src/rs/mapfile.rs +++ b/src/rs/mapfile.rs @@ -205,7 +205,7 @@ impl MapFile { name.push("__fill__"); filepath = prev_file.filepath.with_file_name(name); vram = prev_file.vram + prev_file.size; - section_type = prev_file.section_type.clone(); + section_type.clone_from(&prev_file.section_type); } current_segment.files_list.push(file::File::new_default( @@ -347,7 +347,7 @@ impl MapFile { name.push("__fill__"); filepath = prev_file.filepath.with_file_name(name); - section_type = prev_file.section_type.clone(); + section_type.clone_from(&prev_file.section_type); } let mut new_file = file::File::new_default(filepath, vram, size, §ion_type); From f72cd6a6a6818625477cdb3dbbef7b730144e160 Mon Sep 17 00:00:00 2001 From: Angie Date: Thu, 18 Jul 2024 22:54:20 -0400 Subject: [PATCH 05/14] 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) From b6ff2afd1a523c1c523352becc021492ec8e5cb3 Mon Sep 17 00:00:00 2001 From: angie Date: Fri, 9 Aug 2024 12:21:24 -0400 Subject: [PATCH 06/14] Commit Cargo.lock --- .gitignore | 1 - CHANGELOG.md | 1 + Cargo.lock | 347 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 348 insertions(+), 1 deletion(-) create mode 100644 Cargo.lock diff --git a/.gitignore b/.gitignore index f25e209..bf3b90a 100644 --- a/.gitignore +++ b/.gitignore @@ -170,4 +170,3 @@ cython_debug/ # Added by cargo /target -/Cargo.lock diff --git a/CHANGELOG.md b/CHANGELOG.md index c721957..ad599a3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Tweak symbol comparison logic a bit. - Symbol shifting (due to different sizes or extra/missing symbols) should not affect comparing non shifted files. +- `Cargo.lock` file is now committed to the repo. ## [2.4.0] - 2024-03-25 diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..b01abf3 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,347 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "aho-corasick" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" +dependencies = [ + "memchr", +] + +[[package]] +name = "autocfg" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" + +[[package]] +name = "bitflags" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "heck" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" + +[[package]] +name = "indoc" +version = "2.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b248f5224d1d606005e02c97f5aa4e88eeb230488bcc03bc9ca4d7991399f2b5" + +[[package]] +name = "lazy_static" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" + +[[package]] +name = "libc" +version = "0.2.155" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" + +[[package]] +name = "lock_api" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" +dependencies = [ + "autocfg", + "scopeguard", +] + +[[package]] +name = "mapfile_parser" +version = "2.4.1-dev0" +dependencies = [ + "lazy_static", + "pyo3", + "regex", +] + +[[package]] +name = "memchr" +version = "2.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" + +[[package]] +name = "memoffset" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a" +dependencies = [ + "autocfg", +] + +[[package]] +name = "once_cell" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" + +[[package]] +name = "parking_lot" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-targets", +] + +[[package]] +name = "portable-atomic" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da544ee218f0d287a911e9c99a39a8c9bc8fcad3cb8db5959940044ecfc67265" + +[[package]] +name = "proc-macro2" +version = "1.0.86" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "pyo3" +version = "0.20.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53bdbb96d49157e65d45cc287af5f32ffadd5f4761438b527b055fb0d4bb8233" +dependencies = [ + "cfg-if", + "indoc", + "libc", + "memoffset", + "parking_lot", + "portable-atomic", + "pyo3-build-config", + "pyo3-ffi", + "pyo3-macros", + "unindent", +] + +[[package]] +name = "pyo3-build-config" +version = "0.20.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "deaa5745de3f5231ce10517a1f5dd97d53e5a2fd77aa6b5842292085831d48d7" +dependencies = [ + "once_cell", + "target-lexicon", +] + +[[package]] +name = "pyo3-ffi" +version = "0.20.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62b42531d03e08d4ef1f6e85a2ed422eb678b8cd62b762e53891c05faf0d4afa" +dependencies = [ + "libc", + "pyo3-build-config", +] + +[[package]] +name = "pyo3-macros" +version = "0.20.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7305c720fa01b8055ec95e484a6eca7a83c841267f0dd5280f0c8b8551d2c158" +dependencies = [ + "proc-macro2", + "pyo3-macros-backend", + "quote", + "syn", +] + +[[package]] +name = "pyo3-macros-backend" +version = "0.20.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c7e9b68bb9c3149c5b0cade5d07f953d6d125eb4337723c4ccdb665f1f96185" +dependencies = [ + "heck", + "proc-macro2", + "pyo3-build-config", + "quote", + "syn", +] + +[[package]] +name = "quote" +version = "1.0.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "redox_syscall" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a908a6e00f1fdd0dfd9c0eb08ce85126f6d8bbda50017e74bc4a4b7d4a926a4" +dependencies = [ + "bitflags", +] + +[[package]] +name = "regex" +version = "1.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "smallvec" +version = "1.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" + +[[package]] +name = "syn" +version = "2.0.72" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc4b9b9bf2add8093d3f2c0204471e951b2285580335de42f9d2534f3ae7a8af" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "target-lexicon" +version = "0.12.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1" + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "unindent" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7de7d73e1754487cb58364ee906a499937a0dfabd86bcb980fa99ec8c8fa2ce" + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" From 31cbe8f19477fe85d7cd8c9b4f37cc11f171e127 Mon Sep 17 00:00:00 2001 From: Angie Date: Wed, 7 Aug 2024 14:24:11 -0400 Subject: [PATCH 07/14] Fix some arguments to take references instead of consuming the arguments --- CHANGELOG.md | 2 ++ src/rs/lib.rs | 4 +++- src/rs/mapfile.rs | 56 +++++++++++++++++++++++------------------------ src/rs/utils.rs | 4 ++-- 4 files changed, 35 insertions(+), 31 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ad599a3..a54592b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Symbol shifting (due to different sizes or extra/missing symbols) should not affect comparing non shifted files. - `Cargo.lock` file is now committed to the repo. +- Change Rust functions to properly take references instead of consuming the + argument. ## [2.4.0] - 2024-03-25 diff --git a/src/rs/lib.rs b/src/rs/lib.rs index c392aa3..e05e47c 100644 --- a/src/rs/lib.rs +++ b/src/rs/lib.rs @@ -42,6 +42,8 @@ fn mapfile_parser(_py: Python<'_>, m: &PyModule) -> PyResult<()> { #[cfg(test)] mod tests { + use std::path::PathBuf; + use crate::mapfile::MapFile; // TODO: tests @@ -49,6 +51,6 @@ mod tests { #[test] fn w0_000_map() { let mut map = MapFile::new(); - map.read_map_file("tests/maps/w0_000.map".into()); + map.read_map_file(&PathBuf::from("tests/maps/w0_000.map")); } } diff --git a/src/rs/mapfile.rs b/src/rs/mapfile.rs index 8d927a8..f43a05b 100644 --- a/src/rs/mapfile.rs +++ b/src/rs/mapfile.rs @@ -4,6 +4,7 @@ use std::collections::HashMap; use std::collections::HashSet; use std::fmt::Write; +use std::path::Path; use std::path::PathBuf; use regex::*; @@ -37,7 +38,7 @@ pub struct MapFile { impl MapFile { pub fn new() -> Self { - MapFile { + Self { segments_list: Vec::new(), #[cfg(feature = "python_bindings")] @@ -54,10 +55,10 @@ impl MapFile { - GNU ld - clang ld.lld */ - pub fn read_map_file(&mut self, map_path: PathBuf) { - let map_contents = utils::read_file_contents(&map_path); + pub fn read_map_file(&mut self, map_path: &Path) { + let map_contents = utils::read_file_contents(map_path); - self.parse_map_contents(map_contents); + self.parse_map_contents(&map_contents); } /** @@ -71,11 +72,11 @@ impl MapFile { - GNU ld - clang ld.lld */ - pub fn parse_map_contents(&mut self, map_contents: String) { + pub fn parse_map_contents(&mut self, map_contents: &str) { let regex_lld_header = Regex::new(r"\s+VMA\s+LMA\s+Size\s+Align\s+Out\s+In\s+Symbol").unwrap(); - if regex_lld_header.is_match(&map_contents) { + if regex_lld_header.is_match(map_contents) { self.parse_map_contents_lld(map_contents); } else { // GNU is the fallback @@ -88,7 +89,7 @@ impl MapFile { The `mapContents` argument must contain the contents of a GNU ld mapfile. */ - pub fn parse_map_contents_gnu(&mut self, map_contents: String) { + pub fn parse_map_contents_gnu(&mut self, map_contents: &str) { // TODO: maybe move somewhere else? let regex_section_alone_entry = Regex::new(r"^\s+(?P
[^*][^\s]+)\s*$").unwrap(); let regex_file_data_entry = Regex::new(r"^\s+(?P
([^*][^\s]+)?)\s+(?P0x[^\s]+)\s+(?P0x[^\s]+)\s+(?P[^\s]+)$").unwrap(); @@ -301,7 +302,7 @@ impl MapFile { The `mapContents` argument must contain the contents of a clang ld.lld mapfile. */ - pub fn parse_map_contents_lld(&mut self, map_contents: String) { + pub fn parse_map_contents_lld(&mut self, map_contents: &str) { let map_data = map_contents; // Every line starts with this information, so instead of duplicating it we put them on one single regex @@ -443,7 +444,7 @@ impl MapFile { } } - pub fn filter_by_section_type(&self, section_type: &str) -> MapFile { + pub fn filter_by_section_type(&self, section_type: &str) -> Self { let mut new_map_file = MapFile::new(); for segment in &self.segments_list { @@ -457,7 +458,7 @@ impl MapFile { new_map_file } - pub fn get_every_file_except_section_type(&self, section_type: &str) -> MapFile { + pub fn get_every_file_except_section_type(&self, section_type: &str) -> Self { let mut new_map_file = MapFile::new(); for segment in &self.segments_list { @@ -499,7 +500,7 @@ impl MapFile { pub fn find_lowest_differing_symbol( &self, - other_map_file: MapFile, + other_map_file: &Self, ) -> Option<(symbol::Symbol, file::File, Option)> { let mut min_vram = u64::MAX; let mut found = None; @@ -532,7 +533,7 @@ impl MapFile { None } - pub fn mix_folders(&self) -> MapFile { + pub fn mix_folders(&self) -> Self { let mut new_map_file = MapFile::new(); for segment in &self.segments_list { @@ -544,9 +545,9 @@ impl MapFile { pub fn get_progress( &self, - asm_path: PathBuf, - nonmatchings: PathBuf, - aliases: HashMap, + asm_path: &Path, + nonmatchings: &Path, + aliases: &HashMap, path_index: usize, ) -> ( progress_stats::ProgressStats, @@ -616,7 +617,7 @@ impl MapFile { /// Useful for finding bss reorders pub fn compare_files_and_symbols( &self, - other_map_file: MapFile, + other_map_file: &Self, check_other_on_self: bool, ) -> maps_comparison_info::MapsComparisonInfo { let mut comp_info = maps_comparison_info::MapsComparisonInfo::new(); @@ -712,18 +713,18 @@ impl MapFile { impl MapFile { // TODO: figure out if this is doing unnecessary copies or something - fn preprocess_map_data_gnu(mut map_data: String) -> String { + fn preprocess_map_data_gnu(map_data: &str) -> String { // Skip the stuff we don't care about // Looking for this string will only work on English machines (or C locales) // but it doesn't matter much, because if this string is not found then the // parsing should still work, but just a bit slower because of the extra crap if let Some(aux_var) = map_data.find("\nLinker script and memory map") { if let Some(start_index) = map_data[aux_var + 1..].find('\n') { - map_data = map_data[aux_var + 1 + start_index + 1..].to_string(); + return map_data[aux_var + 1 + start_index + 1..].to_string(); } } - map_data + map_data.to_string() } } @@ -738,8 +739,7 @@ impl Default for MapFile { pub(crate) mod python_bindings { use pyo3::prelude::*; - use std::collections::HashMap; - use std::path::PathBuf; + use std::{collections::HashMap, path::PathBuf}; use crate::{file, found_symbol_info, maps_comparison_info, progress_stats, segment, symbol}; @@ -751,14 +751,14 @@ pub(crate) mod python_bindings { } pub fn readMapFile(&mut self, map_path: PathBuf) { - self.read_map_file(map_path) + self.read_map_file(&map_path) } - pub fn parseMapContents(&mut self, map_contents: String) { + pub fn parseMapContents(&mut self, map_contents: &str) { self.parse_map_contents(map_contents) } - pub fn parseMapContentsGNU(&mut self, map_contents: String) { + pub fn parseMapContentsGNU(&mut self, map_contents: &str) { self.parse_map_contents_gnu(map_contents) } @@ -768,7 +768,7 @@ pub(crate) mod python_bindings { The `mapContents` argument must contain the contents of a clang ld.lld mapfile. */ #[pyo3(name = "parseMapContentsLLD")] - pub fn parseMapContentsLLD(&mut self, map_contents: String) { + pub fn parseMapContentsLLD(&mut self, map_contents: &str) { self.parse_map_contents_lld(map_contents) } @@ -796,7 +796,7 @@ pub(crate) mod python_bindings { pub fn findLowestDifferingSymbol( &self, - other_map_file: Self, + other_map_file: &Self, ) -> Option<(symbol::Symbol, file::File, Option)> { self.find_lowest_differing_symbol(other_map_file) } @@ -816,13 +816,13 @@ pub(crate) mod python_bindings { progress_stats::ProgressStats, HashMap, ) { - self.get_progress(asm_path, nonmatchings, aliases, path_index) + self.get_progress(&asm_path, &nonmatchings, &aliases, path_index) } #[pyo3(signature=(other_map_file, *, check_other_on_self=true))] pub fn compareFilesAndSymbols( &self, - other_map_file: Self, + other_map_file: &Self, check_other_on_self: bool, ) -> maps_comparison_info::MapsComparisonInfo { self.compare_files_and_symbols(other_map_file, check_other_on_self) diff --git a/src/rs/utils.rs b/src/rs/utils.rs index a239a74..e10bdeb 100644 --- a/src/rs/utils.rs +++ b/src/rs/utils.rs @@ -1,13 +1,13 @@ /* SPDX-FileCopyrightText: © 2023-2024 Decompollaborate */ /* SPDX-License-Identifier: MIT */ -use std::{fs::File, io::Read, path::PathBuf}; +use std::{fs::File, io::Read, path::Path}; pub fn parse_hex(src: &str) -> u64 { u64::from_str_radix(src.trim_start_matches("0x"), 16).unwrap() } -pub fn read_file_contents(file_path: &PathBuf) -> String { +pub fn read_file_contents(file_path: &Path) -> String { let mut f = File::open(file_path).expect("Could not open input file"); let mut file_contents: String = String::new(); let _contents_length = f From c4f0861bb8a599497317467b4a8130d5ff1a431d Mon Sep 17 00:00:00 2001 From: Angie Date: Wed, 7 Aug 2024 14:37:34 -0400 Subject: [PATCH 08/14] Add `MapFile::new_from_map_file` function to simplify `MapFile` creation --- CHANGELOG.md | 1 + src/mapfile_parser/mapfile_parser.pyi | 3 +++ src/rs/mapfile.rs | 27 +++++++++++++++++++++++---- 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a54592b..92bc2c3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Add Minimal Supported Rust Version (MSRV) to Cargo.toml. +- Add `MapFile::new_from_map_file` function to simplify `MapFile` creation. ### Changed diff --git a/src/mapfile_parser/mapfile_parser.pyi b/src/mapfile_parser/mapfile_parser.pyi index 5c3b1b1..f29dcb5 100644 --- a/src/mapfile_parser/mapfile_parser.pyi +++ b/src/mapfile_parser/mapfile_parser.pyi @@ -211,6 +211,9 @@ class Segment: class MapFile: def __init__(self) -> None: ... + @staticmethod + def newFromMapFile(mapPath: Path) -> MapFile: ... + def readMapFile(self, mapPath: Path) -> None: ... def parseMapContents(self, mapContents: str) -> None: ... def parseMapContentsGNU(self, mapContents: str) -> None: ... diff --git a/src/rs/mapfile.rs b/src/rs/mapfile.rs index f43a05b..dd8b6c8 100644 --- a/src/rs/mapfile.rs +++ b/src/rs/mapfile.rs @@ -46,8 +46,22 @@ impl MapFile { } } + /// Creates a new `MapFile` object and fills it with the contents from the + /// file pointed by the `map_path` argument. + /// + /// The format of the map will be guessed based on its contents. + /// + /// Currently supported map formats: + /// - GNU ld + /// - clang ld.lld + pub fn new_from_map_file(map_path: &Path) -> Self { + let mut m = Self::new(); + m.read_map_file(map_path); + m + } + /** - Opens the mapfile pointed by the `mapPath` argument and parses it. + Opens the mapfile pointed by the `map_path` argument and parses it. The format of the map will be guessed based on its contents. @@ -64,7 +78,7 @@ impl MapFile { /** Parses the contents of the map. - The `mapContents` argument must contain the contents of a mapfile. + The `map_contents` argument must contain the contents of a mapfile. The format of the map will be guessed based on its contents. @@ -87,7 +101,7 @@ impl MapFile { /** Parses the contents of a GNU ld map. - The `mapContents` argument must contain the contents of a GNU ld mapfile. + The `map_contents` argument must contain the contents of a GNU ld mapfile. */ pub fn parse_map_contents_gnu(&mut self, map_contents: &str) { // TODO: maybe move somewhere else? @@ -300,7 +314,7 @@ impl MapFile { /** Parses the contents of a clang ld.lld map. - The `mapContents` argument must contain the contents of a clang ld.lld mapfile. + The `map_contents` argument must contain the contents of a clang ld.lld mapfile. */ pub fn parse_map_contents_lld(&mut self, map_contents: &str) { let map_data = map_contents; @@ -750,6 +764,11 @@ pub(crate) mod python_bindings { Self::new() } + #[staticmethod] + pub fn newFromMapFile(map_path: PathBuf) -> Self { + Self::new_from_map_file(&map_path) + } + pub fn readMapFile(&mut self, map_path: PathBuf) { self.read_map_file(&map_path) } From 9adab028331de2869c12c7bdca812ac1de1ca99a Mon Sep 17 00:00:00 2001 From: Angie Date: Wed, 7 Aug 2024 15:08:53 -0400 Subject: [PATCH 09/14] Add `serde` feature to the Rust crate --- .github/workflows/publish_crate.yml | 40 +++++++++++++++++++++++++++++ CHANGELOG.md | 2 ++ Cargo.lock | 21 +++++++++++++++ Cargo.toml | 3 ++- src/rs/file.rs | 4 +++ src/rs/mapfile.rs | 4 +++ src/rs/segment.rs | 4 +++ src/rs/symbol.rs | 20 ++++++++++++++- 8 files changed, 96 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish_crate.yml b/.github/workflows/publish_crate.yml index 8bcf1ca..45428f7 100644 --- a/.github/workflows/publish_crate.yml +++ b/.github/workflows/publish_crate.yml @@ -41,6 +41,46 @@ jobs: - name: Run clippy run: cargo clippy --all-targets -- -D warnings + check_clippy_serde: + name: Check clippy + runs-on: ubuntu-latest + + steps: + - name: Checkout reposistory + uses: actions/checkout@v4 + + - name: Setup Rust toolchain + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + override: true + + - name: Setup clippy + run: rustup component add clippy + + - name: Run clippy + run: cargo clippy --all-targets --features serde -- -D warnings + + check_clippy_all_features: + name: Check clippy + runs-on: ubuntu-latest + + steps: + - name: Checkout reposistory + uses: actions/checkout@v4 + + - name: Setup Rust toolchain + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + override: true + + - name: Setup clippy + run: rustup component add clippy + + - name: Run clippy + run: cargo clippy --all-targets --all-features -- -D warnings + run_tests: name: Run tests runs-on: ubuntu-latest diff --git a/CHANGELOG.md b/CHANGELOG.md index 92bc2c3..e8c4516 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Add Minimal Supported Rust Version (MSRV) to Cargo.toml. - Add `MapFile::new_from_map_file` function to simplify `MapFile` creation. +- Add `serde` feature to the Rust crate. + - Allows serializing and deserializing a `MapFile` object using serde. ### Changed diff --git a/Cargo.lock b/Cargo.lock index b01abf3..aae38a6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -70,6 +70,7 @@ dependencies = [ "lazy_static", "pyo3", "regex", + "serde", ] [[package]] @@ -247,6 +248,26 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" +[[package]] +name = "serde" +version = "1.0.205" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e33aedb1a7135da52b7c21791455563facbbcc43d0f0f66165b42c21b3dfb150" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.205" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "692d6f5ac90220161d6774db30c662202721e64aed9058d2c394f451261420c1" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "smallvec" version = "1.13.2" diff --git a/Cargo.toml b/Cargo.toml index 29d27d1..df0e248 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,6 @@ rust-version = "1.65.0" authors = ["Anghelo Carvajal "] description = "Map file parser library focusing decompilation projects" readme = "README.md" -homepage = "https://github.com/Decompollaborate/mapfile_parser" repository = "https://github.com/Decompollaborate/mapfile_parser" license = "MIT" keywords = ["mapfile", "parser", "decomp", "decompilation"] @@ -26,6 +25,8 @@ crate-type = ["cdylib", "staticlib", "rlib"] regex = "1.10.2" pyo3 = { version = "0.20.0", optional = true, features = ["abi3", "abi3-py37"]} lazy_static = "1.4.0" +serde = { version = "1.0", features = ["derive"], optional = true } [features] python_bindings = ["dep:pyo3"] +serde = ["dep:serde"] diff --git a/src/rs/file.rs b/src/rs/file.rs index cab89ce..6989cf2 100644 --- a/src/rs/file.rs +++ b/src/rs/file.rs @@ -12,8 +12,12 @@ use crate::{symbol, utils}; #[cfg(feature = "python_bindings")] use pyo3::prelude::*; +#[cfg(feature = "serde")] +use serde::{Deserialize, Serialize}; + #[derive(Debug, Clone)] #[cfg_attr(feature = "python_bindings", pyclass(module = "mapfile_parser"))] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] pub struct File { pub filepath: PathBuf, diff --git a/src/rs/mapfile.rs b/src/rs/mapfile.rs index dd8b6c8..f1a2622 100644 --- a/src/rs/mapfile.rs +++ b/src/rs/mapfile.rs @@ -12,6 +12,9 @@ use regex::*; #[cfg(feature = "python_bindings")] use pyo3::prelude::*; +#[cfg(feature = "serde")] +use serde::{Deserialize, Serialize}; + use crate::{ file, found_symbol_info, maps_comparison_info, progress_stats, segment, symbol, symbol_comparison_info, utils, @@ -28,6 +31,7 @@ lazy_static! { #[derive(Debug, Clone)] // TODO: sequence? #[cfg_attr(feature = "python_bindings", pyclass(module = "mapfile_parser"))] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] pub struct MapFile { pub segments_list: Vec, diff --git a/src/rs/segment.rs b/src/rs/segment.rs index f472219..78950f2 100644 --- a/src/rs/segment.rs +++ b/src/rs/segment.rs @@ -13,8 +13,12 @@ use std::hash::{Hash, Hasher}; #[cfg(feature = "python_bindings")] use pyo3::prelude::*; +#[cfg(feature = "serde")] +use serde::{Deserialize, Serialize}; + #[derive(Debug, Clone)] #[cfg_attr(feature = "python_bindings", pyclass(module = "mapfile_parser"))] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] pub struct Segment { pub name: String, diff --git a/src/rs/symbol.rs b/src/rs/symbol.rs index bb2c15b..0763d2e 100644 --- a/src/rs/symbol.rs +++ b/src/rs/symbol.rs @@ -7,8 +7,12 @@ use std::hash::{Hash, Hasher}; #[cfg(feature = "python_bindings")] use pyo3::prelude::*; +#[cfg(feature = "serde")] +use serde::{Deserialize, Serialize}; + #[derive(Debug, Clone)] #[cfg_attr(feature = "python_bindings", pyclass(module = "mapfile_parser"))] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] pub struct Symbol { pub name: String, @@ -20,7 +24,9 @@ pub struct Symbol { pub align: Option, + // idk if it is worth to continue maintaining this, given the complexity introduced by other features #[cfg(feature = "python_bindings")] + #[cfg(not(feature = "serde"))] chached_name: Option, } @@ -40,6 +46,7 @@ impl Symbol { align, #[cfg(feature = "python_bindings")] + #[cfg(not(feature = "serde"))] chached_name: None, } } @@ -53,6 +60,7 @@ impl Symbol { align: None, #[cfg(feature = "python_bindings")] + #[cfg(not(feature = "serde"))] chached_name: None, } } @@ -144,6 +152,7 @@ pub(crate) mod python_bindings { /* Getters and setters */ #[getter] + #[cfg(not(feature = "serde"))] fn get_name(&mut self) -> PyObject { Python::with_gil(|py| { if self.chached_name.is_none() { @@ -154,9 +163,18 @@ pub(crate) mod python_bindings { }) } + #[getter] + #[cfg(feature = "serde")] + fn get_name(&self) -> PyResult { + Ok(self.name.clone()) + } + #[setter] fn set_name(&mut self, value: String) -> PyResult<()> { - self.chached_name = None; + #[cfg(not(feature = "serde"))] + { + self.chached_name = None; + } self.name = value; Ok(()) } From e2e2903b50b2ef7ab5365d787fea2175279a817f Mon Sep 17 00:00:00 2001 From: Angie Date: Wed, 7 Aug 2024 19:32:27 -0400 Subject: [PATCH 10/14] Fix `MapFile::find_lowest_differing_symbol` not returning a previous symbol from a previous file if the symbol found is the first symbol from the file. --- CHANGELOG.md | 5 +++ src/mapfile_parser/mapfile.py | 40 ++++++++++++++++++--- src/rs/mapfile.rs | 66 ++++++++++++++++++++++++++++------- 3 files changed, 94 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e8c4516..51392c1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Change Rust functions to properly take references instead of consuming the argument. +### Fixed + +- Fix `MapFile::find_lowest_differing_symbol` not returning a previous symbol + from a previous file if the symbol found is the first symbol from the file. + ## [2.4.0] - 2024-03-25 ### Added diff --git a/src/mapfile_parser/mapfile.py b/src/mapfile_parser/mapfile.py index 8a35cba..bae239e 100644 --- a/src/mapfile_parser/mapfile.py +++ b/src/mapfile_parser/mapfile.py @@ -614,9 +614,10 @@ def findSymbolByVramOrVrom(self, address: int) -> FoundSymbolInfo|None: def findLowestDifferingSymbol(self, otherMapFile: MapFile) -> tuple[Symbol, File, Symbol|None]|None: minVram = None found = None - for builtSegement in self._segmentsList: - for builtFile in builtSegement: - for i, builtSym in enumerate(builtFile): + foundIndices = (0, 0) + for i, builtSegement in enumerate(self._segmentsList): + for j, builtFile in enumerate(builtSegement): + for k, builtSym in enumerate(builtFile): expectedSymInfo = otherMapFile.findSymbolByName(builtSym.name) if expectedSymInfo is None: continue @@ -626,9 +627,38 @@ def findLowestDifferingSymbol(self, otherMapFile: MapFile) -> tuple[Symbol, File if minVram is None or builtSym.vram < minVram: minVram = builtSym.vram prevSym = None - if i > 0: - prevSym = builtFile[i-1] + if k > 0: + prevSym = builtFile[k-1] found = (builtSym, builtFile, prevSym) + foundIndices = (i, j) + + if found is not None and found[2] is None: + # Previous symbol was not in the same section of the given + # file, so we try to backtrack until we find any symbol. + + foundBuiltSym, foundBuiltFile, _ = found + i, j = foundIndices + + # We want to check the previous file, not the current one, + # since we already know the current one doesn't have a symbol + # preceding the one we found. + j -= 1; + + while i >= 0: + builtSegment = self[i] + while j >= 0: + builtFile = builtSegment[j] + + if len(builtFile) > 0: + found = (foundBuiltSym, foundBuiltFile, builtFile[-1]) + i = -1 + j = -1 + break + j -= 1 + i -= 1 + if i >= 0: + j = len(self[i]) - 1 + return found diff --git a/src/rs/mapfile.rs b/src/rs/mapfile.rs index f1a2622..aa58c34 100644 --- a/src/rs/mapfile.rs +++ b/src/rs/mapfile.rs @@ -519,13 +519,14 @@ impl MapFile { pub fn find_lowest_differing_symbol( &self, other_map_file: &Self, - ) -> Option<(symbol::Symbol, file::File, Option)> { + ) -> Option<(&symbol::Symbol, &file::File, Option<&symbol::Symbol>)> { let mut min_vram = u64::MAX; let mut found = None; + let mut found_indices = (0, 0); - for built_segement in &self.segments_list { - for built_file in &built_segement.files_list { - for (i, built_sym) in built_file.symbols.iter().enumerate() { + for (i, built_segment) in self.segments_list.iter().enumerate() { + for (j, built_file) in built_segment.files_list.iter().enumerate() { + for (k, built_sym) in built_file.symbols.iter().enumerate() { if let Some(expected_sym_info) = other_map_file.find_symbol_by_name(&built_sym.name) { @@ -534,21 +535,58 @@ impl MapFile { if built_sym.vram != expected_sym.vram && built_sym.vram < min_vram { min_vram = built_sym.vram; - let mut prev_sym = None; - if i > 0 { - prev_sym = Some(built_file.symbols[i - 1].clone()); - } + let prev_sym = if k > 0 { + Some(&built_file.symbols[k - 1]) + } else { + None + }; found = Some((built_sym, built_file, prev_sym)); + found_indices = (i as isize, j as isize); } } } } } - if let Some(found_temp) = found { - return Some((found_temp.0.clone(), found_temp.1.clone(), found_temp.2)); + if let Some((found_built_sym, found_built_file, prev_sym)) = found { + if prev_sym.is_none() { + // Previous symbol was not in the same section of the given + // file, so we try to backtrack until we find any symbol. + + let (mut i, mut j) = found_indices; + + // We want to check the previous file, not the current one, + // since we already know the current one doesn't have a symbol + // preceding the one we found. + j -= 1; + + 'outer: while i >= 0 { + let built_segment = &self.segments_list[i as usize]; + + while j >= 0 { + let built_file = &built_segment.files_list[j as usize]; + + if !built_file.symbols.is_empty() { + found = Some(( + found_built_sym, + found_built_file, + built_file.symbols.last(), + )); + break 'outer; + } + + j -= 1; + } + + i -= 1; + if i >= 0 { + j = self.segments_list[i as usize].files_list.len() as isize - 1; + } + } + } } - None + + found } pub fn mix_folders(&self) -> Self { @@ -821,7 +859,11 @@ pub(crate) mod python_bindings { &self, other_map_file: &Self, ) -> Option<(symbol::Symbol, file::File, Option)> { - self.find_lowest_differing_symbol(other_map_file) + if let Some((s, f, os)) = self.find_lowest_differing_symbol(other_map_file) { + Some((s.clone(), f.clone(), os.cloned())) + } else { + None + } } pub fn mixFolders(&self) -> Self { From f21c54097a4e3482819f891d807d29d62b4d2e69 Mon Sep 17 00:00:00 2001 From: Angie Date: Wed, 7 Aug 2024 19:49:27 -0400 Subject: [PATCH 11/14] more reference fixing --- src/rs/file.rs | 31 +++++++++++++++---------------- src/rs/segment.rs | 10 +++------- 2 files changed, 18 insertions(+), 23 deletions(-) diff --git a/src/rs/file.rs b/src/rs/file.rs index 6989cf2..49a3fd5 100644 --- a/src/rs/file.rs +++ b/src/rs/file.rs @@ -58,27 +58,22 @@ impl File { utils::is_noload_section(&self.section_type) } - pub fn find_symbol_by_name(&self, sym_name: &str) -> Option { - for sym in &self.symbols { - if sym.name == sym_name { - return Some(sym.clone()); - } - } - None + pub fn find_symbol_by_name(&self, sym_name: &str) -> Option<&symbol::Symbol> { + self.symbols.iter().find(|&sym| sym.name == sym_name) } - pub fn find_symbol_by_vram_or_vrom(&self, address: u64) -> Option<(symbol::Symbol, i64)> { + pub fn find_symbol_by_vram_or_vrom(&self, address: u64) -> Option<(&symbol::Symbol, i64)> { let mut prev_sym: Option<&symbol::Symbol> = None; let is_vram = address >= 0x1000000; for sym in &self.symbols { if sym.vram == address { - return Some((sym.clone(), 0)); + return Some((sym, 0)); } if let Some(sym_vrom_temp) = sym.vrom { if sym_vrom_temp == address { - return Some((sym.clone(), 0)); + return Some((sym, 0)); } } @@ -90,7 +85,7 @@ impl File { if offset < 0 { return None; } - return Some((prev_sym_temp.clone(), offset)); + return Some((prev_sym_temp, offset)); } } } @@ -99,7 +94,7 @@ impl File { if offset < 0 { return None; } - return Some((prev_sym_temp.clone(), offset)); + return Some((prev_sym_temp, offset)); } } @@ -114,7 +109,7 @@ impl File { if offset < 0 { return None; } - return Some((prev_sym_temp.clone(), offset)); + return Some((prev_sym_temp, offset)); } } @@ -123,7 +118,7 @@ impl File { if offset < 0 { return None; } - return Some((prev_sym_temp.clone(), offset)); + return Some((prev_sym_temp, offset)); } } } @@ -391,11 +386,15 @@ pub(crate) mod python_bindings { } pub fn findSymbolByName(&self, sym_name: &str) -> Option { - self.find_symbol_by_name(sym_name) + self.find_symbol_by_name(sym_name).cloned() } pub fn findSymbolByVramOrVrom(&self, address: u64) -> Option<(symbol::Symbol, i64)> { - self.find_symbol_by_vram_or_vrom(address) + if let Some((sym, offset)) = self.find_symbol_by_vram_or_vrom(address) { + Some((sym.clone(), offset)) + } else { + None + } } #[staticmethod] diff --git a/src/rs/segment.rs b/src/rs/segment.rs index 78950f2..ef3e6ea 100644 --- a/src/rs/segment.rs +++ b/src/rs/segment.rs @@ -77,7 +77,7 @@ impl Segment { if let Some(sym) = file.find_symbol_by_name(sym_name) { return Some(found_symbol_info::FoundSymbolInfo::new_default( file.clone(), - sym, + sym.clone(), )); } } @@ -89,13 +89,10 @@ impl Segment { address: u64, ) -> Option { for file in &self.files_list { - if let Some(pair) = file.find_symbol_by_vram_or_vrom(address) { - let sym = pair.0; - let offset = pair.1; - + if let Some((sym, offset)) = file.find_symbol_by_vram_or_vrom(address) { return Some(found_symbol_info::FoundSymbolInfo::new( file.clone(), - sym, + sym.clone(), offset, )); } @@ -106,7 +103,6 @@ impl Segment { pub fn mix_folders(&self) -> Self { let mut new_segment = self.clone_no_filelist(); - // > let mut aux_dict = HashMap::new(); // Put files in the same folder together From 030cc73e6110325a02d5b656be3f875ac6d79afe Mon Sep 17 00:00:00 2001 From: angie Date: Fri, 9 Aug 2024 12:59:01 -0400 Subject: [PATCH 12/14] Remove `pub` from python bindings --- src/rs/file.rs | 16 +++++++------- src/rs/found_symbol_info.rs | 6 +++--- src/rs/mapfile.rs | 36 ++++++++++++++++---------------- src/rs/maps_comparison_info.rs | 2 +- src/rs/progress_stats.rs | 14 ++++++------- src/rs/segment.rs | 20 +++++++++--------- src/rs/symbol.rs | 18 ++++++++-------- src/rs/symbol_comparison_info.rs | 2 +- 8 files changed, 57 insertions(+), 57 deletions(-) diff --git a/src/rs/file.rs b/src/rs/file.rs index 49a3fd5..2999aa1 100644 --- a/src/rs/file.rs +++ b/src/rs/file.rs @@ -270,7 +270,7 @@ pub(crate) mod python_bindings { #[pymethods] impl super::File { #[new] - pub fn py_new( + fn py_new( filepath: PathBuf, vram: u64, size: u64, @@ -370,7 +370,7 @@ pub(crate) mod python_bindings { */ #[getter] - pub fn isNoloadSection(&self) -> bool { + fn isNoloadSection(&self) -> bool { self.is_noload_section() } @@ -385,11 +385,11 @@ pub(crate) mod python_bindings { .collect() } - pub fn findSymbolByName(&self, sym_name: &str) -> Option { + fn findSymbolByName(&self, sym_name: &str) -> Option { self.find_symbol_by_name(sym_name).cloned() } - pub fn findSymbolByVramOrVrom(&self, address: u64) -> Option<(symbol::Symbol, i64)> { + fn findSymbolByVramOrVrom(&self, address: u64) -> Option<(symbol::Symbol, i64)> { if let Some((sym, offset)) = self.find_symbol_by_vram_or_vrom(address) { Some((sym.clone(), offset)) } else { @@ -399,23 +399,23 @@ pub(crate) mod python_bindings { #[staticmethod] #[pyo3(signature=(print_vram=true))] - pub fn toCsvHeader(print_vram: bool) -> String { + fn toCsvHeader(print_vram: bool) -> String { Self::to_csv_header(print_vram) } #[pyo3(signature=(print_vram=true))] - pub fn toCsv(&self, print_vram: bool) -> String { + fn toCsv(&self, print_vram: bool) -> String { self.to_csv(print_vram) } #[staticmethod] #[pyo3(signature=(print_vram=true))] - pub fn printCsvHeader(print_vram: bool) { + fn printCsvHeader(print_vram: bool) { Self::print_csv_header(print_vram) } #[pyo3(signature=(print_vram=true))] - pub fn printAsCsv(&self, print_vram: bool) { + fn printAsCsv(&self, print_vram: bool) { self.print_as_csv(print_vram) } diff --git a/src/rs/found_symbol_info.rs b/src/rs/found_symbol_info.rs index 2a782e0..6ed876d 100644 --- a/src/rs/found_symbol_info.rs +++ b/src/rs/found_symbol_info.rs @@ -74,7 +74,7 @@ pub(crate) mod python_bindings { impl super::FoundSymbolInfo { #[new] #[pyo3(signature=(file, symbol, offset=0))] - pub fn py_new(file: file::File, symbol: symbol::Symbol, offset: i64) -> Self { + fn py_new(file: file::File, symbol: symbol::Symbol, offset: i64) -> Self { Self::new(file, symbol, offset) } @@ -116,12 +116,12 @@ pub(crate) mod python_bindings { /* Methods */ #[pyo3(name = "getAsStr")] - pub fn getAsStr(&self) -> String { + fn getAsStr(&self) -> String { self.get_as_str() } #[pyo3(name = "getAsStrPlusOffset")] - pub fn getAsStrPlusOffset(&self, sym_name: Option) -> String { + fn getAsStrPlusOffset(&self, sym_name: Option) -> String { self.get_as_str_plus_offset(sym_name) } } diff --git a/src/rs/mapfile.rs b/src/rs/mapfile.rs index aa58c34..7ed5bb4 100644 --- a/src/rs/mapfile.rs +++ b/src/rs/mapfile.rs @@ -802,24 +802,24 @@ pub(crate) mod python_bindings { #[pymethods] impl super::MapFile { #[new] - pub fn py_new() -> Self { + fn py_new() -> Self { Self::new() } #[staticmethod] - pub fn newFromMapFile(map_path: PathBuf) -> Self { + fn newFromMapFile(map_path: PathBuf) -> Self { Self::new_from_map_file(&map_path) } - pub fn readMapFile(&mut self, map_path: PathBuf) { + fn readMapFile(&mut self, map_path: PathBuf) { self.read_map_file(&map_path) } - pub fn parseMapContents(&mut self, map_contents: &str) { + fn parseMapContents(&mut self, map_contents: &str) { self.parse_map_contents(map_contents) } - pub fn parseMapContentsGNU(&mut self, map_contents: &str) { + fn parseMapContentsGNU(&mut self, map_contents: &str) { self.parse_map_contents_gnu(map_contents) } @@ -829,33 +829,33 @@ pub(crate) mod python_bindings { The `mapContents` argument must contain the contents of a clang ld.lld mapfile. */ #[pyo3(name = "parseMapContentsLLD")] - pub fn parseMapContentsLLD(&mut self, map_contents: &str) { + fn parseMapContentsLLD(&mut self, map_contents: &str) { self.parse_map_contents_lld(map_contents) } - pub fn filterBySectionType(&self, section_type: &str) -> Self { + fn filterBySectionType(&self, section_type: &str) -> Self { self.filter_by_section_type(section_type) } - pub fn getEveryFileExceptSectionType(&self, section_type: &str) -> Self { + fn getEveryFileExceptSectionType(&self, section_type: &str) -> Self { self.get_every_file_except_section_type(section_type) } - pub fn findSymbolByName( + fn findSymbolByName( &self, sym_name: &str, ) -> Option { self.find_symbol_by_name(sym_name) } - pub fn findSymbolByVramOrVrom( + fn findSymbolByVramOrVrom( &self, address: u64, ) -> Option { self.find_symbol_by_vram_or_vrom(address) } - pub fn findLowestDifferingSymbol( + fn findLowestDifferingSymbol( &self, other_map_file: &Self, ) -> Option<(symbol::Symbol, file::File, Option)> { @@ -866,12 +866,12 @@ pub(crate) mod python_bindings { } } - pub fn mixFolders(&self) -> Self { + fn mixFolders(&self) -> Self { self.mix_folders() } #[pyo3(signature = (asm_path, nonmatchings, aliases=HashMap::new(), path_index=2))] - pub fn getProgress( + fn getProgress( &self, asm_path: PathBuf, nonmatchings: PathBuf, @@ -885,7 +885,7 @@ pub(crate) mod python_bindings { } #[pyo3(signature=(other_map_file, *, check_other_on_self=true))] - pub fn compareFilesAndSymbols( + fn compareFilesAndSymbols( &self, other_map_file: &Self, check_other_on_self: bool, @@ -894,20 +894,20 @@ pub(crate) mod python_bindings { } #[pyo3(signature=(print_vram=true, skip_without_symbols=true))] - pub fn toCsv(&self, print_vram: bool, skip_without_symbols: bool) -> String { + fn toCsv(&self, print_vram: bool, skip_without_symbols: bool) -> String { self.to_csv(print_vram, skip_without_symbols) } - pub fn toCsvSymbols(&self) -> String { + fn toCsvSymbols(&self) -> String { self.to_csv_symbols() } #[pyo3(signature=(print_vram=true, skip_without_symbols=true))] - pub fn printAsCsv(&self, print_vram: bool, skip_without_symbols: bool) { + fn printAsCsv(&self, print_vram: bool, skip_without_symbols: bool) { self.print_as_csv(print_vram, skip_without_symbols) } - pub fn printSymbolsCsv(&self) { + fn printSymbolsCsv(&self) { self.print_symbols_csv() } diff --git a/src/rs/maps_comparison_info.rs b/src/rs/maps_comparison_info.rs index 6cedd2c..6dce8fd 100644 --- a/src/rs/maps_comparison_info.rs +++ b/src/rs/maps_comparison_info.rs @@ -46,7 +46,7 @@ pub(crate) mod python_bindings { #[pymethods] impl super::MapsComparisonInfo { #[new] - pub fn py_new() -> Self { + fn py_new() -> Self { Self::new() } diff --git a/src/rs/progress_stats.rs b/src/rs/progress_stats.rs index 7e0e48d..14eb4b0 100644 --- a/src/rs/progress_stats.rs +++ b/src/rs/progress_stats.rs @@ -109,7 +109,7 @@ pub(crate) mod python_bindings { #[pymethods] impl super::ProgressStats { #[new] - pub fn py_new() -> Self { + fn py_new() -> Self { Self::new() } @@ -139,7 +139,7 @@ pub(crate) mod python_bindings { #[getter] #[pyo3(name = "total")] - pub fn py_total(&self) -> usize { + fn py_total(&self) -> usize { self.total() } @@ -161,24 +161,24 @@ pub(crate) mod python_bindings { self.decomped_percentage_total(total_stats) } - pub fn getAsFrogressEntry(&self, name: &str) -> HashMap { + fn getAsFrogressEntry(&self, name: &str) -> HashMap { self.get_as_frogress_entry(name) } #[staticmethod] #[pyo3(signature=(category_column_size=28))] - pub fn getHeaderAsStr(category_column_size: usize) -> String { + fn getHeaderAsStr(category_column_size: usize) -> String { Self::get_header_as_str(category_column_size) } #[staticmethod] #[pyo3(signature=(category_column_size=28))] - pub fn printHeader(category_column_size: usize) { + fn printHeader(category_column_size: usize) { Self::print_header(category_column_size) } #[pyo3(signature=(category, total_stats, category_column_size=28))] - pub fn getEntryAsStr( + fn getEntryAsStr( &self, category: &str, total_stats: &Self, @@ -189,7 +189,7 @@ pub(crate) mod python_bindings { #[pyo3(name = "print")] #[pyo3(signature=(category, total_stats, category_column_size=28))] - pub fn py_print(&self, category: &str, total_stats: &Self, category_column_size: usize) { + fn py_print(&self, category: &str, total_stats: &Self, category_column_size: usize) { self.print(category, total_stats, category_column_size) } } diff --git a/src/rs/segment.rs b/src/rs/segment.rs index ef3e6ea..5871636 100644 --- a/src/rs/segment.rs +++ b/src/rs/segment.rs @@ -286,7 +286,7 @@ pub(crate) mod python_bindings { #[pymethods] impl super::Segment { #[new] - pub fn py_new(name: String, vram: u64, size: u64, vrom: u64, align: Option) -> Self { + fn py_new(name: String, vram: u64, size: u64, vrom: u64, align: Option) -> Self { Self::new(name, vram, size, vrom, align) } @@ -362,47 +362,47 @@ pub(crate) mod python_bindings { /* Methods */ - pub fn filterBySectionType(&self, section_type: &str) -> Self { + fn filterBySectionType(&self, section_type: &str) -> Self { self.filter_by_section_type(section_type) } - pub fn getEveryFileExceptSectionType(&self, section_type: &str) -> Self { + fn getEveryFileExceptSectionType(&self, section_type: &str) -> Self { self.get_every_file_except_section_type(section_type) } - pub fn findSymbolByName( + fn findSymbolByName( &self, sym_name: &str, ) -> Option { self.find_symbol_by_name(sym_name) } - pub fn findSymbolByVramOrVrom( + fn findSymbolByVramOrVrom( &self, address: u64, ) -> Option { self.find_symbol_by_vram_or_vrom(address) } - pub fn mixFolders(&self) -> Self { + fn mixFolders(&self) -> Self { self.mix_folders() } #[pyo3(signature=(print_vram=true, skip_without_symbols=true))] - pub fn toCsv(&self, print_vram: bool, skip_without_symbols: bool) -> String { + fn toCsv(&self, print_vram: bool, skip_without_symbols: bool) -> String { self.to_csv(print_vram, skip_without_symbols) } - pub fn toCsvSymbols(&self) -> String { + fn toCsvSymbols(&self) -> String { self.to_csv_symbols() } #[pyo3(signature=(print_vram=true, skip_without_symbols=true))] - pub fn printAsCsv(&self, print_vram: bool, skip_without_symbols: bool) { + fn printAsCsv(&self, print_vram: bool, skip_without_symbols: bool) { self.print_as_csv(print_vram, skip_without_symbols) } - pub fn printSymbolsCsv(&self) { + fn printSymbolsCsv(&self) { self.print_symbols_csv() } diff --git a/src/rs/symbol.rs b/src/rs/symbol.rs index 0763d2e..e94457b 100644 --- a/src/rs/symbol.rs +++ b/src/rs/symbol.rs @@ -139,7 +139,7 @@ pub(crate) mod python_bindings { impl super::Symbol { #[new] #[pyo3(signature=(name,vram,size=None,vrom=None,align=None))] - pub fn py_new( + fn py_new( name: String, vram: u64, size: Option, @@ -283,37 +283,37 @@ pub(crate) mod python_bindings { /* Methods */ - pub fn getVramStr(&self) -> String { + fn getVramStr(&self) -> String { self.get_vram_str() } - pub fn getSizeStr(&self) -> String { + fn getSizeStr(&self) -> String { self.get_size_str() } - pub fn getVromStr(&self) -> String { + fn getVromStr(&self) -> String { self.get_vrom_str() } - pub fn getAlignStr(&self) -> String { + fn getAlignStr(&self) -> String { self.get_align_str() } #[staticmethod] - pub fn toCsvHeader() -> String { + fn toCsvHeader() -> String { Self::to_csv_header() } - pub fn toCsv(&self) -> String { + fn toCsv(&self) -> String { self.to_csv() } #[staticmethod] - pub fn printCsvHeader() { + fn printCsvHeader() { Self::print_csv_header() } - pub fn printAsCsv(&self) { + fn printAsCsv(&self) { self.print_as_csv() } diff --git a/src/rs/symbol_comparison_info.rs b/src/rs/symbol_comparison_info.rs index a7ecb13..4e684d5 100644 --- a/src/rs/symbol_comparison_info.rs +++ b/src/rs/symbol_comparison_info.rs @@ -76,7 +76,7 @@ pub(crate) mod python_bindings { impl super::SymbolComparisonInfo { #[new] #[pyo3(signature = (symbol, build_address, build_file, expected_address, expected_file))] - pub fn py_new( + fn py_new( symbol: symbol::Symbol, build_address: u64, build_file: Option, From 1ecc74fec8baea1593f28ef6363d91909aef060f Mon Sep 17 00:00:00 2001 From: angie Date: Fri, 9 Aug 2024 13:05:43 -0400 Subject: [PATCH 13/14] version bump --- CHANGELOG.md | 3 +++ Cargo.lock | 2 +- Cargo.toml | 2 +- README.md | 4 ++-- pyproject.toml | 2 +- src/mapfile_parser/__init__.py | 4 ++-- 6 files changed, 10 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 51392c1..b2a85f8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [2.5.0] - 2024-08-09 + ### Added - Add Minimal Supported Rust Version (MSRV) to Cargo.toml. @@ -364,6 +366,7 @@ Full changes: "] diff --git a/README.md b/README.md index ad1cdb8..cad04a0 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ If you use a `requirements.txt` file in your repository, then you can add this library with the following line: ```txt -mapfile_parser>=2.4.0,<3.0.0 +mapfile_parser>=2.5.0,<3.0.0 ``` #### Development version @@ -74,7 +74,7 @@ cargo add mapfile_parser Or add the following line manually to your `Cargo.toml` file: ```toml -mapfile_parser = "2.4.0" +mapfile_parser = "2.5.0" ``` ## Versioning and changelog diff --git a/pyproject.toml b/pyproject.toml index 39df286..7010282 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ [project] name = "mapfile_parser" -version = "2.4.1-dev0" +version = "2.5.0" description = "Map file parser library focusing decompilation projects" readme = "README.md" requires-python = ">=3.8" diff --git a/src/mapfile_parser/__init__.py b/src/mapfile_parser/__init__.py index 6b104a7..6b7c6be 100644 --- a/src/mapfile_parser/__init__.py +++ b/src/mapfile_parser/__init__.py @@ -5,8 +5,8 @@ from __future__ import annotations -__version_info__ = (2, 4, 1) -__version__ = ".".join(map(str, __version_info__)) + "-dev0" +__version_info__ = (2, 5, 0) +__version__ = ".".join(map(str, __version_info__))# + "-dev0" __author__ = "Decompollaborate" from . import utils as utils From bee4905563be78e172973807549197f9af9da0cb Mon Sep 17 00:00:00 2001 From: angie Date: Fri, 9 Aug 2024 13:07:14 -0400 Subject: [PATCH 14/14] fmt --- .github/workflows/publish_crate.yml | 6 +++--- src/rs/mapfile.rs | 5 +---- src/rs/segment.rs | 5 +---- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/.github/workflows/publish_crate.yml b/.github/workflows/publish_crate.yml index 45428f7..a2ef8b3 100644 --- a/.github/workflows/publish_crate.yml +++ b/.github/workflows/publish_crate.yml @@ -22,7 +22,7 @@ jobs: run: cargo fmt --check check_clippy: - name: Check clippy + name: Check clippy: no features runs-on: ubuntu-latest steps: @@ -42,7 +42,7 @@ jobs: run: cargo clippy --all-targets -- -D warnings check_clippy_serde: - name: Check clippy + name: Check clippy: features: serde runs-on: ubuntu-latest steps: @@ -62,7 +62,7 @@ jobs: run: cargo clippy --all-targets --features serde -- -D warnings check_clippy_all_features: - name: Check clippy + name: Check clippy: features: all runs-on: ubuntu-latest steps: diff --git a/src/rs/mapfile.rs b/src/rs/mapfile.rs index 7ed5bb4..fe40a82 100644 --- a/src/rs/mapfile.rs +++ b/src/rs/mapfile.rs @@ -841,10 +841,7 @@ pub(crate) mod python_bindings { self.get_every_file_except_section_type(section_type) } - fn findSymbolByName( - &self, - sym_name: &str, - ) -> Option { + fn findSymbolByName(&self, sym_name: &str) -> Option { self.find_symbol_by_name(sym_name) } diff --git a/src/rs/segment.rs b/src/rs/segment.rs index 5871636..2137c72 100644 --- a/src/rs/segment.rs +++ b/src/rs/segment.rs @@ -370,10 +370,7 @@ pub(crate) mod python_bindings { self.get_every_file_except_section_type(section_type) } - fn findSymbolByName( - &self, - sym_name: &str, - ) -> Option { + fn findSymbolByName(&self, sym_name: &str) -> Option { self.find_symbol_by_name(sym_name) }