我正在学习汇编语言。 我正在使用gdb来了解如何从编写的C代码中获取信息。 我试图在每行的开头看到rip寄存器,看看如何 许多字节的机器代码都在这个程序的每个C语句中? 谁能告诉我gdb中的命令才能找到这些命令?
#include <stdio.h>
int main(void) {
register int wye;
int *ptr;
int ex;
ptr = &ex;
ex = 305441741;
wye = -1;
printf("Enter an integer: ");
scanf("%i", ptr);
wye += *ptr;
printf("The result is %i\n", wye);
return 0;
}
答案 0 :(得分:1)
您可以查看有关程序的一些内容的简短示例。 $
是shell提示符,gdb>
是gdb提示符,因此请不要输入:
$ gdb myprogram
... info about gdb and myprogram
gdb> disas main
... disassembly of the main function
gdb> break main
... sets a breakpoint in main; you see a message about this probably calling it breakpoint 1
gdb> run
... program starts and stops immediately at the start of main
gdb> i r
... lots of info about register contents
gdb> p $rip
... current instruction pointer (assuming x86_64)
gdb> s
... program runs for one source line.
gdb> p $rip
... ip has advanced a bit.