简体   繁体   中英

How can I see the assembly code that is generated by a gcc (any flavor) compiler for a C/C++ program?

I am trying to optimize a lot of multiplications and pointer arithmetics and would like to see what the compiler does underneath when I put in optimization flags.

--Edit--

How to restrict it to a specific function or a code block?

--Edit_2--

How to let gcc generate a less verbose assembly-code?

Add -S switch to your command line.

Edit: Do not forget that it will place the assembly to the files you specified under -o switch.

How to restrict it to a specific function or a code block?

Put that function in a separate source file (and use a different command-line parameter for that one source file).

You could also run that program in a debugger like gdb and use a disassembly view. In gdb you could use the command disass/m to view the assembly mixed with the C code on the current location.

您可以停止在Visual Studio调试器中的断点处编程并执行“显示汇编”,甚至一次一步地执行它。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM