Skip to content

Debugger Configurations

NitinKM edited this page Mar 11, 2023 · 26 revisions

This page can provide additional debugger configurations beyond the ones shipped by default in Helix.

Install Debuggers

Codelldb GitHub release (latest by date)

linux (tested in ubuntu):

Access your user folder.

cd ~

Check the architecture of the cpu to later download the correct version of codelldb.

lscpu | grep -oP 'Architecture:\s*\K.+'

create a folder named bin and access it.

mkdir bin && cd bin

Will download codelldb through curl. ( .vsix can be opened as .zip ).

sudo curl -L "https://github.com/vadimcn/vscode-lldb/releases/download/v1.7.0/codelldb-x86_64-linux.vsix" -o "codelldb-x86_64-linux.zip"

Unzip only the necessary folders, in this case extension/adapter and extension/lldb.

unzip "codelldb-x86_64-linux.zip" "extension/adapter/*" "extension/lldb/*"

Rename the extension/ folder to codelldb_adapter/

mv extension/ codelldb_adapter

Delete the unneeded codelldb-x86_64-linux.zip at this time.

sudo rm "codelldb-x86_64-linux.zip"

Create the symlink from codelldb_adapter/adapter/codelldb to /usr/bin/codelldb and you're done.

ln -s codelldb_adapter/adapter/codelldb /usr/bin/codelldb

Test: codelldb -h

Configure Debuggers

Rust (with codelldb)

Helix supports debugging Rust, by default, with lldb-vscode, which is part of llvm/lldb.

However, you can also use vscode-lldb's adapter named codelldb. (Note, the names can be confusing. vscode-lldb is a separate project from the aforementioned lldb-vscode.)

[[language]]
name = "rust"

[language.debugger]
command = "codelldb"
name = "codelldb"
port-arg = "--port {}"
transport = "tcp"

[[language.debugger.templates]]
name = "binary"
request = "launch"
[[language.debugger.templates.completion]]
completion = "filename"
name = "binary"

[language.debugger.templates.args]
program = "{0}"
runInTerminal = true

Test with: debug-start binary target/debug/zellij, for example. Status: start/stop debugging works, breakpoints work

Addendum: For users who can't make any of the above work

To simply install the default debugger that will work out of the box you need to:

  1. Install LLVM.

The easiest way to do this is to use the pre-compiled binaries from the releases page: https://github.com/llvm/llvm-project/releases, for example, at the time of writing the latest version for Linux is: https://github.com/llvm/llvm-project/releases/download/llvmorg-15.0.2/clang+llvm-15.0.2-x86_64-unknown-linux-gnu-rhel86.tar.xz

  1. Unpack the entire directory somewhere accessible in your system $PATH and create a symbolic link.

If you have ~/bin in your path then unpack LLVM there and make a symlink to the lldb-vscode file that lives in the bin directory.

Screenshot from 2022-10-12 19-43-46

Now when you run the debugger in Helix select launch debug target and binary, then for example, to debug Rust, target/debug/ and the name of your executable.

MacOS users

  1. Install LLVM: brew install llvm
  2. Add /usr/local/opt/llvm/bin your PATH, usually in your ~/.bashrc or .zshrc file.
  3. Restart your shell

Addendum 2: For users who installed a debugger successfully but cannot attach to a running process

If on Linux, trying to attach to a running process for debugging and being refused by the adapter due to a message similar to Operation not permitted, ensure ptrace is not blocking you. This can be done by following this Microsoft troubleshooting guide.

Summary of steps needed to be done are one of:

  1. Ensure /proc/sys/kernel/yama/ptrace_scope has a 0 as value, instead of 1
  2. If the file is not present or Yama is not used, use libcap2-bin to assign ptrace specific permissions to the debug adapter (overriding the command used by Helix, usually set in a languages.toml file).
Clone this wiki locally