我怎样才能看到大会code的C ++程序? [英] How can I see the assembly code for a C++ program?

查看:108
本文介绍了我怎样才能看到大会code的C ++程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎么能看到大会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,

  • use objdump -d a.out on UNIX (also works for cygwin),
  • dumpbin /DISASM foo.exe on Windows.

也调试器可以显示disassebly。

Debuggers could also show disassebly.

  • Use disas command in GDB,
  • or the disassembly window of Visual Studio on Windows.

这篇关于我怎样才能看到大会code的C ++程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆