Open rebelot opened 2 years ago
Edit:
To show disassembled code, the request is actually a source
request, preceded by a settings change provided by an _adapterSettings
request. This might be too specific for codelldb and perhaps require it's own plugin.
How does the disassembly functionality with codelldb look like?
There is a disassemble request in the protocol: https://microsoft.github.io/debug-adapter-protocol/specification#Requests_Disassemble
It takes a memoryReference, which I assume has to be taken from a stackFrame. I'm not sure how to best integrate that from a UI perspective.
I meant using codelldb *$**** extension. Well, the feature I had in mind was to be able to switch source between c/cpp and assembly code and step through that. I thought this was achieved via disassemble request but I'm not sure about it. For UI, there could be a DAP switch_source command?
An update on this:
using https://github.com/vadimcn/vscode-lldb.git
:lua session = require'dap'.session()
:lua session:request('_adapterSettings', { showDisassembly = 'always'})
produces
[2022-04-14T12:28:33.234Z ERROR codelldb::debug_session] Received invalid thread id in stack trace request.
[2022-04-14T12:28:33.234Z ERROR codelldb::debug_session] Internal debugger error: Invalid thread id.
I know this is extremely naive, but just wanted to share some more context
See also https://github.com/vadimcn/vscode-lldb/pull/627, looks like standard DAP conform disassembly request isn't supported yet in codelldb
See also vadimcn/vscode-lldb#627, looks like standard DAP conform disassembly request isn't supported yet in codelldb
Should be coming soon: https://github.com/vadimcn/vscode-lldb/pull/790. FWIW vscode-cpptools (MIEngine) already supports the DAP disassembly.
I also requested some clarifications because the DAP spec for disassembly is baffling:
I did this as part of implementing disassembly and instruction breakpoints for vimspector, which turned out to be a ton of work and the UI is still not ideal. Useful when needed, mostly not needed.
Hope this is useful info if/when you come to implement it :)
Oh nice work. Thanks, this will be very helpful.
the feat seems to be merged: https://github.com/vadimcn/codelldb/pull/790 are there any plans to have this supported in nvim-dap?
I was curious if this would be hard to do so I gave it a shot.
https://github.com/mfussenegger/nvim-dap/assets/10103049/e948e3a8-20fe-4421-9563-b0814693a98e
It's missing highlighting and doesn't perfectly fit the frame but the POC works. Because one could make a case that the disassembly output is dependent on the size of the window, I ended up placing the request directly in nvim-dap-ui rather than in nvim-dap. I could have done it in nvim-dap to request it any time the stack changes or step-{in,out,over} but it seemed like that wasn't the best thing to do because you'd have to assume the size of the request. Or maybe it would have made more sense to just keep requesting more instructions until DisassembledInstruction's line value goes past the current source code line. I'm curious what people think makes more sense. From what I can see vimspector's https://github.com/puremourning/vimspector/blob/831530b85aad02f2c465047a21452409bfaaf784/python3/vimspector/disassembly.py#L243-L249 incorporates window height into the request which further made me think nvim-dap-ui was the better place.
Iirc Vimspector requests about 2 pages of instructions above and below the viewport and modifies that when the window is scrolled. It took some trial and error to tune this.
We would love to see this feature. I am trying to learn Dap protocol in my free time in order to work on this.
@0xWaleed Check out https://github.com/rcarriga/nvim-dap-ui/pull/309. Specifically lua/dapui/components/disassembly.lua
and its uses of client.session
, client.request.disassemble
, and the like. And of course https://github.com/puremourning/vimspector/blob/831530b85aad02f2c465047a21452409bfaaf784/python3/vimspector/disassembly.py#L243-L249, which is what I based it off of.
Problem Statement
It would be great if one could see the disassembled code in a split window. Similarly to codelldb.
Ideas or possible solutions
No response