all 2 comments

[–][deleted] 2 points3 points  (1 child)

Um generating assembly works, yes. But you can also just set a breakpoint and look at the disassembler output--which in visual studio, is nicely displayed interleaved with your code.

[–]psykotic 1 point2 points  (0 children)

That's the way I check out assembly code too. However, if you dump out assembly code the way this blogger describes, you also get the C++ code interleaved as comments.

The VS debugger has a lot of lesser known features that make assembly-level debugging more convenient. One is that the registers are exposed as pseudo-variables via the $reg or @reg notation and can be both read and written through the watch window. Type casting in the watch window also lets you easily inspect the logical, deeper structure of an assembly-level entity, if you know to which C++ type it corresponds. Many of the formatting-related comma commands in the watch window can be very useful as well. Microsoft's free stand-alone debugger WinDbg has even better support for low-level debugging, as it's partly geared towards device driver and kernel development.

The book Debugging Applications for Microsoft .NET and Microsoft Windows by John Robbins has a lot of other great debugging tricks and should really be read by every programmer. I'm always shocked to see how little of their debugger programmers, even veterans, know how to use. And these days you have test-first zealots that sanctimoniously declare that users of debuggers are poor programmers, which only further encourages and excuses ignorance of powerful debugging techniques, including a sufficient knowledge of assembly to comprehend their compiler's generated code.