Skip to content

Commit

Permalink
fix(dap): only add sourceMap and lldb commands if the files exist (#102)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrcjkb committed Dec 18, 2023
1 parent cc2b887 commit a13e311
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
## [3.10.2] - 2023-12-18

### Fixed

- DAP: Only add sourceMap and lldb commands if the files exist.
- DAP (Windows): Fixed .exe extension in mason.nvim codelldb detection.
Thanks [@svermeulen](https://github.com/svermeulen)!

Expand Down
2 changes: 1 addition & 1 deletion lua/rustaceanvim/commands/crate_graph.lua
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ local function handler_factory(backend, output, pipe)
end

graph = string.gsub(graph, '\n', '')
print('rust-tools: Processing crate graph. This may take a while...')
vim.notify('rustaceanvim: Processing crate graph. This may take a while...')

local cmd = 'dot -T' .. backend
if pipe ~= nil then -- optionally pipe to `pipe`
Expand Down
21 changes: 17 additions & 4 deletions lua/rustaceanvim/dap.lua
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,20 @@ local source_maps = {}
local function generate_source_map(workspace_root)
get_rustc_commit_hash(function(commit_hash)
get_rustc_sysroot(function(rustc_sysroot)
local src_path
for _, src_dir in pairs { 'src', 'rustc-src' } do
src_path = compat.joinpath(rustc_sysroot, 'lib', 'rustlib', src_dir, 'rust')
if compat.uv.fs_stat(src_path) then
break
end
src_path = nil
end
if not src_path then
return
end
---@type DapSourceMap
local new_map = {
[compat.joinpath('/rustc', commit_hash)] = compat.joinpath(rustc_sysroot, 'lib', 'rustlib', 'src', 'rust'),
[compat.joinpath('/rustc', commit_hash)] = src_path,
}
source_maps[workspace_root] = vim.tbl_extend('force', source_maps[workspace_root] or {}, new_map)
end)
Expand All @@ -126,9 +137,11 @@ local init_commands = {}

local function get_lldb_commands(workspace_root)
get_rustc_sysroot(function(rustc_sysroot)
local script_import = 'command script import "'
.. compat.joinpath(rustc_sysroot, 'lib', 'rustlib', 'etc', 'lldb_lookup.py')
.. '"'
local script = compat.joinpath(rustc_sysroot, 'lib', 'rustlib', 'etc', 'lldb_lookup.py')
if not compat.uv.fs_stat(script) then
return
end
local script_import = 'command script import "' .. script .. '"'
local commands_file = compat.joinpath(rustc_sysroot, 'lib', 'rustlib', 'etc', 'lldb_commands')
local file = io.open(commands_file, 'r')
local workspace_root_cmds = {}
Expand Down

0 comments on commit a13e311

Please sign in to comment.