Skip to content

Using CodeLLDB as default debuggers for rust #550

@ClSlaid

Description

@ClSlaid

Feature description

lldb-vscode is the vscode-dap wrapped version of lldb, it does embed with pretty print features, making commonly used rust data structures like std::string::String, std::sync::Arc, std::collections::Vec hard to read.

This is an example of the view of &str, all static string in the executable image came out together, too much noise!

图片

Switching to CodeLLDB, that's much usable.

图片

Additional information

I've been using codelldb on my customized branch, but I don't know how to ensure the users will have a local image of codelldb. What I can do is paste my configuration here as an example:

-- lua/modules/tools/dap/dap-lldb.lua

-- other configurations
local codelldb_port = "65472"
dap.adapters.codelldb = {
	type = "server",
	port = codelldb_port,
	executable = {
		command = os.getenv("HOME") .. "/" .. ".local/share/nvim/mason/bin/codelldb", -- installed with mason
		args = { "--port", codelldb_port },
	},
	name = "codelldb",
}
-- copy from cpp with custom type
dap.configurations.rust = {
	{
		name = "Launch",
		type = "codelldb",
		request = "launch",
		program = function()
			return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file")
		end,
		cwd = "${workspaceFolder}",
		stopOnEntry = false,
		args = function()
			local input = vim.fn.input("Input args: ")
			return vim.fn.split(input, " ", true)
		end,

		-- if you change `runInTerminal` to true, you might need to change the yama/ptrace_scope setting:
		--
		--    echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope
		--
		-- Otherwise you might get the following error:
		--
		--    Error on launch: Failed to attach to the target process
		--
		-- But you should be aware of the implications:
		-- https://www.kernel.org/doc/html/latest/admin-guide/LSM/Yama.html
		runInTerminal = false,
	},
}
-- lua/modules/config/lang/rust-tools.lua

-- other configurations
    dap = {
        adapter = require("nvim-dap").adapters.codelldb,
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    dapDebug Adapter related issuesenhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions