Skip to content

Commit 85c1007

Browse files
authored
Adding Debug support cross platform (#375)
1 parent 2fc01a4 commit 85c1007

39 files changed

+14422
-3909
lines changed

.vscodeignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,6 @@ nanoFirmwareFlasher/**
2929
!node_modules/extract-zip
3030
!node_modules/semver
3131
!node_modules/typed-rest-client
32+
33+
# Include debug bridge binaries
34+
!bin/nanoDebugBridge/**

CHANGELOG.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,28 @@
11
# Changelog
22

3+
## [Unreleased]
4+
5+
### Added
6+
7+
- **Full Debugging Support** - The extension now supports source-level debugging of nanoFramework applications
8+
- Set and hit breakpoints in your C# code
9+
- Step through code (Step Into, Step Over, Step Out)
10+
- Inspect local variables, arguments, and object properties
11+
- View call stacks with source file locations
12+
- Evaluate expressions in the Debug Console
13+
- Watch expressions panel support
14+
- Debug.WriteLine output in Debug Console
15+
- Exception handling with break on exception options
16+
- Automatic device detection and selection
17+
- Support for both Launch (deploy and debug) and Attach (debug running code) modes
18+
19+
### Documentation
20+
21+
- Added comprehensive debugging documentation in [docs/debugging.md](docs/debugging.md)
22+
- Updated README with debugging section, launch.json configuration, and troubleshooting guide
23+
24+
---
25+
326
## [v1.0.132](https://github.com/nanoframework/nf-VSCodeExtension/tree/v1.0.132) (2022-09-08)
427

528
[Full Changelog](https://github.com/nanoframework/nf-VSCodeExtension/compare/v1.0.130...v1.0.132)

README.md

Lines changed: 99 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,106 @@ Then select the type of project you want to add.
7474

7575
![type of project](docs/create-solution-step4.png)
7676

77-
### Check Prerequisites
77+
## Debugging
78+
79+
The extension provides full debugging support for .NET nanoFramework applications running on connected devices.
80+
81+
### Quick Start
82+
83+
1. **Connect your device** - Ensure your nanoFramework device is connected via USB/Serial
84+
2. **Build your project** - Use `nanoFramework: Build Project` command
85+
3. **Start debugging** - Press `F5` or use `Run > Start Debugging`
86+
87+
### Debug Features
88+
89+
| Feature | Description |
90+
| ------- | ----------- |
91+
| **Breakpoints** | Set breakpoints by clicking in the gutter or pressing `F9` |
92+
| **Step Through Code** | Step Over (`F10`) currently like Continue, Step Into (`F11`), Step Out (`Shift+F11`) |
93+
| **Variable Inspection** | View local variables, arguments, and object properties |
94+
| **Watch Expressions** | Add expressions to the Watch panel |
95+
| **Call Stack** | View the current call stack with source locations |
96+
| **Debug Console** | See `Debug.WriteLine` output and evaluate expressions |
97+
| **Exception Handling** | Break on exceptions (configurable) |
98+
99+
### launch.json Configuration
100+
101+
Create a `.vscode/launch.json` file in your workspace with the following configurations:
102+
103+
```json
104+
{
105+
"version": "0.2.0",
106+
"configurations": [
107+
{
108+
"name": "nanoFramework: Launch and Debug",
109+
"type": "nanoframework",
110+
"request": "launch",
111+
"program": "${workspaceFolder}/${workspaceFolderBasename}/bin/Debug",
112+
"device": "",
113+
"stopOnEntry": true,
114+
"deployAssemblies": true,
115+
"verbosity": "none"
116+
},
117+
{
118+
"name": "nanoFramework: Attach to Device",
119+
"type": "nanoframework",
120+
"request": "attach",
121+
"device": "",
122+
"program": "${workspaceFolder}/${workspaceFolderBasename}/bin/Debug"
123+
}
124+
]
125+
}
126+
```
127+
128+
#### Configuration Options
129+
130+
| Option | Type | Description |
131+
| ------ | ---- | ----------- |
132+
| `type` | string | Must be `"nanoframework"` |
133+
| `request` | string | `"launch"` to deploy and debug, `"attach"` to debug running code |
134+
| `program` | string | Path to the `.pe` file or directory containing assemblies |
135+
| `device` | string | COM port (e.g., `"COM3"`) or IP address. Leave empty for auto-detect |
136+
| `stopOnEntry` | boolean | Pause at program entry point (default: `true`) |
137+
| `deployAssemblies` | boolean | Deploy assemblies before debugging (launch only) |
138+
| `verbosity` | string | Logging verbosity: `"none"`, `"information"` (default), or `"debug"` |
139+
140+
### Device Selection
141+
142+
- If `device` is empty, the extension will:
143+
- Use the last selected device if available
144+
- Auto-select if only one device is connected
145+
- Show a device picker if multiple devices are found
146+
147+
- Use the `nanoFramework: Select Debug Device` command to manually choose a device
148+
149+
### Troubleshooting
150+
151+
**Device not detected:**
152+
153+
- Ensure the device is properly connected and running nanoFramework firmware
154+
- Check that the correct drivers are installed for your device
155+
- Try unplugging and reconnecting the device
78156

79-
Select `nanoFramework: Check Prerequisites` to verify that all required tools are installed and properly configured on your system. This is especially helpful for macOS and Linux users to diagnose setup issues.
157+
**Breakpoints not hitting:**
158+
159+
- Ensure you have build the project first!
160+
- Ensure the deployed code matches your source files
161+
- Adjust the path for `"program": "${workspaceFolder}/${workspaceFolderBasename}/bin/Debug"` if needed
162+
- Rebuild the project before debugging
163+
- Check that symbol files (.pdbx, .pdb) are present in the output directory
164+
165+
**Debug session won't start:**
166+
167+
- Verify .NET 10.0 runtime is installed
168+
- Check the Debug Console for error messages
169+
- Ensure no other application is using the COM port
170+
- Change the log level to see more errors
80171

81172
## Requirements
82173

83174
You will need to make sure you'll have the following elements installed:
84175

85-
- [.NET 8.0](https://dotnet.microsoft.com/download/dotnet/8.0) or later
176+
- [.NET 10.0](https://dotnet.microsoft.com/download/dotnet/10.0) or later
86177
- [nanoff](https://github.com/nanoframework/nanoFirmwareFlasher) - Install via: `dotnet tool install -g nanoff`
87178
- **Windows only:** [Visual Studio Build Tools](https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2022) with ".NET desktop build tools" workload
88179
- **Linux/macOS only:** [mono-complete](https://www.mono-project.com/docs/getting-started/install/) with msbuild, and [nuget CLI](https://www.nuget.org/downloads)
@@ -103,9 +194,7 @@ Log out and back in for this to take effect.
103194
> Instead install the `mono-complete` package provided by the Mono Project.
104195
> The [preview](https://www.mono-project.com/download/preview/) version is recommended.
105196
106-
## Known Issues
107-
108-
This extension will **not** allow you to debug the device. Debug is only available on Windows with [Visual Studio](https://visualstudio.microsoft.com/downloads/) (any edition) and the [.NET nanoFramework Extension](https://marketplace.visualstudio.com/items?itemName=nanoframework.nanoFramework-VS2022-Extension) installed.
197+
**Debugging is now supported!** See the [Debugging](#debugging) section below.
109198

110199
This extension works on:
111200

@@ -115,6 +204,10 @@ This extension works on:
115204

116205
32-bit operating systems are not supported.
117206

207+
## Known Issues
208+
209+
Step over in debug mode is like continue so far. We're activey working on improving this. You can setup as many break points as you want, so, if you need an equivalent of setp over, you can do this!
210+
118211
## Developing for the VS Code extension
119212

120213
Documentation about development for the extension can be found [here](installation.md).

azure-pipelines.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ steps:
6565
displayName: npm ci
6666
condition: succeeded()
6767

68+
- script: npx gulp build-debug-bridge
69+
displayName: Build debug bridge
70+
condition: succeeded()
71+
6872
# we don't have unit tests
6973
# - script: npm run test
7074
# displayName: Run unit tests

0 commit comments

Comments
 (0)