- 
                Notifications
    You must be signed in to change notification settings 
- Fork 2.2k
dap: implement readMemory for strings and expose memoryReference #4083
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| SupportsVariablePaging bool `json:"supportsVariablePaging,omitempty"` | ||
| SupportsRunInTerminalRequest bool `json:"supportsRunInTerminalRequest,omitempty"` | ||
| SupportsMemoryReferences bool `json:"supportsMemoryReferences,omitempty"` | ||
| SupportsReadMemoryRequest bool `json:"supportsReadMemoryRequest,omitempty"` | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can't change vendored packages like this, you need to make a PR to google/go-dap first.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeap, i know, i did google/go-dap#94
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great!
| LGTM but held because we need the go-dap change. | 
| Hi @aarzilli I think the go tools team is the maintainer of google/go-dap, I will discuss this within the team and review the PR and CL that @MistaTwista drafted. | 
| sorry for inconvenience with go-dap PR. I closed it because it looks like we don't need those changes here 😐 | 
| Many tests fail. | 
| PS. the TODO on line service/dap/server.go:841 needs to be removed. | 
| Hey @aarzilli, I’ve fixed the previously failing tests and also added a new one for my changes to be sure everything works. The main idea of this new test is to generate a large JSON payload, retrieve it from the Delve server via the read-memory request page-by-page, compute a hash, and compare it with the original hash to ensure there are no duplicates or missing data. All tests pass locally, but the CI still fails for my test with: === RUN   TestReadMemory_StringPagination
Error compiling ../../_fixtures/readmem_json.go: wait6: no child processes
FAIL	github.com/go-delve/delve/service/dap	50.196s
?   	github.com/go-delve/delve/service/dap/daptest	[no test files]
?   	github.com/go-delve/delve/service/dap/daptest/gen	[no test files]It seems like an environment difference between my setup and the CI runner, and I can’t reproduce it locally. Do you have any idea what might be wrong? | 
| I think the reason the tests do not pass is just because your branch is fairly old and needs to be rebased. | 
| 
 Ok, I'll rebase it and try again, thanks 
 I'm not sure I understand you correctly. In the description of the original issue I showed what functionality I'm trying to archive in vscode and why. And this comment is about why I’m proposing delve changes. | 
| So, this would also require a change to vscode? | 
| not vscode itself, but vscode-go plugin for vscode golang/vscode-go#3818 | 
c841fe0    to
    e04d4b8      
    Compare
  
    There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was looking over the DAP specification again and it occurs to me that memory references are used in one other place in the spec: for disassembly.
I think it would be prudent to put memory references for disassembly and the ones for the memory of variables in the same address space, in case clients expects them to be. That would mean that instead of using a sequential number to number memory references you just send the address of the variable formatted into a string.
06034a4    to
    efcb70a      
    Compare
  
    | 
 done 👌 test is also updated for the new format, but still there are some issues | 
| I don't know why your test is failing like that on freebsd, there is no obvious problem that would lead to that. I think it's fine to just add a skip for freebsd ( | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
| The []byte variable, sure, not the  | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
| 
 Do I need to do something (like rebase to current master) or just wait until merge? | 
| Just wait. | 
| @MistaTwista this patch does need a rebase now. After the rebase I will merge. | 
868991c    to
    a6fb2e6      
    Compare
  
    | Done, would you like me to squash the commits, or should I improve the commit messages for better documentation? | 
- enable setting SupportsReadMemoryRequest in Initialize response - variable listings now include MemoryReference for strings and slices - implement Session.onReadMemoryRequest handling for readMemory requests
a6fb2e6    to
    0db7dce      
    Compare
  
    | fixed conflict with master, squashed commits, made better description of a commit | 





Motivation
Large Go strings are still truncated in common debugging workflows (variables view uses ~512 chars; hover / “Copy Value” use ~4096 chars). That’s often not enough for JSON payloads, logs, etc., and users rely on awkward workarounds (manual slicing, multiple reads).
Adding DAP readMemory enables clients to page the underlying bytes on demand and render full values.

Fixes: #4084
Vscode-go feature: golang/vscode-go#3817