Skip to content

[WIP] Enable search during debugging via backend memory map#1120

Draft
xusheng6 wants to merge 1 commit into
devfrom
test_debugger_memory_map
Draft

[WIP] Enable search during debugging via backend memory map#1120
xusheng6 wants to merge 1 commit into
devfrom
test_debugger_memory_map

Conversation

@xusheng6

Copy link
Copy Markdown
Member

Summary

Prototype for #668. Makes Find work during a debug session by mirroring the backend's memory map into the debugger BinaryView as bounded regions, instead of the single blanket overlay [0, UINT64_MAX) that made search either hang or be hard-disabled.

  • When the adapter reports a memory map (DebugAdapter::GetMemoryMap), register one bounded remote region per entry (debugger:N, with R/W/X flags). GetBackedAddressRanges() / GetNextBackedAddress() — which drive Find — then cover only mapped memory.
  • SyncMemoryRegions() runs on every stop but no-ops when the map is unchanged, so single-stepping stays cheap.
  • Adapters that report no map fall back to the blanket "debugger" region, which keeps search disabled gracefully (no 2^64 scan / hang).

Status

Not ready for review. Compiles clean (debugger core + parent core/UI) but not yet run against a live session.

Companion parent-repo change (search-gate warning messages): Vector35/binaryninja test_debugger_memory_map.

Known follow-ups

  • Accessor-backed AddRemoteMemoryRegion is O(N²) per rebuild (rare, since diffed).
  • Retired per-region accessors are only freed at teardown; an incremental diff would fix both this and the O(N²).
  • Design question still open: push the fallback into the adapter (base default returns a full range + an explicit "exact/placeholder" bit) instead of branching on empty in the controller.

🤖 Generated with Claude Code

…while debugging

When a debug adapter reports a memory map (DebugAdapter::GetMemoryMap),
mirror it into the debugger BinaryView as one bounded remote memory
region per entry instead of the single blanket overlay that spans the
whole address space. This makes GetBackedAddressRanges() /
GetNextBackedAddress() (which drive Find) cover only mapped memory, so
search works during a debug session and skips unmapped gaps.

- SyncMemoryRegions() runs on every stop but no-ops when the map is
  unchanged, so single-stepping stays cheap.
- Adapters that report no map fall back to the blanket "debugger" region
  (search stays disabled gracefully instead of hanging on a 2^64 scan).
- Per-region accessors are retired (not freed) on change and drained at
  teardown to avoid use-after-free from in-flight reads.

Prototype; not ready for review. Known follow-ups: accessor-backed
AddRemoteMemoryRegion is O(N^2), and the fallback should likely move into
the adapter (base default returns a full range + an "exact" bit).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant