- pkg/disass/colors.go: move 3 regexps compiled on every ColorOperands() call to package-level vars
- pkg/emu/disass.go: move 2 regexps compiled on every colorOperands() call to package-level vars
- pkg/ota/aa.go: move 6 regexps compiled per file per Info() loop iteration to package-level vars
- pkg/plist/plist.go: replace in-loop regexp with strings.HasSuffix; drop regexp import
- pkg/devicetree/devicetree.go: replace 6 in-loop regexp.MustCompile calls with strings.Contains/HasSuffix; drop regexp import
- pkg/img4/payload.go: compile regexp once before the loop instead of per-iteration
- pkg/dyld/utils.go: add readCStringAt helper to read null-terminated strings via io.ReaderAt (avoids allocating bufio.Reader)
- pkg/dyld/file.go: replace 6 bufio.NewReader allocations in tight inner loops with readCStringAt; drop bufio import
- pkg/dyld/objc.go: replace 2 bufio.NewReader allocations in inner loops with readCStringAt; drop bufio import
- pkg/dyld/image.go: replace bufio.NewReader allocation in inner loop with readCStringAt; drop bufio import
- internal/search/search.go: move 3 regexps compiled per-loop-iteration to package-level vars
- internal/diff/diff.go: move iBoot regexp to package-level var; compile DSC regexp once instead of twice
- internal/commands/ent/replacement.go: replace regexp.MatchString (recompiles every call) and per-call MustCompile with package-level vars
- internal/download/scrape.go: move 7 constant regexp patterns to package-level vars
Co-authored-by: blacktop <6118188+blacktop@users.noreply.github.com>
Agent-Logs-Url: https://github.com/blacktop/ipsw/sessions/44cb516b-6503-478d-bcf6-9f275d78419c
Add API endpoints and CLI support for discovering C++ classes and symbolication of kernelcaches, refactor Mach-O handling, and improve symbol collection.
- API: add /kernel/cpp and /kernel/symbolicate routes, request param structs, response types, and openKernel helper. Use cpp scanner and signature parsing to return classes and symbol maps.
- CLI: wire scanner LogStats flag, refactor kernel symbolicate command (schema writer helper, improved signature parsing, and symbol matching logic). Add tests for symbolicator schema and kernel symbol matching.
- Signature pkg: add kernel C++ symbol extraction (pkg/signature/kernel_cpp.go) and SymbolicateMachO to symbolicate already-open Mach-Os; integrate C++ symbols into symbol map and update signature matching/logging behavior.
- Internal: refactor in-memory DB lookups (findMachOByUUID, findSymbolByAddr) to reduce duplication. Improve symbols collection for kernel Mach-Os (collectKernelMachoSymbols, extra kernel symbols from signature/C++), add helpers to append symbols.
- Kernelcache CPP: add LogStats option and conditional logging of scan stats.
- Crashlog/ips: update wording to reflect kernel symbols are from kernel analysis and store KernelSymbols earlier in processing; parse signatures only when configured.
Also add unit tests for new symbolication helpers and kernel C++ signature handling. Overall this consolidates kernel symbol discovery, improves reuse, and surfaces C++-derived symbols in symbol maps.
Update all disassembly code to use new cgo-based decoder API with
stack-allocated instruction structs instead of heap-allocated
pointers. Add instruction filtering to skip decoding operations that
register tracking doesn't care about, avoiding expensive CGo calls.
Key changes:
- Replace Decompose with DecomposeInto using stack allocation
- Add mayBeTrackedInstruction filter for common tracked ops
- Introduce helper functions for safe operand/register access
- Fix metaclass pointer index to use caller index for efficiency
- Remove root file special-casing in pointer index builder
- Add comprehensive unit tests for tracking options and helpers
- Updated disassembly functions to utilize the new `disassemble.Inst` type instead of `disassemble.Instruction`.
- Modified operand retrieval functions to accommodate the new instruction structure.
- Enhanced error handling and logging for instruction decoding failures.
- Improved JSON output for disassembly to ensure disassembly strings are preserved.
- Refactored various components across the disassembly package, including Mach-O and dyld handling, to streamline instruction processing.
- Added tests to validate the new disassembly behavior and ensure backward compatibility.