refactor Emu/Config god objects: add OperatingSystem enum, persist ELF/Mach-O, remove dead fields#167
Merged
sha0coder merged 1 commit intosha0coder:mainfrom Apr 6, 2026
Merged
Conversation
…F/Mach-O, remove dead fields
Structural cleanup of the two largest structs (Emu, Config, SerializableEmu):
**OperatingSystem enum replaces linux/macos bools**
- Add `OperatingSystem { Windows, Linux, MacOS }` enum to arch/mod.rs
- Replace `emu.linux: bool` + `emu.macos: bool` with `emu.os: OperatingSystem`
- Windows is now an explicit variant instead of implicit `!linux && !macos`
- Update all 27 conditional sites across instruction_pointer, operands,
syscall, svc, int handlers, and tests
**Persist ELF/Mach-O structs on Emu (parity with PE)**
- Add `elf32: Option<Elf32>`, `elf64: Option<Elf64>`, `macho64: Option<Macho64>`
to Emu, matching the existing pe32/pe64 pattern
- Loaders now store parsed binary structs instead of dropping them after load
- Add `addr_to_symbol: HashMap<u64, String>` to Macho64 struct, populated
during dylib loading — replaces the standalone `emu.macho_addr_to_symbol`
**Remove dead fields**
- Remove `mnemonic: String` — never written, actual mnemonic comes from
`ins.mnemonic()`. Fix emu_context.rs to use instruction.mnemonic() instead
- Remove `aarch64_instruction: Option<Instruction>` — was set but never read
**Organize structs with section comments**
- Group Emu fields into: Configuration, Memory, Instruction decoding,
Core execution, Platform & binary, Threads, API interception,
Debugging, Tracing, Resource management
- Group Config fields into: Binary & arch, Memory layout, Heap behavior,
Tracing, Verbosity, Console, Execution limits, API emulation,
Threading, Inspection, Dump, Environment constants, Testing
- Group SerializableEmu to match Emu layout, with a dedicated
"Flattened thread context" section for fields extracted at serialize time
- Add NOTE comments documenting fields intentionally not serialized
- Simplify SerializableEmu::Default to delegate to From<&Emu>
**Nix flake**
- Add flake.nix/flake.lock for reproducible Rust dev shell
- Per-system target lists (Linux vs macOS)
- Document nix develop in AGENTS.md
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Structural cleanup of the two largest structs (Emu, Config, SerializableEmu):
OperatingSystem enum replaces linux/macos bools
OperatingSystem { Windows, Linux, MacOS }enum to arch/mod.rsemu.linux: bool+emu.macos: boolwithemu.os: OperatingSystem!linux && !macosPersist ELF/Mach-O structs on Emu (parity with PE)
elf32: Option<Elf32>,elf64: Option<Elf64>,macho64: Option<Macho64>to Emu, matching the existing pe32/pe64 patternaddr_to_symbol: HashMap<u64, String>to Macho64 struct, populated during dylib loading — replaces the standaloneemu.macho_addr_to_symbolRemove dead fields
mnemonic: String— never written, actual mnemonic comes fromins.mnemonic(). Fix emu_context.rs to use instruction.mnemonic() insteadaarch64_instruction: Option<Instruction>— was set but never readOrganize structs with section comments
Nix flake