|
| 1 | +# GNU source level debugger for Visual Studio Code |
| 2 | + |
| 3 | +This extension for Visual Studo Code enables debugging of bare metal C/C++ |
| 4 | +programs for Arm Cortex processors. The extension implements the Visual Studio |
| 5 | +Code debug adaptor for Arm embedded processors. This extension is suited for |
| 6 | +macOS, Linux and Window. |
| 7 | + |
| 8 | +<div align="center"> |
| 9 | +<img src="https://raw.githubusercontent.com/metalcode-eu/gnu-debugger/master/images/GNU-debugger-512x512.png" alt="GNU debugger" width="20%"> |
| 10 | +<img src="https://raw.githubusercontent.com/metalcode-eu/gnu-debugger/master/images/macOS-512x512.png" alt="macOS" width="20%"> |
| 11 | +<img src="https://raw.githubusercontent.com/metalcode-eu/gnu-debugger/master/images/Linux-512x512.png" alt="Linux" width="20%"> |
| 12 | +<img src="https://raw.githubusercontent.com/metalcode-eu/gnu-debugger/master/images/Windows-512x512.png" alt="Windows" width="20%"> |
| 13 | +</div> |
| 14 | + |
| 15 | +The adaptor uses the GNU source level debugger (GDB) that enables examination of |
| 16 | +your running program. You can find background documentation about the GNU source |
| 17 | +level debugger |
| 18 | +[here](https://sourceware.org/gdb/current/onlinedocs/gdb/). |
| 19 | + |
| 20 | +# Dependencies |
| 21 | + |
| 22 | +- GDB client from GNU toolchain for you operating system (one of the following) |
| 23 | + - [GNU Arm embedded toolchain for macOS](https://marketplace.visualstudio.com/items?itemName=metalcode-eu.darwin-arm-none-eabi) |
| 24 | + - [GNU Arm embedded toolchain for Linux (64-bit)](https://marketplace.visualstudio.com/items?itemName=metalcode-eu.linux-arm-none-eabi) |
| 25 | + - [GNU Arm embedded toolchain for Windows](https://marketplace.visualstudio.com/items?itemName=metalcode-eu.windows-arm-none-eabi) |
| 26 | +- GDB server for your debug probe (one of the following) |
| 27 | + - [SEGGER J-Link probe](https://www.segger.com/downloads/jlink/) |
| 28 | + - ST-Link debug probe upgraded to J-Link probe |
| 29 | + |
| 30 | +If you have a development board with an onboard ST-Link debug probe you can |
| 31 | +upgrade the firmware to J-Link. More information for upgrading to J-Link may |
| 32 | +be found |
| 33 | +[here](https://www.segger.com/products/debug-probes/j-link/models/other-j-links/st-link-on-board/). |
| 34 | + |
| 35 | +# Features |
| 36 | +<img src="https://raw.githubusercontent.com/metalcode-eu/gnu-debugger/master/images/play-bar.png" alt="playbar"> |
| 37 | + |
| 38 | +- source level debugging of C and C+++ |
| 39 | +- set / clear breakpoints |
| 40 | +- pause / continue, step over, step into, step out, restart |
| 41 | +- change variables |
| 42 | +- watch expressions |
| 43 | + |
| 44 | +## Output format |
| 45 | +Visual Studio Code has no standard way to set the format of variables. In this |
| 46 | +extension you can change the output format with a number prefix. |
| 47 | + |
| 48 | +<img src="https://raw.githubusercontent.com/metalcode-eu/gnu-debugger/master/images/set-format.png" alt="set format"> |
| 49 | + |
| 50 | +Use the following number prefixes: |
| 51 | +- *0b* = binary |
| 52 | +- *0o* = octal |
| 53 | +- *0d* = decimal |
| 54 | +- *0x* = hexadecimal |
| 55 | +- *0n* = natural (back to GDB default output format) |
| 56 | + |
| 57 | +## Custom variables |
| 58 | +To view/change global variables on every debug session add a *customVariables* |
| 59 | +list to the launch.json. |
| 60 | + |
| 61 | +<div align="center"> |
| 62 | +<img src="https://raw.githubusercontent.com/metalcode-eu/gnu-debugger/master/images/custom.png" alt="custom variables"> |
| 63 | +</div> |
| 64 | + |
| 65 | +Here is an example launch.json for the Infineon XMC 2Go a low cost board with |
| 66 | +an Arm Cortex-M0 processor. |
| 67 | + |
| 68 | +<div align="center"> |
| 69 | +<img src="https://raw.githubusercontent.com/metalcode-eu/gnu-debugger/master/images/XMC2Go.jpg" alt="XMC 2Go"> |
| 70 | +</div> |
| 71 | + |
| 72 | +```javascript |
| 73 | +{ |
| 74 | + // Visual Studio Code launch.json for XMC 2Go development board |
| 75 | + "version": "0.2.0", |
| 76 | + "configurations": [ |
| 77 | + { |
| 78 | + "type": "gnu-debugger", |
| 79 | + "request": "launch", |
| 80 | + "name": "GNU debugger", |
| 81 | + "program": "${workspaceFolder}/build.nosync/firmware.elf", |
| 82 | + "toolchain": "${config:arm-none-eabi.bin}", |
| 83 | + "client": "arm-none-eabi-gdb", |
| 84 | + "server": "JLinkGDBServer", |
| 85 | + "windows": { |
| 86 | + "server": "C:/Program Files/SEGGER/JLink_V632g/JLinkGDBServerCL.exe", |
| 87 | + }, |
| 88 | + "serverArgs": [ |
| 89 | + "-device", "XMC1100-0064", |
| 90 | + "-if", "SWD", |
| 91 | + "-speed", "4000" |
| 92 | + ], |
| 93 | + "serverPort": 2331, |
| 94 | + "customVariables": [ |
| 95 | + "port0", |
| 96 | + "port1", |
| 97 | + "port2", |
| 98 | + ], |
| 99 | + "autoRun": false, |
| 100 | + "debugOutput": false, |
| 101 | + "preLaunchTask": "build firmware" |
| 102 | + } |
| 103 | + ] |
| 104 | +} |
| 105 | +``` |
| 106 | + |
| 107 | +# Principle of operation |
| 108 | +The extension uses the machine oriented text interface of the GNU source level |
| 109 | +debugger |
| 110 | +([GDB/MI](https://sourceware.org/gdb/current/onlinedocs/gdb/GDB_002fMI.html#GDB_002fMI)). |
| 111 | +The adaptor translates workbench.action.debug commands to GDB/MI commands and |
| 112 | +translate GDB/MI outputs to graphical representation inside Visual Studio Code. |
| 113 | + |
| 114 | +For Arm embedded platforms the GNU source level debugger consists of two parts: |
| 115 | +- GDB client |
| 116 | +- GDB server |
| 117 | + |
| 118 | +Both programs must be installed on your development system. |
| 119 | + |
| 120 | +### GDB client |
| 121 | +The GDB client is supplied by Arm free of charge as part of the Arm embedded |
| 122 | +toolchain. For convience I have packaged the latest toolchain for different |
| 123 | +operating systems as Visual Studio Code extension as mentioned in the |
| 124 | +dependencies section. |
| 125 | + |
| 126 | +You can find GDB client for Arm embedded processors under the bin directory of |
| 127 | +the toolchain. The name of the GDB client program is: |
| 128 | + |
| 129 | +- arm-none-eabi-gdb (macOS, Linux) |
| 130 | +- arm-none-eabi-gdb.exe (Windows) |
| 131 | + |
| 132 | +The GDB client communicates with a GDB server through a network connection |
| 133 | +(TCP/IP socket). |
| 134 | + |
| 135 | +### GDB server |
| 136 | +The GDB server is supplied by the manufacterer of the debug probe. The most |
| 137 | +widely used lines of debug probes are the J-Link and ST-Link debug probes. |
| 138 | +The name of the SEGGER J-Link GDB server program is: |
| 139 | + |
| 140 | +- JLinkGDBServer (macOS, Linux) |
| 141 | + (symbolic link, the actual command line program is JLinkGDBServerCLExe) |
| 142 | +- JLinkGDBServerCL.exe (Windows) |
| 143 | + |
| 144 | +If you have a development board with an onboard ST-Link debug probe you can |
| 145 | +upgrade the firmware to J-Link. More information for upgrading to J-Link may |
| 146 | +be found |
| 147 | +[here](https://www.segger.com/products/debug-probes/j-link/models/other-j-links/st-link-on-board/). |
| 148 | + |
| 149 | +# Release Notes |
| 150 | + |
| 151 | +### Version 0.0.3 |
| 152 | +Changes in visual studio code 1.28.1 caused a problem. Updated all vscode |
| 153 | +dependencies to the latest version. |
| 154 | + |
| 155 | +### Version 0.0.2 |
| 156 | +Fixed a bug causing a error message "resource is not available". |
| 157 | +This problems shows when you have a source file compiled without debug |
| 158 | +information. Visual Studio code now shows "Unknown Source" if the debug |
| 159 | +information is missing. |
| 160 | + |
| 161 | +### Version 0.0.1 |
| 162 | +First version tested on macOS, Linux and Windows. |
0 commit comments