Samsung / netcoredbg

NetCoreDbg is a managed code debugger with MI interface for CoreCLR.
MIT License
780 stars 101 forks source link

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

Open C-SELLERS opened 2 years ago

C-SELLERS commented 2 years ago

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!

viewizard commented 2 years ago

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?

C-SELLERS commented 2 years ago

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 🤔

viewizard commented 2 years ago

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.

C-SELLERS commented 2 years ago

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 👍🏽