diff --git a/CHANGELOG.md b/CHANGELOG.md index 250c38ed..16f667c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ All notable changes to this project will be documented in this file. ### Changed - The bundled version of the Arduino CLI was updated to [version 0.31.0](https://github.com/arduino/arduino-cli/releases/tag/0.31.0). [#1606](https://github.com/microsoft/vscode-arduino/pull/1606) +- All functionality related to the `arduino` debug type was removed from the extension. The built-in debugging support was rarely used and not actively maintained. [#1610](https://github.com/microsoft/vscode-arduino/pull/1610) ### Fixed diff --git a/README.md b/README.md index d059ae41..26950106 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![Gitter](https://img.shields.io/badge/chat-on%20gitter-blue.svg)](https://gitter.im/Microsoft/vscode-arduino) -Welcome to the Visual Studio Code extension for **Arduino** preview ! The Arduino extension makes it easy to develop, build, deploy and debug your Arduino sketches in Visual Studio Code, with a rich set of functionalities. These include: +Welcome to the Visual Studio Code extension for **Arduino** preview ! The Arduino extension makes it easy to develop, build, and deploy your Arduino sketches in Visual Studio Code, with a rich set of functionalities. These include: * IntelliSense and syntax highlighting for Arduino sketches * Verify and upload your sketches in Visual Studio Code @@ -12,7 +12,6 @@ Welcome to the Visual Studio Code extension for **Arduino** preview ! * Snippets for sketches * Automatic Arduino project scaffolding * Command Palette (F1) integration of frequently used commands (e.g. Verify, Upload...) -* Integrated Arduino Debugging New ## Prerequisites Either the legacy Arduino IDE or Arduino CLI are required. The recommended @@ -121,7 +120,6 @@ The following settings are as per sketch settings of the Arduino extension. You "port": "COM5", "board": "adafruit:samd:adafruit_feather_m0", "output": "../build", - "debugger": "jlink", "prebuild": "./prebuild.sh", "postbuild": "./postbuild.sh", "intelliSenseGen": "global" @@ -131,7 +129,6 @@ The following settings are as per sketch settings of the Arduino extension. You - `port` - Name of the serial port connected to the device. Can be set by the `Arduino: Select Serial Port` command. For Mac users could be "/dev/cu.wchusbserial1420". - `board` - Currently selected Arduino board alias. Can be set by the `Arduino: Change Board Type` command. Also, you can find the board list there. - `output` - Arduino build output path. If not set, Arduino will create a new temporary output folder each time, which means it cannot reuse the intermediate result of the previous build leading to long verify/upload time, so it is recommended to set the field. Arduino requires that the output path should not be the workspace itself or in a subfolder of the workspace, otherwise, it may not work correctly. By default, this option is not set. It's worth noting that the contents of this file could be deleted during the build process, so pick (or create) a directory that will not store files you want to keep. -- `debugger` - The short name of the debugger that will be used when the board itself does not have a debugger and there is more than one debugger available. You can find the list of debuggers [here](https://github.com/Microsoft/vscode-arduino/blob/main/misc/debuggerUsbMapping.json). By default, this option is not set. - `prebuild` - External command which will be invoked before any sketch build (verify, upload, ...). For details see the [Pre- and Post-Build Commands](#Pre--and-Post-Build-Commands) section. - `postbuild` - External command to be run after the sketch has been built successfully. See the afore mentioned section for more details. - `intelliSenseGen` - Override the global setting for auto-generation of the IntelliSense configuration (i.e. `.vscode/c_cpp_properties.json`). Three options are available: @@ -201,24 +198,6 @@ vscode-arduino's analysis stores the result as a dedicated IntelliSense-configur This system allows you to setup and use own IntelliSense configurations in parallel to the automatically generated configurations provided through vscode-arduino. Just add your configuration to `c_cpp_properties.json` and name it differently from the default configuration (`Arduino`), e.g. `My awesome configuration` and select it from the status bar or via the command palette command **C/C++: Select a Configuration...** -## Debugging Arduino Code preview -Before you start to debug your Arduino code, please read [this document](https://code.visualstudio.com/docs/editor/debugging) to learn about the basic mechanisms of debugging in Visual Studio Code. Also see [debugging for C++ in VSCode](https://code.visualstudio.com/docs/languages/cpp#_debugging) for further reference. - -Make sure that your Arduino board can work with [STLink](http://www.st.com/en/development-tools/st-link-v2.html), [Jlink](https://www.segger.com/jlink-debug-probes.html) or [EDBG](http://www.atmel.com/webdoc/protocoldocs/ch01s01.html). The debugging support is currently fully tested with the following boards: -- [MXChip IoT Developer Kit - AZ3166](https://microsoft.github.io/azure-iot-developer-kit/) -- [Arduino M0 PRO](https://www.arduino.cc/en/Main/ArduinoBoardM0PRO) -- [Adafruit WICED WiFi Feather](https://www.adafruit.com/product/3056) -- [Adafruit Feather M0](https://www.adafruit.com/product/3010) -- Arduino Zero Pro - -Steps to start debugging: -1. Plug in your board to your development machine properly. For those boards that do not have an on-board debugging chip, you need to use a STLink or JLink connector. -2. Go to the **Debug View** (Ctrl + Shift + D *or* Cmd + Shift + D). and set breakpoints in your source files. -3. Press F5 to select your debugging environment. -4. When your breakpoint is hit, you can see variables and add expression(s) to watch on the Debug Side Bar. - -> To learn more about how to debug Arduino code, visit our [team blog](https://blogs.msdn.microsoft.com/iotdev/2017/05/27/debug-your-arduino-code-with-visual-studio-code/). - ## Change Log See the [Change log](https://github.com/Microsoft/vscode-arduino/blob/main/CHANGELOG.md) for details about the changes in each version. diff --git a/misc/arduinoValidator.json b/misc/arduinoValidator.json index 5386fc4f..139caa99 100644 --- a/misc/arduinoValidator.json +++ b/misc/arduinoValidator.json @@ -28,11 +28,6 @@ "type": "string", "minLength": 1 }, - "debugger": { - "description": "Arduino Debugger Settings", - "type": "string", - "minLength": 1 - }, "intelliSenseGen": { "description": "Disable/enable the automatic generation of the IntelliSense configuration file (c_cpp_properties.json) for this project (overrides the global setting). When set to \"global\" the global extension settings will be used.", "type": "string", diff --git a/misc/debuggerUsbMapping.json b/misc/debuggerUsbMapping.json deleted file mode 100644 index fe3ad082..00000000 --- a/misc/debuggerUsbMapping.json +++ /dev/null @@ -1,102 +0,0 @@ -[ - { - "vid": "0483", - "pid": "3744", - "name": "ST Link V1.0", - "short_name": "stlink-1.0", - "config_file": "stlink-v1.cfg" - }, - { - "vid": "0483", - "pid": "3748", - "name": "ST Link V2.0", - "short_name": "stlink-2.0", - "config_file": "stlink-v2.cfg" - }, - { - "vid": "0483", - "pid": "374b", - "name": "ST Link V2.1", - "short_name": "stlink-2.1", - "config_file": "stlink-v2-1.cfg" - }, - { - "vid": "0483", - "pid": [ - "374e", - "374f", - "3753" - ], - "name": "ST Link V3.0", - "short_name": "stlink-v3.0", - "config_file": "stlink-v3-0.cfg" - }, - { - "pid": [ - "0101", - "0102", - "0103", - "0104", - "0105", - "0106", - "0107", - "0108", - "0109", - "0110", - "0111", - "0112", - "0113", - "0114", - "0115", - "0116", - "0117", - "0118" - ], - "vid": "1366", - "name": "JLink", - "short_name": "jlink", - "config_file": "jlink.cfg" - }, - { - "vid": "03eb", - "pid": "2111", - "name": "CMSIS-DAP", - "short_name": "cmsis-dap", - "config_file": "cmsis-dap.cfg" - }, - { - "vid": "03eb", - "pid": [ - "2111", - "2157" - ], - "name": "CMSIS-DAP", - "short_name": "cmsis-dap", - "config_file": "cmsis-dap.cfg" - }, - { - "vid": "0d28", - "pid": "0204", - "name": "CMSIS-DAP", - "short_name": "cmsis-dap", - "config_file": "cmsis-dap.cfg" - }, - { - "vid": "1781", - "pid": "0c9f", - "name": "USBtinySPI", - "short_name": "debugWIRE", - "config_file": "" - }, - { - "vid": "c251", - "pid": [ - "f001", - "f002", - "2722" - ], - "name": "CMSIS-DAP", - "short_name": "cmsis-dap", - "config_file": "cmsis-dap.cfg" - } -] diff --git a/misc/openOCDMapping.json b/misc/openOCDMapping.json deleted file mode 100644 index ef50f443..00000000 --- a/misc/openOCDMapping.json +++ /dev/null @@ -1,18 +0,0 @@ -[ - { - "board": "arduino:samd:mzero_pro_bl_dbg", - "interface": "interface/cmsis-dap.cfg", - "target": "target/at91samdXX.cfg" - }, - { - "board": "arduino:samd:mzero_bl", - "interface": "interface/cmsis-dap.cfg", - "target": "target/at91samdXX.cfg" - }, - { - "board": "AZ3166:stm32f4:MXCHIP_AZ3166", - "interface": "interface/stlink-v2-1.cfg", - "target": "target/stm32f4x.cfg" - } -] - diff --git a/package.json b/package.json index 02018104..9e6ac6d0 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,6 @@ "homepage": "https://github.com/Microsoft/vscode-arduino", "categories": [ "Programming Languages", - "Debuggers", "Snippets", "Formatters" ], @@ -50,8 +49,7 @@ "onCommand:arduino.showBoardManager", "onCommand:arduino.showLibraryManager", "onCommand:arduino.showExamples", - "onCommand:arduino.initialize", - "onDebug" + "onCommand:arduino.initialize" ], "main": "./out/src/extension", "contributes": { @@ -188,267 +186,6 @@ "contents": "No examples are installed. [Find additional examples online.](https://go.microsoft.com/fwlink/?linkid=2225276)" } ], - "debuggers": [ - { - "type": "arduino", - "label": "Arduino", - "configurationSnippets": [ - { - "label": "Arduino: Launch Debugger", - "description": "Debug Arduino sketch", - "body": { - "name": "Arduino", - "type": "arduino", - "request": "launch", - "program": "^\"\\${file}\"", - "cwd": "^\"\\${workspaceFolder}\"", - "MIMode": "gdb", - "targetArchitecture": "arm", - "miDebuggerPath": "", - "debugServerPath": "", - "debugServerArgs": "", - "customLaunchSetupCommands": [ - { - "text": "target remote localhost:3333" - }, - { - "text": "^\"file \\\"\\${file}\\\"\"" - }, - { - "text": "load" - }, - { - "text": "monitor reset halt" - }, - { - "text": "monitor reset init" - } - ], - "stopAtEntry": true, - "serverStarted": "Info\\\\ :\\\\ [\\\\w\\\\d\\\\.]*:\\\\ hardware", - "launchCompleteCommand": "exec-continue", - "filterStderr": true, - "args": [] - } - } - ], - "configurationAttributes": { - "launch": { - "required": [ - "program" - ], - "properties": { - "program": { - "type": "string", - "description": "Full path to program executable.", - "default": "${workspaceFolder}/arduino.elf" - }, - "args": { - "type": "array", - "description": "Command line arguments passed to the program.", - "items": { - "type": "string" - }, - "default": [] - }, - "type": { - "type": "string", - "description": "The type of the engine.", - "default": "arduino" - }, - "targetArchitecture": { - "type": "string", - "description": "The architecture of the debugger.", - "default": "arm" - }, - "cwd": { - "type": "string", - "description": "The working directory of the target", - "default": "." - }, - "setupCommands": { - "type": "array", - "description": "One or more GDB commands to execute in order to setup the underlying debugger. Example: \"setupCommands\": [ { \"text\": \"-enable-pretty-printing\", \"description\": \"Enable GDB pretty printing\", \"ignoreFailures\": true }].", - "items": { - "type": "object", - "properties": { - "text": { - "type": "string", - "description": "The debugger command to execute.", - "default": "" - }, - "description": { - "type": "string", - "description": "Optional description for the command.", - "default": "" - }, - "ignoreFailures": { - "type": "boolean", - "description": "If true, failures from the command should be ignored. Default value is false.", - "default": "false" - } - } - }, - "default": [] - }, - "customLaunchSetupCommands": { - "type": "array", - "description": "If provided, this replaces the default commands used to launch a target with some other commands. For example, this can be \"-target-attach\" in order to attach to a target process. An empty command list replaces the launch commands with nothing, which can be useful if the debugger is being provided launch options as command line options. Example: \"customLaunchSetupCommands\": [ { \"text\": \"target-run\", \"description\": \"run target\", \"ignoreFailures\": false }].", - "items": { - "type": "object", - "properties": { - "text": { - "type": "string", - "description": "The debugger command to execute.", - "default": "" - }, - "description": { - "type": "string", - "description": "Optional description for the command.", - "default": "" - }, - "ignoreFailures": { - "type": "boolean", - "description": "If true, failures from the command should be ignored. Default value is false.", - "default": "" - } - } - }, - "default": [] - }, - "launchCompleteCommand": { - "enum": [ - "exec-run", - "exec-continue", - "None" - ], - "description": "The command to execute after the debugger is fully setup in order to cause the target process to run. Allowed values are \"exec-run\", \"exec-continue\", \"None\". The default value is \"exec-run\".", - "default": "exec-run" - }, - "visualizerFile": { - "type": "string", - "description": ".natvis file to be used when debugging this process. This option is not compatible with GDB pretty printing. Please also see \"showDisplayString\" if using this setting.", - "default": "" - }, - "showDisplayString": { - "type": "boolean", - "description": "When a visualizerFile is specified, showDisplayString will enable the display string. Turning this option on can cause slower performance during debugging.", - "default": "true" - }, - "additionalSOLibSearchPath": { - "type": "string", - "description": "Semicolon separated list of directories to use to search for .so files. Example: \"c:\\dir1;c:\\dir2\".", - "default": "" - }, - "MIMode": { - "type": "string", - "description": "Indicates the console debugger that the MIDebugEngine will connect to. Allowed values are \"gdb\" \"lldb\".", - "default": "gdb" - }, - "miDebuggerPath": { - "type": "string", - "description": "The path to the mi debugger (such as gdb). When unspecified, it will search path first for the debugger.", - "default": "/usr/bin/gdb" - }, - "miDebuggerServerAddress": { - "type": "string", - "description": "Network address of the MI Debugger Server to connect to (example: localhost:1234).", - "default": "serveraddress:port" - }, - "stopAtEntry": { - "type": "boolean", - "description": "Optional parameter. If true, the debugger should stop at the entrypoint of the target. If processId is passed, has no effect.", - "default": false - }, - "debugServerPath": { - "type": "string", - "description": "Optional full path to debug server to launch. Defaults to null.", - "default": "" - }, - "debugServerArgs": { - "type": "string", - "description": "Optional debug server args. Defaults to null.", - "default": "" - }, - "serverStarted": { - "type": "string", - "description": "Optional server-started pattern to look for in the debug server output. Defaults to null.", - "default": "" - }, - "filterStdout": { - "type": "boolean", - "description": "Search stdout stream for server-started pattern and log stdout to debug output. Defaults to true.", - "default": "true" - }, - "filterStderr": { - "type": "boolean", - "description": "Search stderr stream for server-started pattern and log stderr to debug output. Defaults to false.", - "default": "false" - }, - "serverLaunchTimeout": { - "type": "integer", - "description": "Optional time, in milliseconds, for the debugger to wait for the debugServer to start up. Default is 10000.", - "default": "10000" - }, - "coreDumpPath": { - "type": "string", - "description": "Optional full path to a core dump file for the specified program. Defaults to null.", - "default": "" - }, - "externalConsole": { - "type": "boolean", - "description": "If true, a console is launched for the debuggee. If false, no console is launched. Note this option is ignored in some cases for technical reasons.", - "default": "false" - }, - "sourceFileMap": { - "type": "object", - "description": "Optional source file mappings passed to the debug engine. Example: '{ \"/original/source/path\":\"/current/source/path\" }'", - "default": { - "": "" - } - }, - "logging": { - "type": "object", - "description": "Optional flags to determine what types of messages should be logged to the Debug Console.", - "default": {}, - "properties": { - "exceptions": { - "type": "boolean", - "description": "Optional flag to determine whether exception messages should be logged to the Debug Console. Defaults to true.", - "default": true - }, - "moduleLoad": { - "type": "boolean", - "description": "Optional flag to determine whether module load events should be logged to the Debug Console. Defaults to true.", - "default": true - }, - "programOutput": { - "type": "boolean", - "description": "Optional flag to determine whether program output should be logged to the Debug Console. Defaults to true.", - "default": true - }, - "engineLogging": { - "type": "boolean", - "description": "Optional flag to determine whether diagnostic engine logs should be logged to the Debug Console. Defaults to false.", - "default": false - }, - "trace": { - "type": "boolean", - "description": "Optional flag to determine whether diagnostic adapter command tracing should be logged to the Debug Console. Defaults to false.", - "default": false - }, - "traceResponse": { - "type": "boolean", - "description": "Optional flag to determine whether diagnostic adapter command and response tracing should be logged to the Debug Console. Defaults to false.", - "default": false - } - } - } - } - } - } - } - ], "keybindings": [ { "command": "arduino.verify", diff --git a/src/arduinoContext.ts b/src/arduinoContext.ts index 321d2857..ddfb6334 100644 --- a/src/arduinoContext.ts +++ b/src/arduinoContext.ts @@ -3,8 +3,6 @@ import { ArduinoApp } from "./arduino/arduino"; import { BoardManager } from "./arduino/boardManager"; -import { DebuggerManager } from "./debug/debuggerManager"; -import { DeviceContext } from "./deviceContext"; class ArduinoContext { public get initialized(): boolean { @@ -29,23 +27,11 @@ class ArduinoContext { this._boardManager = value; } - public get debuggerManager(): DebuggerManager { - if (this._debuggerManager === null) { - this._debuggerManager = new DebuggerManager( - DeviceContext.getInstance().extensionPath, - this.arduinoApp.settings, - this.boardManager); - this._debuggerManager.initialize(); - } - return this._debuggerManager; - } - // TODO EW: You don't have to initialize members to null // if they don't get a default value or aren't initialized // within a constructor they are "undefined" by default. // This makes comparing against null (above) superfluous. private _arduinoApp: ArduinoApp = null; - private _debuggerManager: DebuggerManager = null; private _boardManager: BoardManager = null; } diff --git a/src/debug/configurationProvider.ts b/src/debug/configurationProvider.ts deleted file mode 100644 index fa0cd2cd..00000000 --- a/src/debug/configurationProvider.ts +++ /dev/null @@ -1,213 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. - -import * as path from "path"; -import * as vscode from "vscode"; - -import { BuildMode } from "../arduino/arduino"; -import ArduinoActivator from "../arduinoActivator"; -import ArduinoContext from "../arduinoContext"; - -import { VscodeSettings } from "../arduino/vscodeSettings"; -import * as constants from "../common/constants"; -import * as platform from "../common/platform"; -import * as util from "../common/util"; -import { ArduinoWorkspace } from "../common/workspace"; -import { DeviceContext } from "../deviceContext"; -import * as Logger from "../logger/logger"; - -export class ArduinoDebugConfigurationProvider implements vscode.DebugConfigurationProvider { - - constructor() { } - - public provideDebugConfigurations(folder: vscode.WorkspaceFolder | undefined, token?: vscode.CancellationToken): - vscode.ProviderResult { - return [ - this.getDefaultDebugSettings(folder), - ]; - } - - // Try to add all missing attributes to the debug configuration being launched. - public resolveDebugConfiguration(folder: vscode.WorkspaceFolder | undefined, config: vscode.DebugConfiguration, token?: vscode.CancellationToken): - vscode.ProviderResult { - if (!config || !config.request) { - config = this.getDefaultDebugSettings(folder); - } - return this.resolveDebugConfigurationAsync(config); - } - - private getDefaultDebugSettings(folder: vscode.WorkspaceFolder | undefined) { - return { - name: "Arduino", - type: "arduino", - request: "launch", - program: "${file}", - cwd: "${workspaceFolder}", - MIMode: "gdb", - targetArchitecture: "arm", - miDebuggerPath: "", - debugServerPath: "", - debugServerArgs: "", - customLaunchSetupCommands: [ - { - text: "target remote localhost:3333", - }, - { - text: "file \"${file}\"", - }, - { - text: "load", - }, - { - text: "monitor reset halt", - }, - { - text: "monitor reset init", - }, - ], - stopAtEntry: true, - serverStarted: "Info\\ :\\ [\\w\\d\\.]*:\\ hardware", - launchCompleteCommand: "exec-continue", - filterStderr: true, - args: [], - }; - } - - private async resolveDebugConfigurationAsync(config: vscode.DebugConfiguration) { - if (!ArduinoContext.initialized) { - await ArduinoActivator.activate(); - } - - if (VscodeSettings.getInstance().logLevel === constants.LogLevel.Verbose && !config.logging) { - config = { - ...config, logging: { - engineLogging: true, - }, - }; - } - - if (!ArduinoContext.boardManager.currentBoard) { - vscode.window.showErrorMessage("Please select a board."); - return undefined; - } - - if (!this.resolveOpenOcd(config)) { - return undefined; - } - - if (!await this.resolveOpenOcdOptions(config)) { - return undefined; - } - - if (!this.resolveDebuggerPath(config)) { - return undefined; - } - - if (!await this.resolveProgramPath(config)) { - return undefined; - } - - // Use the C++ debugger MIEngine as the real internal debugger - config.type = "cppdbg"; - const dc = DeviceContext.getInstance(); - Logger.traceUserData("start-cppdbg", { board: dc.board }); - return config; - } - - private async resolveProgramPath(config) { - const dc = DeviceContext.getInstance(); - - if (!config.program || config.program === "${file}") { - const outputFolder = path.join(dc.output || `.build`); - const outputPath = path.join(ArduinoWorkspace.rootPath, outputFolder); - - // if the directory was already there, clear the folder so that it's not corrupted from previous builds. - if (util.directoryExistsSync(outputPath)) { - util.rmdirRecursivelySync(outputPath); - } - - util.mkdirRecursivelySync(outputPath); - if (!dc.sketch || !util.fileExistsSync(path.join(ArduinoWorkspace.rootPath, dc.sketch))) { - await dc.resolveMainSketch(); - } - - if (!dc.sketch) { - vscode.window.showErrorMessage("No sketch file was found. Please specify the sketch in the arduino.json file"); - return false; - } - - if (!util.fileExistsSync(path.join(ArduinoWorkspace.rootPath, dc.sketch))) { - vscode.window.showErrorMessage(`Cannot find ${dc.sketch}, Please specify the sketch in the arduino.json file`); - return false; - } - config.program = path.join(outputPath, `${path.basename(dc.sketch)}.elf`); - - // always compile elf to make sure debug the right elf - if (!await ArduinoContext.arduinoApp.build(BuildMode.Verify, outputFolder)) { - vscode.window.showErrorMessage("Failed to verify the program, please check the output for details."); - return false; - } - - config.program = config.program.replace(/\\/g, "/"); - - config.customLaunchSetupCommands.forEach((obj) => { - if (obj.text && obj.text.indexOf("${file}") > 0) { - obj.text = obj.text.replace(/\$\{file\}/, config.program); - } - }); - } - if (!util.fileExistsSync(config.program)) { - vscode.window.showErrorMessage("Cannot find the elf file."); - return false; - } - return true; - } - - private resolveDebuggerPath(config) { - if (!config.miDebuggerPath) { - config.miDebuggerPath = platform.findFile(platform.getExecutableFileName("arm-none-eabi-gdb"), - path.join(ArduinoContext.arduinoApp.settings.packagePath, "packages", ArduinoContext.boardManager.currentBoard.getPackageName())); - } - if (!util.fileExistsSync(config.miDebuggerPath)) { - config.miDebuggerPath = ArduinoContext.debuggerManager.miDebuggerPath; - } - if (!util.fileExistsSync(config.miDebuggerPath)) { - vscode.window.showErrorMessage("Cannot find the debugger path."); - return false; - } - return true; - } - - private resolveOpenOcd(config) { - if (!config.debugServerPath) { - config.debugServerPath = platform.findFile(platform.getExecutableFileName("openocd"), - path.join(ArduinoContext.arduinoApp.settings.packagePath, "packages", - ArduinoContext.boardManager.currentBoard.getPackageName())); - } - if (!util.fileExistsSync(config.debugServerPath)) { - config.debugServerPath = ArduinoContext.debuggerManager.debugServerPath; - } - if (!util.fileExistsSync(config.debugServerPath)) { - vscode.window.showErrorMessage("Cannot find the OpenOCD from the launch.json debugServerPath property." + - "Please input the right path of OpenOCD"); - return false; - } - - return true; - } - - private async resolveOpenOcdOptions(config) { - if (config.debugServerPath && !config.debugServerArgs) { - try { - config.debugServerArgs = await ArduinoContext.debuggerManager.resolveOpenOcdOptions(config); - if (!config.debugServerArgs) { - return false; - } - } catch (error) { - vscode.window.showErrorMessage(error.message); - return false; - } - } - return true; - } -} diff --git a/src/debug/debuggerManager.ts b/src/debug/debuggerManager.ts deleted file mode 100644 index 5546e8dd..00000000 --- a/src/debug/debuggerManager.ts +++ /dev/null @@ -1,159 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. - -import * as fs from "fs"; -import * as path from "path"; -import * as vscode from "vscode"; - -import { IArduinoSettings } from "../arduino/arduinoSettings"; -import { BoardManager } from "../arduino/boardManager"; -import * as platform from "../common/platform"; -import * as util from "../common/util"; -import { DeviceContext } from "../deviceContext"; - -export class DebuggerManager { - private _usbDetector; - private _debugServerPath: string; - private _miDebuggerPath: string; - private _debuggerMappings: any = {}; - private _debuggerBoardMappings: any = {}; - constructor( - private _extensionRoot: string, - private _arduinoSettings: IArduinoSettings, - private _boardManager: BoardManager) { - } - - public initialize() { - const debugFileContent = fs.readFileSync(path.join(this._extensionRoot, "misc", "debuggerUsbMapping.json"), "utf8"); - const usbFileContent = fs.readFileSync(path.join(this._extensionRoot, "misc", "usbmapping.json"), "utf8"); - - for (const _debugger of JSON.parse(debugFileContent)) { - if (Array.isArray(_debugger.pid)) { - for (const pid of _debugger.pid) { - this._debuggerMappings[`${pid}%${_debugger.vid}`] = { ..._debugger, pid, vid: _debugger.vid }; - } - } else { - this._debuggerMappings[`${_debugger.pid}%${_debugger.vid}`] = { ..._debugger, pid: _debugger.pid, vid: _debugger.vid }; - } - } - for (const config of JSON.parse(usbFileContent)) { - for (const board of config.boards) { - if (board.interface || board.target) { - this._debuggerBoardMappings[[board.package, board.architecture, board.id].join(":")] = board; - } - } - } - // For anyone looking at blame history, I doubt this import works as-is. - // I swapped it out for the old import to remove dependency on "node-usb-native", - // but otherwise anything that was broken before is still broken. - this._usbDetector = require("usb-detection"); - this._debugServerPath = platform.findFile(platform.getExecutableFileName("openocd"), - path.join(this._arduinoSettings.packagePath, "packages")); - if (!util.fileExistsSync(this._debugServerPath)) { - this._debugServerPath = ""; - } - - this._miDebuggerPath = platform.findFile(platform.getExecutableFileName("arm-none-eabi-gdb"), - path.join(this._arduinoSettings.packagePath, "packages")); - if (!util.fileExistsSync(this._miDebuggerPath)) { - this._miDebuggerPath = ""; - } - } - - public get miDebuggerPath(): string { - return this._miDebuggerPath; - } - - public get debugServerPath(): string { - return this._debugServerPath; - } - - public async listDebuggers(): Promise { - const usbDeviceList = await this._usbDetector.find(); - const keys = []; - const results = []; - usbDeviceList.forEach((device) => { - if (device.vendorId && device.productId) { - /* tslint:disable:max-line-length*/ - const key = util.convertToHex(device.productId, 4) + "%" + util.convertToHex(device.vendorId, 4); - const relatedDebugger = this._debuggerMappings[key]; - if (relatedDebugger && keys.indexOf(key) < 0) { - keys.push(key); - results.push(relatedDebugger); - } - } - }); - return results; - } - - public async resolveOpenOcdOptions(config): Promise { - const board = this._boardManager.currentBoard.key; - const debugConfig = this._debuggerBoardMappings[board]; - const dc = DeviceContext.getInstance(); - const debuggerConfigured: string = dc.debugger_; - if (!debugConfig) { - throw new Error(`Debug for board ${this._boardManager.currentBoard.name} is not supported by now.`); - } - let resolvedDebugger; - const debuggers = await this.listDebuggers(); - if (!debuggers.length) { - throw new Error(`No supported debuggers are connected.`); - } - // rule 1: if this board has debuggers, use its own debugger - if (debugConfig.interface) { - resolvedDebugger = debuggers.find((_debugger) => { - return _debugger.short_name === debugConfig.interface || _debugger.config_file === debugConfig.interface; - }); - if (!resolvedDebugger) { - throw new Error(`Debug port for board ${this._boardManager.currentBoard.name} is not connected.`); - } - } - // rule 2: if there is only one debugger, use the only debugger - if (!resolvedDebugger && !debuggerConfigured && debuggers.length === 1) { - resolvedDebugger = debuggers[0]; - } - - // rule 3: if there is any configuration about debugger, use this configuration - if (!resolvedDebugger && debuggerConfigured) { - resolvedDebugger = debuggers.find((_debugger) => { - return _debugger.short_name === debuggerConfigured || _debugger.config_file === debuggerConfigured; - }); - } - if (!resolvedDebugger) { - const chosen = await vscode.window.showQuickPick(debuggers.map((l): vscode.QuickPickItem => { - return { - description: `(0x${l.vid}:0x${l.pid})`, - label: l.name, - }; - }).sort((a, b): number => { - return a.label === b.label ? 0 : (a.label > b.label ? 1 : -1); - }), { placeHolder: "Select a debugger" }); - if (chosen && chosen.label) { - resolvedDebugger = debuggers.find((_debugger) => _debugger.name === chosen.label); - if (resolvedDebugger) { - dc.debugger_ = resolvedDebugger.config_file; - } - } - if (!resolvedDebugger) { - return ""; - } - } - - const debugServerPath = config.debugServerPath; - let scriptsFolder = path.join(path.dirname(debugServerPath), "../scripts/"); - if (!util.directoryExistsSync(scriptsFolder)) { - scriptsFolder = path.join(path.dirname(debugServerPath), "../share/openocd/scripts/"); - } - if (!util.directoryExistsSync(scriptsFolder)) { - throw new Error("Cannot find scripts folder from openocd."); - } - // TODO: need to config gdb port other than hard-coded 3333 - if (resolvedDebugger.config_file.includes("jlink")) { - // only swd is supported now - /* tslint:disable:max-line-length*/ - return `-s ${scriptsFolder} -f interface/${resolvedDebugger.config_file} -c "transport select swd" -f target/${debugConfig.target} -c "telnet_port disabled" -c "tcl_port disabled"`; - } - /* tslint:disable:max-line-length*/ - return `-s ${scriptsFolder} -f interface/${resolvedDebugger.config_file} -f target/${debugConfig.target} -c "telnet_port disabled" -c "tcl_port disabled"`; - } -} diff --git a/src/deviceContext.ts b/src/deviceContext.ts index 34bd9807..852b9815 100644 --- a/src/deviceContext.ts +++ b/src/deviceContext.ts @@ -39,11 +39,6 @@ export interface IDeviceContext { */ output: string; - /** - * Arduino debugger - */ - - debugger_: string; /** * Current selected programmer. @@ -183,7 +178,6 @@ export class DeviceContext implements IDeviceContext, vscode.Disposable { public get onChangeBoard() { return this._settings.board.emitter.event } public get onChangeSketch() { return this._settings.sketch.emitter.event } public get onChangeOutput() { return this._settings.output.emitter.event } - public get onChangeDebugger() { return this._settings.debugger.emitter.event } public get onChangeISAutoGen() { return this._settings.intelliSenseGen.emitter.event } public get onChangeConfiguration() { return this._settings.configuration.emitter.event } public get onChangePrebuild() { return this._settings.prebuild.emitter.event } @@ -234,15 +228,6 @@ export class DeviceContext implements IDeviceContext, vscode.Disposable { this.saveContext(); } - public get debugger_() { - return this._settings.debugger.value; - } - - public set debugger_(value: string) { - this._settings.debugger.value = value; - this.saveContext(); - } - public get intelliSenseGen() { return this._settings.intelliSenseGen.value; } diff --git a/src/deviceSettings.ts b/src/deviceSettings.ts index 439c4ee0..4913c0c2 100644 --- a/src/deviceSettings.ts +++ b/src/deviceSettings.ts @@ -137,7 +137,6 @@ export class DeviceSettings { public board = new StrSetting(); public sketch = new StrSetting(); public output = new StrSetting(); - public debugger = new StrSetting(); public intelliSenseGen = new StrSetting(); public configuration = new StrSetting(); public prebuild = new StrSetting(); @@ -154,7 +153,6 @@ export class DeviceSettings { this.board.modified || this.sketch.modified || this.output.modified || - this.debugger.modified || this.intelliSenseGen.modified || this.configuration.modified || this.prebuild.modified || @@ -170,7 +168,6 @@ export class DeviceSettings { this.board.commit(); this.sketch.commit(); this.output.commit(); - this.debugger.commit(); this.intelliSenseGen.commit(); this.configuration.commit(); this.prebuild.commit(); @@ -188,7 +185,6 @@ export class DeviceSettings { this.board.reset(); this.sketch.reset(); this.output.reset(); - this.debugger.reset(); this.intelliSenseGen.reset(); this.configuration.reset(); this.prebuild.reset(); @@ -215,7 +211,6 @@ export class DeviceSettings { this.sketch.value = settings.sketch; this.configuration.value = settings.configuration; this.output.value = settings.output; - this.debugger.value = settings.debugger; this.intelliSenseGen.value = settings.intelliSenseGen; this.prebuild.value = settings.prebuild; this.postbuild.value = settings.postbuild; @@ -261,7 +256,6 @@ export class DeviceSettings { settings.port = this.port.value; settings.board = this.board.value; settings.output = this.output.value; - settings.debugger = this.debugger.value; settings.intelliSenseGen = this.intelliSenseGen.value; settings.configuration = this.configuration.value; settings.programmer = this.programmer.value; diff --git a/src/extension.ts b/src/extension.ts index ee8eeb0b..e4764ebf 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -21,7 +21,6 @@ import { import { validateArduinoPath } from "./common/platform"; import * as util from "./common/util"; import { ArduinoWorkspace } from "./common/workspace"; -const arduinoDebugConfigurationProviderModule = impor("./debug/configurationProvider") as typeof import ("./debug/configurationProvider"); import { DeviceContext } from "./deviceContext"; const completionProviderModule = impor("./langService/completionProvider") as typeof import ("./langService/completionProvider"); import { BuildMode } from "./arduino/arduino"; @@ -326,8 +325,6 @@ export async function activate(context: vscode.ExtensionContext) { const completionProvider = new completionProviderModule.CompletionProvider(); context.subscriptions.push(vscode.languages.registerCompletionItemProvider(ARDUINO_MODE, completionProvider, "<", '"', ".")); - context.subscriptions.push(vscode.debug.registerDebugConfigurationProvider("arduino", new - arduinoDebugConfigurationProviderModule.ArduinoDebugConfigurationProvider())); if (ArduinoWorkspace.rootPath && ( util.fileExistsSync(path.join(ArduinoWorkspace.rootPath, ARDUINO_CONFIG_FILE)) diff --git a/test/devicecontext.test.ts b/test/devicecontext.test.ts index f948f62c..73c3778d 100644 --- a/test/devicecontext.test.ts +++ b/test/devicecontext.test.ts @@ -14,7 +14,6 @@ suite("Arduino: Device Context config", () => { assert.equal(deviceContext.sketch, "blink.ino"); assert.equal(deviceContext.configuration, "cpu=atmega328"); assert.equal(deviceContext.output, null); - assert.equal(deviceContext.debugger_, null); assert.equal(deviceContext.programmer, "arduino:jtag3isp"); done(); }); diff --git a/test/resources/blink/.vscode/arduino.json b/test/resources/blink/.vscode/arduino.json index 32bd2323..10ba5ecf 100644 --- a/test/resources/blink/.vscode/arduino.json +++ b/test/resources/blink/.vscode/arduino.json @@ -3,7 +3,6 @@ "port": "COM4", "board": "arduino:avr:diecimila", "output": null, - "_debugger": null, "configuration": "cpu=atmega328", "programmer": "arduino:jtag3isp" } \ No newline at end of file