How can I see the assembly code for a C++ program?
What are the popular tools to do this?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Ask the compiler
If you are building the program yourself, you can ask your compiler to emit assembly source. For most UNIX compilers use the
-Sswitch.If you are using the GNU assembler, compiling with
-g -Wa,-alhwill give intermixed source and assembly on stdout (-Waasks compiler driver to pass options to assembler,-alturns on assembly listing, and-ahadds "high-level source" listing):g++ -g -c -Wa,-alh foo.ccFor Visual Studio, use
/FAsc.Peek into a binary
If you have a compiled binary,
objdump -d a.outon UNIX (also works for cygwin),dumpbin /DISASM foo.exeon Windows.Use your debugger
Debuggers could also show disassembly.
disascommand in GDB.Use
set disassembly-flavor intelif you prefer Intel syntax.