Skip to content

Commit

Permalink
moving to cdt gdb adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
brianignacio5 committed Mar 5, 2024
1 parent 922268e commit 09e2ef7
Show file tree
Hide file tree
Showing 33 changed files with 5,762 additions and 199 deletions.
46 changes: 44 additions & 2 deletions docs/DEBUGGING.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,17 @@
The Visual Studio Code uses `.vscode/launch.json` to configure debug as specified in [Visual Studio Code Debugging](https://code.visualstudio.com/docs/editor/debugging#_launch-configurations).

We recommend using our Eclipse CDT GDB configuration to debug your ESP-IDF projects, but you can configure launch.json for any GDB debugger extension like [Microsoft C/C++ Extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools) and [Native Debug](https://marketplace.visualstudio.com/items?itemName=webfreak.debug). The ESP-IDF Debug adapter will be deprecated and removed in the next major release.
We recommend using our Eclipse CDT GDB Adapter configuration to debug your ESP-IDF projects, but you can configure launch.json for any GDB debugger extension like [Microsoft C/C++ Extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools) and [Native Debug](https://marketplace.visualstudio.com/items?itemName=webfreak.debug). The ESP-IDF Debug adapter will be deprecated and removed in the next major release.

Our extension implements a `ESP-IDF: Peripheral View` tree view in the `Run and Debug` view which will use the SVD file defined in the `IDF SVD File Path (idf.svdFilePath)` configuration setting to be defined in the [settings.json](../SETTINGS.md) to populate a set of peripherals registers values for the active debug session target. You could find Espressif SVD files from [Espressif SVD](https://github.com/espressif/svd).

If `initCommands`, `gdbinitFile` or `initGdbCommands` are defined in launch.json, make sure to include the following commands for debug session to properly work as shown in [JTAG Debugging with command line](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/jtag-debugging/using-debugger.html#command-line).

## Using the Eclipse CDT GDB Debug Adapter

The Eclipse CDT team have published a GDB debug adapter as NPM package which we include in our extension dependencies. For more information about the debug adapter please review [CDT-GDB-Adapter Github Repository](https://github.com/eclipse-cdt-cloud/cdt-gdb-adapter). The arguments in launch.json are
The Eclipse CDT team have published a GDB debug adapter as NPM package which we include in our extension dependencies. For more information about the debug adapter please review [CDT-GDB-Adapter Github Repository](https://github.com/eclipse-cdt-cloud/cdt-gdb-adapter).

The basic arguments in launch.json are

```JSON
{
Expand All @@ -38,6 +42,44 @@ The Eclipse CDT team have published a GDB debug adapter as NPM package which we
}
```

where `program` and `gdb` can be resolved by extension. Some additional arguments you might use are:

- `runOpenOCD`: (Default: true). Run extension openOCD Server.
- `verifyAppBinBeforeDebug`: (Default: false) Verify that current ESP-IDF project binary is the same as binary in chip.
- `logFile`: Absolute path to the file to log interaction with gdb.
- `verbose`: Produce verbose log output.
- `environment`: Environment variables to apply to the ESP-IDF Debug Adapter. It will replace global environment variables and environment variables used by the extension.

```json
"environment": {
"VAR": "Value"
}
```

- `imageAndSymbols`:

```json
"imageAndSymbols": {
"symbolFileName": "If specified, a symbol file to load at the given (optional) offset",
"symbolOffset": "If symbolFileName is specified, the offset used to load",
"imageFileName": "If specified, an image file to load at the given (optional) offset",
"imageOffset": "If imageFileName is specified, the offset used to load"
}
```

- `target`: Configuration for target to be attached.

```json
"target": {
"type": "The kind of target debugging to do. This is passed to -target-select (defaults to remote)",
"host": "Target host to connect to (defaults to 'localhost', ignored if parameters is set)",
"port": "Target port to connect to (defaults to value captured by serverPortRegExp, ignored if parameters is set)",
"parameters": "Target parameters for the type of target. Normally something like localhost:12345. (defaults to `${host}:${port}`)"
}
```

Other arguments please review this extension's package.json `gdbtarget` debugger contribution.

## Use Microsoft C/C++ Extension to Debug

The user can also use [Microsoft C/C++ Extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools) to debug, the community recommend this launch.json configuration:
Expand Down
21 changes: 12 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1464,8 +1464,7 @@
},
{
"type": "gdbtarget",
"label": "GDB Target",
"program": "./node_modules/cdt-gdb-adapter/dist/debugTargetAdapter.js",
"label": "Eclipse GDB Target",
"runtime": "node",
"configurationAttributes": {
"launch": {
Expand All @@ -1479,6 +1478,11 @@
"type": "string",
"description": "Working directory (cwd) to use when launching gdb. Defaults to the directory of the 'program'"
},
"runOpenOCD": {
"type": "boolean",
"description": "Run OpenOCD Server",
"default": true
},
"environment": {
"additionalProperties": {
"type": [
Expand Down Expand Up @@ -1917,14 +1921,12 @@
"type": "gdbtarget",
"request": "attach",
"name": "Eclipse CDT GDB Adapter",
"program": "${workspaceFolder}/build/${command:espIdf.getProjectName}.elf",
"initCommands": [
"set remote hardware-watchpoint-limit 2",
"mon reset halt",
"maintenance flush register-cache",
"thb app_main"
],
"gdb": "${command:espIdf.getXtensaGdb}",
"target": {
"port": "3333"
}
Expand All @@ -1938,14 +1940,12 @@
"type": "gdbtarget",
"request": "attach",
"name": "Eclipse CDT GDB Adapter",
"program": "^\"\\${workspaceFolder}/build/\\${command:espIdf.getProjectName}.elf\"",
"initCommands": [
"set remote hardware-watchpoint-limit 2",
"mon reset halt",
"maintenance flush register-cache",
"thb app_main"
],
"gdb": "^\"\\${command:espIdf.getXtensaGdb}\"",
"target": {
"port": "3333"
}
Expand Down Expand Up @@ -2035,14 +2035,15 @@
"@types/ws": "^7.2.5",
"@types/xml2js": "^0.4.11",
"@types/yauzl": "^2.9.1",
"@vscode/debugadapter": "^1.53.0",
"@vscode/debugadapter": "^1.65.0",
"@vscode/debugadapter-testsupport": "^1.51.0",
"@vscode/debugprotocol": "^1.53.0",
"@vscode/debugprotocol": "^1.65.0",
"@vscode/extension-telemetry": "0.4.8",
"@vscode/test-electron": "^2.1.2",
"@vue/compiler-sfc": "^3.3.4",
"bulma": "^0.9.3",
"chai": "^4.3.4",
"copy-webpack-plugin": "^12.0.2",
"css-loader": "^3.1.0",
"d3-scale": "^4.0.2",
"file-loader": "^6.2.0",
Expand All @@ -2062,6 +2063,7 @@
"reflect-metadata": "^0.1.13",
"sass": "^1.49.8",
"sass-loader": "^10",
"string-replace-loader": "^3.1.0",
"style-loader": "^3.3.1",
"ts-loader": "^9.4.4",
"typescript": "^5.2.2",
Expand All @@ -2081,7 +2083,6 @@
"assert": "^2.1.0",
"axios": "^1.6.0",
"bignumber.js": "^9.0.1",
"cdt-gdb-adapter": "^0.0.32",
"del": "^4.1.1",
"es6-promisify": "^6.0.0",
"follow-redirects": "^1.15.4",
Expand All @@ -2097,9 +2098,11 @@
"plotly.js-dist-min": "^2.26.1",
"postcss": "^8.4.31",
"sanitize-html": "^2.7.0",
"serialport": "^12.0.0",
"stream-browserify": "^3.0.0",
"tar-fs": "^2.0.0",
"tree-kill": "^1.2.2",
"utf8": "^3.0.0",
"vscode-languageclient": "^5.2.1",
"vscode-languageserver": "^5.2.1",
"vscode-nls": "^4.0.0",
Expand Down
Loading

0 comments on commit 09e2ef7

Please sign in to comment.