microsoft / qsharp

Azure Quantum Development Kit, including the Q# programming language, resource estimator, and Quantum Katas
https://microsoft.github.io/qsharp/
MIT License
461 stars 93 forks source link

Debugger #420

Open idavis opened 1 year ago

idavis commented 1 year ago

This is a tracking issue for adding debugger support for Q#.

For a debugger to function across Monaco, VSCode, and potentially in a REPL, the core debugging functionality needs to reside in a new interpreter. As a first cut we can model this on the stateless interpreter. If we wish to look into supporting the REPL or (VS Code debugger REPL) we need to look at what it will take to do side effect free evaluation. This would also potentially power conditional breakpoints.

Components involved

  1. Compiler (QSC): Create a new debugger interpreter alongside the current stateful and stateless evaluator. We should be able to deprecate one or both eventually with the debugger running in execution mode and not using any breakpoint functionality.
  2. WASM: create a decorator around the debugger which translates the rust data structures into JS compatible values. The API should have the same shape and just be a data marshaling shim.
  3. npm package: This is the same package used by the playground that incorporates the Q# compiler. A new interface will be added to provide access to the debugger which handles the loading of the wasm shim and provides a strongly typed interface for consumption by Monaco and VS Code.
  4. VS Code extension: Implementation of the VS Code debug adapter APIs mapping the calls to the shim and setting up debugging capabilities.
  5. Playground: Similar to VS Code, the debugger needs to be wired up to the Monaco editor extension points in the playground. This will require more changes to the way we hook into Monaco as it doesn't natively support debugging extensions. The extent of the work to be done here is TBD.
%%{init: { "flowchart": { "nodeSpacing": 3 } } }%%
flowchart TD

subgraph JS
  vscode[VS Code extension]
  npm[npm package]
end

subgraph Rust
  wasm["JS bindings (WASM)"]
  debugger[Debugger]
  compiler[Compiler]
end

vscode

vscode-->npm

npm-->wasm
wasm-->debugger
debugger-->compiler

Implementation plan

The initial plan is to support the base scaffolding and core features. Several of the triage and out of scope features require side effect free expression evaluation (log points, hit/conditional breakpoints, etc.). After the core features are functional for VS Code, the base functionality can be exposed for Monaco.

Notes

Tracking breakpoints with HIR node ids is blocked on #453

Resources

sezna commented 8 months ago

Is this issue still up to date? It might be worth breaking out into smaller issues to tackle in the future.

idavis commented 8 months ago

@sezna It is a tracking issue for work. Smaller issues are created for those work items. We can discuss if we want to maintain the tracking issue.

sezna commented 8 months ago

I was referring to the items without issues already created for them, primarily the Debug Cleanup Task section.