The Microsoft Visual Studio Code is a great IDE, but does not (yet?) implement features for true embedded usage. Or things are there to some level, but hard to use. One of these things is how to step in the assembly code. This article shows how to do this.
If doing high level development, assembly code is probably not of interest. However, doing embedded system development, being able to see and step through the assembly instructions is an essential feature.
Currently assembly stepping in VSC is not easy accessible. I’m using the version 1.6.1 of Visual Studio Code, and I hope this will be improved in a later release.
To do assembly stepping, use the Command Palette (CTRL+SHIFT+P) with ‘Cortex-Debug: Set Force Disassembly‘:
Then use ‘Forced: Always show disassembly for functions‘:
Now I can step through the assembly code:
As a downside: this does not sync with the C/C++ code shown on the left as one would expect: this is not supported in VSC.
To switch back to C/C++ stepping, do the same again, but this time setting to ‘Auto’:
Stepping through Startup Code
For embedded code it is not uncommon to step through the assembly code in the startup.
One can set breakpoints in the (Assembly) startup code: set a break-point in the left column and hit ‘restart’ and one can debug/step through the assembly code:
I’m using in above example the ‘correct’ *.S extension for assembly files (see an article on this for Eclipse here: Assembly Files in Eclipse CDT Projects). In case you have an assembly file with *.s extension, you need to configure VSC to accept breakpoints in other files, using the menu File > Preferences > Features > Debug > Allow Breakpoints Everywhere (thanks to Hubert for the hint!):
Debugging assembly instructions or source files is not as convenient as in Eclipse with Visual Studio Code, but possible. The hope is that Visual Studio Code will improve for embedded usage and especially debugging over time.
Happy assembling 🙂
- Visual Studio Code for C/C++ with ARM Cortex-M: Part 1 – Installation
- Visual Studio Code for C/C++ with ARM Cortex-M: Part 2 – Project
- Visual Studio Code for C/C++ with ARM Cortex-M: Part 3 – Build
- Visual Studio Code for C/C++ with ARM Cortex-M: Part 4 – Debug
- Visual Studio Code for C/C++ with ARM Cortex-M: Part 5 – ToolKit
- Visual Studio Code for C/C++ with ARM Cortex-M: Part 6 – IntelliSense
- Visual Studio Code for C/C++ with ARM Cortex-M: Part 7 – FreeRTOS
- Visual Studio Code for C/C++ with ARM Cortex-M: Part 8 – xPack C/C++ Managed Build Tools
- Visual Studio Code for C/C++ with ARM Cortex-M: Part 9 – RTT
- Visual Studio Code website: https://code.visualstudio.com/
- Examples on GitHub: https://github.com/ErichStyger/mcuoneclipse/tree/master/Examples/VisualStudioCode
I think its the little things that make VSC and embedded miss the mark for me. The only time I step through assembly is either if the code is written by myself (or as in your case NXP) or I need to see what the compiler is doing while debugging. I’m sure there are other use cases. So not being able to sync is just really annoying. But I think its great that you delve into what’s possible.
LikeLiked by 1 person
Yes, agreed. It is the sum of small items missing which makes it somewhat annoying. Clearly Microsoft is still living in another world (or me vice-versa). As well most of the real embedded stuff comes from third/open source extensions, not from Microsoft, at least today.
and yet Microsoft, AWS and Google are all hopping on the IOT bandwagon with their integrated RTOS/Cloud services and solutions so one would think they would improve the actual embedded coding tools… oh well.
LikeLiked by 1 person
IMHO, they all did that with acquiring companies and their IP, bundling existing things in way, trying to lock the customer base into their own cloud/solutions: I believe this was the primary purpose, not improving the tools, at least not in the first place.