如何查看 C++ 程序的汇编代码?
How can I see the assembly code for a C++ program?
有哪些流行的工具可以做到这一点?
What are the popular tools to do this?
如果您自己构建程序,您可以要求您的编译器发出汇编源代码.对于大多数 UNIX 编译器,使用 -S 开关.
如果您使用的是 GNU 汇编程序,则使用 -g -Wa,-alh 进行编译将在标准输出上提供混合的源代码和程序集(-Wa 询问编译器驱动程序将选项传递给汇编程序,-al 打开汇编列表,-ah 添加高级源代码"列表):
If you are using the GNU assembler, compiling with -g -Wa,-alh will give intermixed source and assembly on stdout (-Wa asks compiler driver to pass options to assembler, -al turns on assembly listing, and -ah adds "high-level source" listing):
g++ -g -c -Wa,-alh foo.cc
对于 Visual Studio,使用 /FAsc代码>.
For Visual Studio, use /FAsc.
如果你有一个编译好的二进制文件,
If you have a compiled binary,
objdump -d a.out(也适用于 cygwin),dumpbin/DISASM foo.exe 在 Windows 上.objdump -d a.out on UNIX (also works for cygwin),dumpbin /DISASM foo.exe on Windows.调试器还可以显示反汇编.
Debuggers could also show disassembly.
disas 命令.set disassembly-flavor intel.disas command in GDB.set disassembly-flavor intel if you prefer Intel syntax.这篇关于如何查看 C++ 程序的汇编代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
当没有异常时,C++ 异常会以何种方式减慢代码速In what ways do C++ exceptions slow down code when there are no exceptions thown?(当没有异常时,C++ 异常会以何种方式减慢代码速度?)
为什么要捕获异常作为对 const 的引用?Why catch an exception as reference-to-const?(为什么要捕获异常作为对 const 的引用?)
我应该何时以及如何使用异常处理?When and how should I use exception handling?(我应该何时以及如何使用异常处理?)
C++中异常对象的范围Scope of exception object in C++(C++中异常对象的范围)
从构造函数的初始化列表中捕获异常Catching exceptions from a constructor#39;s initializer list(从构造函数的初始化列表中捕获异常)
C++03 throw() 说明符 C++11 noexcept 之间的区别Difference between C++03 throw() specifier C++11 noexcept(C++03 throw() 说明符 C++11 noexcept 之间的区别)