visual-studiodebuggingvisual-c++visual-studio-debugginginline-assembly

Debugging inline assembly in C++ code in Visual Studio 2022 is broken


We are having issues with debugging inline assembly code in Visual Studio 2022 Community. It worked fine in previous versions, such as 2017, 2019. Even though the optimizations are disabled, debuggable assembly is set to Yes, support just my code debugging is set to No, Debug Information format is set to Program Database /Zi, Basic Runtime Checks are set to Default...

...the debugger incorrectly shows the current line, when stepping over an inline assembly code. It can be clearly seen when Debug Window Disassembly is shown - instructions are not detected properly to align to the source code. Thus when debugging without disassembly, debugger shows incorrect lines, and - breakpoints do not work as they are not detected at proper instructions.

I was wondering if anyone has a hint for any other options that we could try to switch to get this working. We've been fighting this a few months, and Microsoft Support requires you to pay 149 Eur just to file a bug.

enter image description here

adding debug windows modules and output:

enter image description here

enter image description here


Solution

  • It occurs to me I never posted an Answer to this. We both put some time and effort into this, so we deserve the karma from resolving it.

    Turns out that you weren't doing anything wrong. Despite my earliest comments, there was nothing wrong with what you were building or how you were building it, and there were no out of date files.

    The actual problem was that somewhere between 16.7.28 and 16.8.0, MS just broke this. When they wrote the debug information to the .obj and .pdb files, they just plain wrote the wrong information. So it wasn't the debugger's fault, it was the compiler.

    After I opened a bug against devstudio, they fixed it in 17.6.0.

    So, they broke it in November 2020, people started complaining about it in Mar 2021, I filed my bug in Jun 2022, and it was fixed in May 2023. Even allowing for the fact that the early bug reports didn't clearly identify the underlying problem, that's still not great turnaround.

    So in the end, the solution is to avoid any release greater than 16.7.28 and less than 17.6.0. Given that we're now up to 17.13.0, that's probably no longer an issue. But if any future SO readers end up here, at least they'll know what it was all about.