Support source maps between editor and debugger file paths #1030
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When nvim-dap is running on a separate machine from the debugger then Nvim and the debugger will use different paths for source files. For example, if Nvim is running on a machine where the source tree is located at
/a/project/foo
and the debugger is running on a separate machine where the source tree is located at/b/project/foo
, when nvim-dap tries to set a breakpoint it will use/a/project/foo/
in the breakpoint location. When the debugger receives this request it will not set the breakpoint correctly because the debugger does not have any files at/a/project/foo
.The
source_map
option instructs nvim-dap to convert paths as seen by the editor and nvim-dap itself to the paths as the debugger sees them. The opposite mapping takes place when nvim-dap receives stack frame or source file information from the debugger.Note that this is different than the "source map" option provided by many debuggers themselves (such as codelldb's "sourceMap" option or GDB's "substitute-path" setting). Those options convert compiled source paths (i.e. the path of the source file when the binary was compiled) into the debugger's path namespace (
/b/project/foo
in our example).