38

在 gdb 中调试 C 或 C++ 程序时,有什么方法可以切换到汇编?(假设所有源文件及其对应的汇编文件都可用)

4

5 回答 5

67

您可以在 gdb 中切换到 asm 布局:

(gdb) layout asm

请参阅此处了解更多信息。

于 2010-01-06T19:15:40.030 回答
24

有一种方法可以反汇编一个函数或一段代码,这就是你所追求的吗?

执行此操作的命令将是disassemble <function name>或内存位置。

这是你指的吗?

(gdb) help disassemble
Disassemble a specified section of memory.
Default is the function surrounding the pc of the selected frame.
With a single argument, the function surrounding that address is dumped.
Two arguments are taken as a range of memory to dump.
于 2009-02-26T08:39:49.867 回答
11

在新的 gdb 版本 7.0 中,该disassemble命令可以采用一个新参数/m,使其发出混合的源代码和反汇编。

于 2009-10-28T20:07:24.123 回答
4

使用 disas 命令可能会做你想做的事。

根据内部帮助,disas 命令执行以下操作:

Disassemble a specified section of memory.
Default is the function surrounding the pc of the selected frame.
With a single argument, the function surrounding that address is dumped.
Two arguments are taken as a range of memory to dump.
于 2009-02-26T08:45:42.427 回答
1

在 cgdb 的 googlegroup https://groups.google.com/forum/?hl=de&fromgroups=#!topic/cgdb-users/E-jZCJiBAQQ中也提出了这个问题

虽然布局 asm 不起作用,但还没有答案

编辑:他们最近发布并告诉它是一个尚未实现的功能。(检查上面的链接)

于 2012-11-15T14:17:49.370 回答