Repository navigation
Description
What
readMemory, gated bysupportsReadMemoryRequest.writeMemory, gated bysupportsWriteMemoryRequest.- The
memoryevent, which needs the client capabilitysupportsMemoryEvent. memoryReferenceon Variable, EvaluateResponse, SetVariableResponse and SetExpressionResponse. Per the spec it "may be returned by a debug adapter if corresponding capabilitysupportsMemoryReferencesis true", a client capability.- Details: data is base64, offsets can be negative,
unreadableBytes,allowPartial.
Why
Read and write:
- Both: vscode-js-debug (
debugAdapter.ts:308-309), CodeLLDB (debug_session.rs:617,:622), lldb-dap (RequestHandler.h:622,:673), Delve (server.go:1034-1035), GDB (dap/memory.py). - Read only: MIEngine (
AD7DebugSession.cs:1091,:3156).
memoryReference:
- js-debug: on typed arrays, DataView, ArrayBuffer and WebAssembly memory (
variableStore.ts:64-69,:906). - CodeLLDB: on variables and evaluate, only when the client sends
supportsMemoryReferences(debug_session/variables.rs:397). - lldb-dap: on variables, evaluate and setVariable.
- Delve: on child variables (
server.go:3023). - GDB: on pointers, only with
supportsMemoryReferences(dap/varref.py:254-264). - MIEngine: on pointers and arrays.
memory event: lldb-dap only, after setVariable, and only with supportsMemoryEvent (EventHelper.cpp:404-412).
None of this: debugpy, netcoredbg, rdbg, java-debug.
What users miss: seeing and changing the bytes behind a pointer, buffer or array, in C, C++, Rust, Go, WebAssembly or JavaScript typed arrays. In VS Code, "View Memory" on a variable with memoryReference opens the Hex Editor extension (variablesView.ts:734-783).
Today
- LSP4IJ sends neither
supportsMemoryReferencesnorsupportsMemoryEvent(DebugAdapterDescriptor.java:232-251). So CodeLLDB and GDB send nomemoryReference. - The others send it, but LSP4IJ uses memory references only for disassembly, from the frame's
instructionPointerReference(DisassemblyFile.java:105).memory()is not overridden. - IntelliJ IDEA has no hex memory view:
com.intellij.xdebugger.memory.*in both versions is the Java "Memory" view of instance counts (MemoryViewManager,InstancesTracker);- no hex or memory viewer class is in 2026.3's
lib/jars.
- CLion and RustRover have a Memory View of their own; Address editor in RustRover's Memory View tab triggers LSP requests #560 is about its address field in RustRover. Whether a debug process that isn't CIDR's can use it was not checked: no CLion or RustRover distribution was available.
How it could be done
Capabilities and data:
- Set
supportsMemoryReferences = true. SetsupportsMemoryEvent = trueonce the event is handled. - Keep
memoryReference:DAPDebuggerEvaluatordrops it today (DAPDebuggerEvaluator.java:124).DAPValueModifiershould copy it from thesetVariableanswer.
The action:
- Add an action
DAP.ViewMemory, "View Memory", inXDebugger.ValueGroup. That group exists in both versions, and LSP4IJ already addsDAP.HexadecimalValuesandDAP.BreakOnValueChangeto it. - It is enabled when the selected value has a
memoryReferenceand its client supportsreadMemory. Find the value withDAPBreakOnValueChangeAction.getValue(DataContext), which already handles the 2025.3+ split UI through reflection.
The memory editor, built like the disassembly view (DisassemblyFile and DisassemblyFileEditorProvider):
- a
LightVirtualFileper client and memoryReference, opened withFileEditorManager.openFile(VirtualFile, boolean)(both versions); - a read-only document with lines of address, 16 hex bytes and ASCII; unreadable bytes show as
??; - pages of 1 to 4 KiB read with
readMemory(memoryReference, offset, count), and more when scrolling. Offsets can be negative. - The address column comes from
ReadMemoryResponse.address. Its width could come from thepointerSizeof the Process event (DAP: handle the process event #2114).
Refresh:
- at each stop of that client (
XDebugSessionListener.sessionPaused, both versions); - on a
memoryevent whose range overlaps what is shown; - shown as out of date while the program runs;
- closed or disabled when the client ends.
Write, with supportsWriteMemoryRequest:
- "Write Bytes…" on a selection, typed in hex, calls
writeMemory(memoryReference, offset, base64, allowPartial = false). - On a partial write, show
bytesWritten. - Then call
session.rebuildViews(), or rely on the adapter'sinvalidated.
Threading: requests run off the EDT; document changes happen in a write action on the EDT.
Multi-session: a memoryReference belongs to the client, possibly a child session, that returned it.
Later step: disassemble from a function pointer's memoryReference. The spec says "For executable data, this reference may later be used in a disassemble request".
Compatibility: the action is hidden without a reference or the capability. Behaviour change: CodeLLDB and GDB add memoryReference fields once the flag is set.
Test
- Unit tests: the hex dump layout, base64,
unreadableBytes, page offsets, and the overlap check for the event. - Session test: an in-process server backed by a byte array.
- A variable with
memoryReferenceenables the action. - Check the
readMemoryrequests and the document text, and thewriteMemoryarguments. - A
memoryevent reloads the view.
- A variable with
- Initialize arguments: both new flags are set, in the style of
DebugAdapterDescriptorTest.
Effort and risk
Large: a new editor, paging and editing. Medium UI risk. Open questions:
- Ship read-only first?
- How should editing work?
- Can this plug into CLion's and RustRover's Memory View?
- Size limits?
Related: #560 and #601 (an LSP-side fix for RustRover's Memory View address field).
Activity
feat: show the process which a DAP session debugs, with its PID, in t…