我怎样才能看到大会code的C ++程序? [英] How can I see the assembly code for a C++ program?
问题描述
我怎么能看到大会code的C ++程序?
How can I see the assembly code for a C++ program?
什么是流行的工具来做到这一点?
What are the popular tools to do this?
推荐答案
如果您正在构建自己的程序,你可以问问你的编译器生成汇编源。对于大多数UNIX编译器使用 -S
开关。
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 -S
switch.
-
如果您使用的是GNU汇编器,用
-g -Wa,-alh
编译会给混杂源和装配在stdout(-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 compiled binary,
- 使用
objdump的-d的a.out
在UNIX(也适用于Cygwin的), -
DUMPBIN / DISASM foo.exe的
一>在Windows上。
- use
objdump -d a.out
on UNIX (also works for cygwin), dumpbin /DISASM foo.exe
on Windows.
也调试器可以显示disassebly。
Debuggers could also show disassebly.
- 使用
disas
命令, - 或Windows上的分解窗口。
在GDB
- Use
disas
command in GDB, - or the disassembly window of Visual Studio on Windows.
这篇关于我怎样才能看到大会code的C ++程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!