netcoredbg icon indicating copy to clipboard operation
netcoredbg copied to clipboard

VSCode protocol "launch" command "sourceFileMap" option support.

Open C-SELLERS opened this issue 3 years ago • 4 comments

Question for you guys,

Does netcoredbg support source file mapping through the VSCodeProtocol? Just looking through vscodeprotocol.cpp, I don't believe it does but I could be missing something.

Thank you!

C-SELLERS avatar Dec 11 '21 01:12 C-SELLERS

We don't support this for sure. Could you please share more info about source file mapping through the VSCode protocol? Do you mean "Source Request" https://microsoft.github.io/debug-adapter-protocol/specification?

viewizard avatar Dec 11 '21 09:12 viewizard

Apologies, turns out its not something that the VSCode protocol manages, but rather is a feature of the debugger. I believe debugger engines like vsdbg manage this sort of mapping internally.

When testing with vsdbg it comes through with the "attach" or "launch" command in the argument list like so "sourceFileMap":{"/pathDuringBuild":"/currentPath"}

Then presumably the debugger behind the scenes will replace any instance of pathDuringBuild with currentPath. This way I can continue to debug a file that has changed locations since the building of the dll & pdb.

Curious what it would take to add that flexibility to netcoredbg 🤔

C-SELLERS avatar Dec 13 '21 20:12 C-SELLERS

I see, you mean https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md#source-file-map, we already support "justMyCode" and "enableStepFiltering" launch options, so, add more launch options possible. Unfortunately, we don't have time right now, but I added this to feature requests list.

viewizard avatar Dec 13 '21 20:12 viewizard

Yes!

That's great, I appreciate it.

In the meantime I found a less flexible work around that can be set during build. By using property PathMap in your csproj or as a build property from the cli you can effectively map an alternative directory as the source directory.

EX. I am building in /Builder/Project/ , but will be running and debugging the copied source in /Project/.

  1. Adding <PathMap>/Builder/Project/=/Project/</PathMap> to the csproj property group
  2. dotnet build -p:pathmap=/Builder/Project/=/Project/

Both of these will map the file locations in the pdbs to /Project/ allowing you to debug a source in a different directory than the original 👍🏽

C-SELLERS avatar Dec 13 '21 22:12 C-SELLERS