26 July 2016 - New version of Visual Micro Gdb for .ino and .cpp is released - Tested with Arduino Zero, M0 Pro and LM4F
tip: Follow the standard Visual Micro documentation to create new or open existing Arduino projects. Please use the forum for assistance and feedback. Requires the free Android Tools for Visual Studio to also be installed. You can also use board.txt or boards/platform.txt to add new gdb definitions.
Any visual micro project, with the android tools installed, can now run gdb debug without need for the cross platform projects used previously (still supported). For Gdb, automatic debugging can remain at default state (on).
Selecting the Arduino Zero/M0 (or board with debug.tool defined) and clicking "Debug>Start debugging" will start a GDB debug session. "Debug>Attach To Process" will start gdb without build/upload.
Existing users please note - Older project need a minor update
The Visual Micro new project templates now contain two new properties in the .vcproj files. However existing visual micro .vcxproj files currently need to be updated manually (or deleted and re-created using "file>open>arduino project") before GDB will work.
To edit a .vcproj users can right click a project in the solution explorer then click Unload. Then right click again and click "Edit project.vcxproj". Adding the ItemGroup and PropertyGroup shown below will allow gdb to work. fyi: I added them just prior to the existing <ItemGroup> entries.
Right click the project in the solution tree and select Reload project to reload the project again.
Old .vcxproj update to support gdb. Add the following xml:-
<ProjectCapability Include="VisualMicro" />
The gdb docs are out of date and being reworked. This document is currently the most up to date.
- Visual Micro uses the standard C++ tools of Visual Studio to provide Arduino programming. The C++ tools are a custom option durng install or at a later date via Control Panel>Add or remove programs.
- To keep the Visual Micro install small we currently use the Microsoft MI debugger that is installed with the Android tools for Visual Studio. If you are unsure how to install Android >>> Control panel>add or remove programs>visual studio
- Visual Micro is installed from within the Ide using "Tools>Extensions & Updates>Online"
- The Arduino Ide can be downloaded from the respective hardware vendor such as arduino.cc and arduino.org
- Visual Micro no longer expects a special cross platform project type for gdb. Any Visual Studio Arduino project will use gdb debugging if a debug capable (known) board is used. New gdb boards can be added to the config so ask in the forum for more info.
- Visual Micro will default to Serial/Usb debugging if a non-gdb compatible board is selected or if Andoid is not installed
- To compile, upload and start gdb debug click F5 or "Debug>Start Debugging". To start gdb debugging without compile and upload click "Debug>Attach To Process" (ensure a valid arduino sketch program is already loaded on the board)
- Sometimes debug might fail with an error about a missing or busy "port". To resolve this issue open Task Manager and terminate the OpenOCD process if it exists.
- Having more than 3 breakpoints can be a problem for many gdb boards so don't use more than 3 otherwise debug will be unstable.
- We found that every so often gdb doesn't start. It just shows a windows "connecting to localhost:3333". To resolve click cancel and then start the debug again.
- The reason for requiring the Android tools is because the tools installer also installs the "Microsoft MI Debug Engine". Visual Micro actually only needs the debug engine but currently checks for "Java" debug support to determine if it can run Gdb. In the future we will provide an MI Debug Engine installer that doesn't require Android and at that time the check to determine if GDB can be used will be changed from "Java" to some other check.
- Comatible with .ino source code
- Debug sketch, libraries and core
- Step by Line or Instruction
- Step Over, Step Out
- Move instruction pointer
- Set/move breakpoints (3 max)
- Inspect memory, locals, call stack
- Disassembly or source navigation
- Immediate expression evaluator
- Watch expressions, local expressions, auto expressions
- Breakpoints, trace points, conditional breakpoin expressions
- Pin variables during debug sessions. Easily see values. Add notes/comment.
- Drill down into variables
- Gdb command tool - optional manual interaction with the debugger (limited testing)
- Toolchain, ocd and gdb automatic configuration based on the selected Arduino board
- Automatic/background conversion between cpp and Arduino format .ino source code
- Auto highlight changed data - Easily see which registers and variables have changed.
- One button click: Build>Upload>Debug
NOTE: Compiler optimization can prevent breakpoints from becoming active.
Do not use more than 3 breakpoints!! 4 are supported but stepping runs out of steam with 4 and the debug stops responding.
If the debugger locks up then kill the openOCD.exe process in task manager. If it is not loaded then kill the MicroGdb.exe process.
If you can't upload or the board is in a bad state after debug discopnnect and reconnect or kill the OpenOCD.exe windows process if it has remained open.
Know lock up causes are:- 1) Source code out of date 2) Optimization prevents all breakpoints from being recognized 3) The odd strange quirk :)
- Some source code paths are incorrect causing temp folder sources instead of local project sources to open during debug.
- Stepping line position a little erratic sometimes see instruction stepping when line stepping was selected (maybe resolved in latest android tools dist).
Which backend Ide?
Use arduino.cc Ide for the Zero and use arduino.org for M0 Pro. You can experiment with burning new bootloader onto M0 board but it's not tested so at your own risk (see www public blogs for more info)
Please note: The IoT and Wifi examples mentioned in this document do not currently (15th Jan 2015) work with the Arduino.org backend ide.