Visual Studio Code for C/C++ with ARM Cortex-M: Part 10 – Assembly Stepping

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.

Outline

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.

Assembly Stepping

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!):

Summary

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 🙂

Links

4 thoughts on “Visual Studio Code for C/C++ with ARM Cortex-M: Part 10 – Assembly Stepping

  1. 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.

    Liked 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.

      Like

      • 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.

        Liked 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.

          Like

What do you think?

This site uses Akismet to reduce spam. Learn how your comment data is processed.