Skip to content

Codelldb rust debug formatter does not work #552

@morphe157

Description

@morphe157

Have you read the docs and searched existing issues?

Neovim version (nvim -v)

v0.10.2

Operating system/version

MacOS 15.1

Output of :checkhealth rustaceanvim

==============================================================================
rustaceanvim: require("rustaceanvim.health").check()

Checking for Lua dependencies ~
- OK [mfussenegger/nvim-dap](https://github.com/mfussenegger/nvim-dap) installed.

Checking external dependencies ~
- OK rust-analyzer: found rust-analyzer 1.82.0 (f6e511ee 2024-10-15)
- OK Cargo: found cargo 1.82.0 (8f40fc59f 2024-08-21)
- OK rustc: found rustc 1.82.0 (f6e511eec 2024-10-15)
- OK debug adapter: found codelldb 

Checking config ~
- OK No errors found in config.

Checking for conflicting plugins ~
- OK No conflicting plugins detected.

Checking for tree-sitter parser ~
- OK tree-sitter parser for Rust detected.

How to reproduce the issue

:MasonInstall codelldb
:DapToggleBreakpoint # toggle breakpoint somewhere in rust code so debugger won't exit too quickly
:RustLsp debug

Expected behaviour

Rust data structures are formatted correctly by debugger, e.g. String variable should show actual text instead internal representation, that it, it should be formatted.

Actual behaviour

Screenshot 2024-10-24 at 14 08 39

Rust data structures / primitives are not formatted correctly; dap adapter outputs formatter error:

[debug-adapter stderr] ERROR(Python) 13:57:42 formatters.rust: ('ReadMemory error: %s', 'SBProcess is invalid')
Traceback (most recent call last):
  File "/Users/morphe/.local/share/nvim/mason/packages/codelldb/extension/formatters/rust.py", line 116, in get_synth_summary
    summary = RustSynthProvider.synth_by_id[obj_id].get_summary()
  File "/Users/morphe/.local/share/nvim/mason/packages/codelldb/extension/formatters/rust.py", line 357, in get_summary
    strval = string_from_ptr(self.ptr, min(self.len, max_string_summary_langth))
  File "/Users/morphe/.local/share/nvim/mason/packages/codelldb/extension/formatters/rust.py", line 147, in string_from_ptr
    raise Exception('ReadMemory error: %s', error.GetCString())
Exception: ('ReadMemory error: %s', 'SBProcess is invalid')

It's worth mentioning using the same verison of codelldb works correctly in Visual Studio Code.

The minimal config used to reproduce this issue.

-- Bootstrap lazy.nvim
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then
	local lazyrepo = "https://github.com/folke/lazy.nvim.git"
	local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
	if vim.v.shell_error ~= 0 then
		vim.api.nvim_echo({
			{ "Failed to clone lazy.nvim:\n", "ErrorMsg" },
			{ out, "WarningMsg" },
			{ "\nPress any key to exit..." },
		}, true, {})
		vim.fn.getchar()
		os.exit(1)
	end
end
vim.opt.rtp:prepend(lazypath)

-- Make sure to setup `mapleader` and `maplocalleader` before
-- loading lazy.nvim so that mappings are correct.
-- This is also a good place to setup other settings (vim.opt)
vim.g.mapleader = " "
vim.g.maplocalleader = "\\"

-- Setup lazy.nvim
require("lazy").setup({
	spec = {
		-- add your plugins here
		{ 
			'williamboman/mason.nvim',
			config = function ()
				require('mason').setup()
			end
		},
		{ 
			'mfussenegger/nvim-dap',
			dependencies = { 'rcarriga/nvim-dap-ui', 'nvim-neotest/nvim-nio' },
			config = function ()
				local dap, dapui = require("dap"), require("dapui")

				dapui.setup()

				dap.listeners.before.attach.dapui_config = function()
					dapui.open()
				end
				dap.listeners.before.launch.dapui_config = function()
					dapui.open()
				end
				dap.listeners.before.event_terminated.dapui_config = function()
					dapui.close()
				end
				dap.listeners.before.event_exited.dapui_config = function()
					dapui.close()
				end
			end
		},
		{ 'mrcjkb/rustaceanvim' },
	},
})

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions