Reputation: 14382
What is the best (quickest) way to view the code that the compiler generated from my files? I'm using mostly C++ but a solution that works for .NET languages would be very welcome as well.
Upvotes: 14
Views: 6094
Reputation: 52197
Within Visual Studio, go to the property pages for your project, then go to C/C++ → Output Files → Assembler Output
. It should look something like this:
Note the corresponding compiler switches, all variants of /FA
.
/FA
: Assembly-Only Listing/FAcs
: Assembly, Machine Code and Source/FAc
: Assembly With Machine Code/FAs
: Assembly With Source CodeUnderneath the "Assembler Output" option there's an "ASM List Location" option. This is equivalent to the /Fa
switch (note capitalization!), and it sets the file path of the output listing.
You can also look at the assembly while debugging (at a breakpoint), complete with the corresponding source code, by right-clicking the current line in the source file text area and clicking "Go To Disassembly".
It'll jump to the assembly at the line you right-clicked on in a separate tab. The listing will resemble this:
Yes I know, the screenshots are not from Visual Studio 2010 but the steps and the general appearance are the same. I just don't have immediate access to VS2010 to make screenshots with. :-)
Upvotes: 25
Reputation: 17951
For .NET you can use the ildasm
tool which comes with the framework to view the IL.
Upvotes: 1
Reputation: 355247
For a C++ project, compile with /FA
to get an assembly listing.
For .NET assemblies, there's ildasm
.
Upvotes: 7