-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Debugger: Show local variables as values, they are currently reported as memory addresses #7007
Comments
We can ask Add the following to [[language]]
name = "rust"
[language.debugger]
name = "lldb-vscode"
transport = "stdio"
command = "lldb-vscode"
[[language.debugger.templates]]
name = "binary"
request = "launch"
completion = [ { name = "binary", completion = "filename" } ]
args = { program = "{0}", initCommands = [ "command script import /opt/homebrew/Cellar/rust/1.71.0/lib/rustlib/etc/lldb_lookup.py", "command source -s 0 /opt/homebrew/Cellar/rust/1.71.0/lib/rustlib/etc/lldb_commands" ] } and voila: |
Nice start but won't work for the majority of people and will break even on your system anytime soon as you're specifying a versioned path into a homebrew install on AppleSilicon. Most people will likely install via rust-up (which goes to The path you want to pass to lldb-vscode is Just leaves the problem that AFAIK neither helix nor lldb-vscode evaluate bash inlines. [EDIT] - a workaround to get a version-independent path that tries to stay semi up-to-date: Add this at the end of your # provide a version independent link to rustlib for the currently active rustc
rm -f "$HOME/.local/lib/rustlib" && mkdir -p "$HOME/.local/lib" && ln -s "$(rustc --print sysroot)/lib/rustlib" "$HOME/.local/lib/rustlib" Then use this path for your languages.toml (replace PATH_TO_YOUR_HOME with whatever your $HOME is, sadly couldn't get around that part): args = { program = "{0}", initCommands = [ "command script import /PATH_TO_YOUR_HOME/.local/lib/rustlib/etc/lldb_lookup.py", "command source -s 0 /PATH_TO_YOUR_HOME/.local/lib/rustlib/etc/lldb_commands" ] } |
The goal here is to find out how to pass these script/command to I will update the wiki based on your suggestion. |
You're right, I'm over-all a bit unhappy with having to have a symlink that my shell profile updates as it doesn't cover for those cases where - on the off chance - I update my rust version or switch the active rust version. In an ideal world we would be able to have some way to tell helix to expand environment variables or execute backtick or inline shell statements so the line could really be reduced to Thank you for updating the wiki - I think rust debugging is one of the more asked-for topics in Helix :) |
@quantonganh - I am so sorry for pinging yet again bit I believe I found an even more elegant solution that also gets rid of the downsides of creating a symlink. Copy this python snippet to import subprocess
import pathlib
import lldb
# determine the sysroot for the active rust interpreter
rustlib_etc = pathlib.Path(subprocess.getoutput('rustc --print sysroot')) / 'lib' / 'rustlib' / 'etc'
if not rustlib_etc.exists():
raise RuntimeError('Unable to determine rustc sysroot')
# load lldb_lookup.py and execute lldb_commands with the correct path
lldb.debugger.HandleCommand(f"""command script import "{rustlib_etc / 'lldb_lookup.py'}" """)
lldb.debugger.HandleCommand(f"""command source -s 0 "{rustlib_etc / 'lldb_commands'}" """) And then use this configuration for helix: [[language]]
name = "rust"
[language.debugger]
name = "lldb-vscode"
transport = "stdio"
command = "lldb-vscode"
[[language.debugger.templates]]
name = "binary"
request = "launch"
completion = [ { name = "binary", completion = "filename" } ]
args = { program = "{0}", initCommands = [ "command script import /usr/local/etc/lldb_vscode_rustc_primer.py" ] } The script takes care of querying the correct rustc sysroot and loading the bindings right at the moment when lldb-vscode is started and is 100% independent of symlinks or ARM / Intel / rust-up or homebrew setups as long as you have rustc in your system path. |
@Shirk Nice solution. Would you mind updating the wiki? |
Revisiting this due to a name change for lldb-vscode. Since now it is called lldb-dap, at least on arch, i simply had to replace lldb-vscode with lldb-dap like so: [[language]]
name = "rust"
[language.debugger]
name = "lldb-dap"
transport = "stdio"
command = "lldb-dap"
[[language.debugger.templates]]
name = "binary"
request = "launch"
completion = [ { name = "binary", completion = "filename" } ]
args = { program = "{0}", initCommands = [ "command script import /usr/local/etc/lldb_vscode_rustc_primer.py" ] } &str is correctly resolved as a string instead of showing the memory address |
@David-Else with the latest version it is indeed picking up the lldb-dap command by default. However by default without the command script import lldb-dap does not resolve variables values but returns the memory address. With the command script import local variables values are resolved for simple types. I simply updated the configuration provided by @HealsCodes to work with the lldb-dap command instead that with lldb-vscode. |
@cino189 Cool. I was just thinking you didn't need to copy out anything from https://github.com/helix-editor/helix/blob/6cca98264fe308bd6a4f7f85be2d821b58f60b4a/languages.toml#L260C1-L281C23 as it is all inherited. Just overwrite the sections in need of an update. I know it seems a bit OCD, but then if the config changes in the main repo you won't get caught out. |
I understand that the debugger is experimental, but surely it is useless at the moment if we can't see the value of the variables?
Everything else seems to work, this one fix would make the debugger very useful. Why has it been left in this state, are the memory addresses useful to some people?
The text was updated successfully, but these errors were encountered: