-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds a DAP server with support for debugging sway unit tests (#5477)
## Description Related FuelLabs/sway-vscode-plugin#166 Adds a [DAP](https://microsoft.github.io/debug-adapter-protocol//) server as a new forc plugin, `forc-debug`. This enables a UI debugging experience in IDEs such as VSCode. For now, only debugging forc tests is supported. Users can: - set breakpoints inside of forc tests - step through the test, one VM instruction at a time, or continue to the next breakpoint - debug through multiple tests sequentially - see the VM register values in the IDE while debugging - see the current VM opcode, its inputs, and/or immediate value when when the VM is stopped ### Screenshots https://github.com/FuelLabs/sway/assets/47993817/24e2016c-d96c-4ef6-931f-8a4ce4f1386b https://github.com/FuelLabs/sway/assets/47993817/5f0fed49-b278-4074-a1a1-d37de00776f8 ![Feb-01-2024 21-46-40](https://github.com/FuelLabs/sway/assets/47993817/23ade516-0068-4f7c-b7bf-b4142137f72c) ### Local testing 1. Install `forc-debug` 2. Copy this sample launch.json in the VSCode workspace with sway code to debug: ```json { "version": "0.2.0", "configurations": [ { "type": "sway", "request": "launch", "name": "Debug Sway", "program": "${file}" }] } ``` 3. Follow [the steps](https://github.com/FuelLabs/sway-vscode-plugin/blob/master/docs/testing.md) for testing the VSCode extension ### Limitations - Breakpoints only work inside of the project/workspace being debugged - Stack trace support is limited - Not every line has source maps. Once debugging, "verified" breakpoints will show red and "unverified" (no source maps) will be greyed out. - Watch/repl expressions are not yet supported - Step into/out of is not supported - If you click "step over" many times in rapid succession, the server takes a while to catch up. Closes #5394 ## Checklist - [x] I have linked to any relevant issues. - [x] I have commented my code, particularly in hard-to-understand areas. - [ ] I have updated the documentation where relevant (API docs, the reference, and the Sway book). - [ ] I have added tests that prove my fix is effective or that my feature works. - [ ] I have added (or requested a maintainer to add) the necessary `Breaking*` or `New Feature` labels where relevant. - [ ] I have done my best to ensure that my PR adheres to [the Fuel Labs Code Review Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md). - [ ] I have requested a review from the relevant team or maintainers. --------- Co-authored-by: Vaivaswatha Nagaraj <[email protected]> Co-authored-by: Vaivaswatha N <[email protected]> Co-authored-by: IGI-111 <[email protected]> Co-authored-by: João Matos <[email protected]> Co-authored-by: Joshua Batty <[email protected]> Co-authored-by: Igor Rončević <[email protected]> Co-authored-by: Sudhakar Verma <[email protected]> Co-authored-by: Marcos Henrich <[email protected]> Co-authored-by: jjcnn <[email protected]>
- Loading branch information
1 parent
b32d0e0
commit 4cf3398
Showing
30 changed files
with
2,251 additions
and
134 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
use crate::types::Instruction; | ||
use dap::requests::Command; | ||
use thiserror::Error; | ||
|
||
#[derive(Error, Debug)] | ||
pub enum AdapterError { | ||
#[error("Unhandled command")] | ||
UnhandledCommand { command: Command }, | ||
|
||
#[error("Missing command")] | ||
MissingCommand, | ||
|
||
#[error("Missing configuration")] | ||
MissingConfiguration, | ||
|
||
#[error("Missing source path argument")] | ||
MissingSourcePathArgument, | ||
|
||
#[error("Missing breakpoint location")] | ||
MissingBreakpointLocation, | ||
|
||
#[error("Missing source map")] | ||
MissingSourceMap { pc: Instruction }, | ||
|
||
#[error("Unknown breakpoint")] | ||
UnknownBreakpoint { pc: Instruction }, | ||
|
||
#[error("Build failed")] | ||
BuildFailed { reason: String }, | ||
|
||
#[error("No active test executor")] | ||
NoActiveTestExecutor, | ||
|
||
#[error("Test execution failed")] | ||
TestExecutionFailed { | ||
#[from] | ||
source: anyhow::Error, | ||
}, | ||
} |
Oops, something went wrong.