Skip to content

Debugging ARM64 on Windows with Visual Studio

Guille Polito edited this page Dec 2, 2020 · 1 revision

Last update: 2/12/2020

If you have a Windows ARM64 machine such as the Surface Pro X, chances are you may want to debug native ARM64 applications with it. However, as of today 2/12/2020, Windows does not support local debugging of ARM64 applications, but only remote debugging. Moreover, CMake projects cannot be configured to use remote debugging, or I did not find it after hours of searching and googling :).

This page covers how to debug the CMake project of the VM on ARM64 using the Windows remote debugger and Visual studio. The remote debugger can be used from a separate machine, or from the same machine too, giving mostly the impression of a local debugger. Yet, there are some glitches and remaining problems.

Installing the Windows Remote Debugger on the ARM64 Machine

The first thing to do is to install the Windows Remote Debugger application on the target machine, the machine we want to debug on. The instructions are in here.

Basically, just install the remote tools package, and open it a first time to set up the network configuration. Make sure you go to the options and you check the port of the connection or set it to the port of your preference

Getting rid of CMake-VS integration (?)

Visual Studio CMake integration is nice, though it does not support our debugging use case. Visual Studio CMake integration so far lacks proper support for ARM64 configurations, and most of the debugging options and features one can set from a normal project. So, instead of opening a CMake-tailored Visual Studio project, we are going to create a normal Visual Studio solution from the command line, and then open it as a normal solution.

To manually create it run the following, specifying your own configuration arguments. Notice that this post was only tested in Visual Studio 2019.

$ cmake -B ARM64Solution -S ../repo -G "Visual Studio 16 2019" -A ARM64

Notice that the solution we did create will not contain the Slang-generated source files of the VM. If you want to generate them, you may run from the command line.

$ cmake --build ARM64Solution --target generate-sources

or copy them from some previous generation if you already have them.

Now you will see CMake has created a lot of .sln and .vcxproj files. Open the solution using visual studio: Done! You're almost there!

Configuring the Project for debugging

The basic information to debug the VM using this setup is now the one described in here: how to remote debug c++ apps. Basically this can be resumed in two steps: 1) configure debugging to use remote debugging on localhost:ourPort and 2) set up deployment of binaries.

Step 1, configure debugging to use remote, can be easily done as specified in the link above: right click on the project, debugging, turn on remote debugging, configure the fields as in the link.

Step 2, set up deployment of binaries, is required because otherwise the debugging runtime seems to not be available by default in the machine. Deployment takes care of deploying the windows debugging runtime too.

Finally, an extra problem I've found was that CMake creates some extra targets/projects ALL_BUILD and ZERO_CHECK that cannot be properly deployed. I removed them from the solution and everything worked like a charm.

Now clicking on the run/debug button will compile, "remotely" deploy, launch, and connect to the VM, and you'll be debugging it natively in ARM64!

To finish, some caveats

Manually removing the ALL_BUILD and ZERO_CHECK projects to debug does not seem the very best solution, I'd like to have something more straight forward that works by default. Let's hope VS support for local debugging comes soon.

Clone this wiki locally