Draco-lang / Compiler

The compiler repository for the Draco programming language.
Apache License 2.0
74 stars 9 forks source link

Make the debugger x-plat #272

Open LPeter1997 opened 1 year ago

LPeter1997 commented 1 year ago

Currently we have a couple of FindDbgShim methods lying around that stupidly tries to look up the default Windows path of the DLL. It is advised that we ship this DLL with our debugger. Let's do that and test the debugger on Linux. Affected components are everything that consumes the debugger API, so we should pack it with the debugger API.

lordmilko commented 10 months ago

Hi @LPeter1997,

I understand this project is utilizing my ClrDebug library, and that it has based its current dbgshim resolution logic found in ClrDebug's NetCore Sample project. At the time this sample was written, there wasn't really any good way (that I could see) of easily acquiring a copy of dbgshim to ship with .NET applications, hence why this hacky FindDbgShim implementation was used.

You may be interested to know that in .NET 8, thanks to an issue which has been resolved, it will be possible to properly reference the Microsoft.Diagnostic.DbgShim NuGet package and have dbgshim be properly copied to your output directory (where previously MSBuild would have refused to copy dbgshim to the output directory on the basis it considered dbgshim to be part of the runtime itself)

Note that depending on the way your program is compiled, and the platforms you wish to support, all desired runtime implementations of dbgshim may not be copied to your output directory (e.g. compiling for and/or on Windows might only give you Windows dbgshim DLLs). You can work around this by adding an MSBuild task to reach out to your $(NuGetPackageRoot) and manually copy all desired runtimes to your output folder. ClrDebug's NetCore Sample has been updated to show this technique, and contains a sample DbgShimResolver implementation which may or may not be useful.

Regards, lordmilko

LPeter1997 commented 10 months ago

@lordmilko Thank you for reaching out, and thank you so much for making your library! IIRC @reflectronic came up with the solution to simply copy all DLLs for all runtimes, since the DLLs are not too big and would make the debugger truly x-plat.

reflectronic commented 10 months ago

I created a workaround for the DbgShim problem some time ago: https://github.com/Draco-lang/Compiler/blob/a00f76c02461bb138e21aff5c03e6c9723cbea57/src/Draco.Debugger/DbgShim.targets#L7-L25

Good to know it's not required when targeting .NET 8!

Kuinox commented 7 months ago

Blocked by #355.

Kuinox commented 4 months ago

The debugger have now tests, we upgraded to .NET 8 but the debugger get stuck on linux/macOS for some reason. The tests are disabled on theses platforms until someone find the cause.

The tests are available here: https://github.com/Draco-lang/Compiler/tree/main/src/Draco.Debugger.Tests