Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/60.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
需要在我的C程序中使用gdb的帮助吗_C_Assembly - Fatal编程技术网

需要在我的C程序中使用gdb的帮助吗

需要在我的C程序中使用gdb的帮助吗,c,assembly,C,Assembly,我正在学习汇编语言。 我正在使用gdb学习如何从编写的C代码中获取信息。 我试图在每行的开头看到rip寄存器,并了解如何使用它 这个程序中的每个C语句中都有许多字节的机器代码? 有人能告诉我gdb中的命令来查找这些吗 #include <stdio.h> int main(void) { register int wye; int *ptr; int ex; ptr = &ex; ex = 305441741; wye =

我正在学习汇编语言。 我正在使用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;
}
#包括
内部主(空){
寄存器int wye;
int*ptr;
int-ex;
ptr=&ex;
ex=305441741;
Y型=-1;
printf(“输入一个整数:”);
scanf(“%i”,ptr);
Y形三通+=*ptr;
printf(“结果是%i\n”,wye);
返回0;
}

你可以做一些简单的例子来了解你的程序
$
是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.

看看register
i r
info register
的值,“每个C语句中有多少字节的机器代码”-->我怀疑GDB是否显示了这一点,但这可能是因为我不知道该命令。还有一种可能是,由于优化,某些语句没有出现在编译后的代码中。