-
-
Notifications
You must be signed in to change notification settings - Fork 156
Improve debugging configuration (displaying local variables, etc) #45
Comments
Thanks for the issue. I'll check out what vscode does to see if its any different |
fwiw, does vimspector work any different? |
Haven't played around with vimspector much, so I can't tell you. I think I remember it working better though, yes. It relies on the VSCode stuff more directly as far as I can tell, so it might make use of the same logic. In general, I'd love to see the "standard" that neovim debugging tries to reach to stay the best-case (VSCode) rather than the best-case-in-vim (vimspector) - and of course, to at some point become "nvim-dap with rust-tools.nvim" ^^ |
Okay - My colleague and I have spent a day playing with our nvim/rust experience and I think we have a handle on this. At the root of it, the key discovery is that vscode-lldb extension is not using lldb-vscode from LLVM. It has its own adapter which does its own interpretation/understanding of rust structures. So yes, you can launch lldb-vscode and ask to debug rust, and you will get unintelligible structures back like everybody is presently seeing. You can also launch the wrapper that the vscode-lldb extension includes in its repo, and use that instead, resulting in the expected/desired pretty printing. An example of this can be found over on my fork of rust-tools.nvim robashton@64af191 In that case, codelldb is the wrapper that the vscode-lldb extension uses for dap. (It is actually a wrapper of that wrapper, as the wrapper would like to know where lldb is located and I am using nixos and this becomes a bit of a dance).
That itself was generated in my nix config using the following runes
I've not sent this as a pull request because quite frankly, I don't know that this is what you want in rust-tools.nvim - a dependency on a VS code extension and having to build that in a way that it was not designed to be built. But it does answer the above question as to why the behaviour in VSCode is different to everything else using lldb-vscode. It is nice having the above code set up, as it means the rust-tools integration for debugging from the menu just works, perhaps allowing override how that rt_lldb is setup might be useful, or some other option. I'll be interested in what opinions are floating around over this, I don't have strong ones of my own - perhaps reaching out to the author of the VScode extension might be fruitful. |
(As an addendum, as stated above - this is precisely what vimspector is doing, so there is indeed precedence https://github.com/puremourning/vimspector#rust ) |
I think the optimal solution would be the ability to customize the default adapter, this way people who wanna use the wacky setup of Codelldb can do so |
wacky setup is about right - it might be more palatable if the adapter was packaged as a thing in its own right and didn't need the janky lldb setup, it would also be somewhat better if the adapter could run using stdio instead of having to spawn it up and then connect to it as a server - but these things are what they are and it has no doubt been done how it is done because it is convenient and easy to do this in the original environment for which it was designed (the VS code experience is very good out of the box, having spun it up to compare whilst investigating this). Being able to simply supply/override the adapter setup seems ideal to me - the most important thing here is that the codelldb setup was at least documented, as searching around yielded plenty of results where people wanting this, without any solutions actually forthcoming! |
Oke we can customize the default adapter now. I'll update the readme once I get a handle on how this stuff actually works, or if you're down for it, feel free to send a PR! |
neat - I'll pull down latest, update my config and see what's what |
I'll add this as a helper function. |
https://github.com/simrat39/rust-tools.nvim#a-better-debugging-experience |
Oh nice! I’ll update my config and try it out when I’m next at a computer |
Hi, I am going to edit the nvim-dap wiki. Also, is there any way to reuse the adapter definitions from nvim-dap, without redefining them in the rust-tools config? |
Well you can use the adapter or that function wherever you want, just do a require('blah blah').blah(). rust-tools uses the adapter provided in the config so you need to read your adapter from dap and put it to rust-tools' config. |
Also the wiki looks good on a quick glance! |
I found the Better-Debugging config from the README and re-using my nvim-dap adapter definition to not work, when looking for The error message is still Looking through the source code, I found this section, that looks for the rust-tools.nvim/lua/rust-tools/dap.lua Lines 93 to 96 in c2aacb9
When using a custom adapter, the hardcoded binary name and the presence in PATH might not be given, e.g. the |
Also, thanks for your feedback on the wiki |
@lasse16 yes I should probably remove that |
We now support codelldb as well, no need for this #45
👍 CodeLLDB and Debuggables are working on my setup. Just in case anybody else stumbles on this thread. require'rust-tools'.setup({
-- ...
-- rust tool setup
-- ...
dap = {
adapter = require('dap').adapters.lldb
}
}) |
That's great, I'll close this in a couple of days |
Closing because the stuff is done 👍 |
This all looks really nice indeed, thanks a lot already! However, trying the setup mentioned in the readme and trying to start a debugging session, I just get |
Don't know if I can really help here. 😅 I am using reusing the setup from Feel free to reference my dotfiles, if you want to copy my setup. |
@elkowar could you show your rust-tools config please? |
@simrat39 i hope the Fennel here is basic enough to understand: https://github.com/elkowar/dots-of-war/blob/a7b6ba71df915da879a909f5cbb6a7e1200f9284/nvim/.config/nvim/fnl/dots/plugins/lsp.fnl#L100 |
@elkowar the config looks fine. Could you try running the codelldb adapter from your terminal and see what it outputs? |
I tested the function from the README on my setup and it is working. Check PR #75, I added the logging mechanism to Should also note, that the |
elkowar/dots-of-war@0d87f0c wow I'm stupid, I'll go find a corner to hide in ^^ |
I didn't see that, and I honest to god thought "I wonder if it's just a typo" and explicitly checked those two lines |
Rust is known to be,... difficult with dap.
rust-lldb
apparently promises to aid the formatting and displaying of variables, although documentation on that is sparse.For reference, currently values like strings or enums are diplayed like this:
which is obviously suboptimal.
Firstly, the string content is displayed,... badly.
secondly, the value of an enum variable is completely invisible.
Looking through several repos and projects where this has been discussed, it always sounds as though there was some solution that some people manage to get to work, although I've not yet found any concrete "this is what you need to do" solution that I could provide and propose here.
Rust-tools uses lldb-vscode for their debugging.
Looking at the rust langauge support section of the CodeLLDB repo, proper displaying of these values is promised. Surely enough, in VSCode, values do actually get shown correctly.
I'm not quite sure if this means that there is some magic that the VSCode plugin does on top of lldb-vscode to manipulate how the data is shown / sourced, or if this is achieved by some magical configuration that can be passed to lldb-vscode directly.
Given that setting this up for nvim-dap seems to be an unsolved problem currently, the rust-tools.nvim project might be the chance to figure out a reference solution for this, and then potentially upstream that to the nvim-dap repo itself.
This is not a concrete proposal, but just me throwing out some thoughts and hoping that someone more knowledgeable about the debug adapter situation will read this ^^' I played around with the mentioned
"sourceLanguages": ["rust"]
option, but that alone did not change anything for me at least.The text was updated successfully, but these errors were encountered: