[英]"step" not ending program at the end of program, but it ending it after 5 more "step"
I am using Windows 10. I wrote a HelloWorld program in C.我使用的是 Windows 10。我用 C 编写了一个 HelloWorld 程序。
#include <stdio.h>
int main()
{
printf("Hello World\n");
return 0;
}
I compiled this with cmd with the following command我用 cmd 用以下命令编译了这个
gcc -g -o HelloWorld HelloWorld.c
In gdb, I write start
.在 gdb 中,我写了
start
。 And I typed step
quite a few times.我打了好几次
step
。 At some point it prints在某些时候它会打印
(gdb) step
7 }
Then I typed step
again.然后我再次输入
step
。 It prints它打印
(gdb) step
__tmainCRTStartup () at C:/crossdev/src/mingw-w64-v4-git/mingw-w64-crt/crt/crtexe.c:334
334 C:/crossdev/src/mingw-w64-v4-git/mingw-w64-crt/crt/crtexe.c: No such file or directory.
After another step it prints另一个步骤后,它打印
332 in C:/crossdev/src/mingw-w64-v4-git/mingw-w64-crt/crt/crtexe.c
After that it prints above line every time I wrote step
.之后,每次我写
step
时它都会打印在上面的行。 And eventually sometime it printed最终它打印出来
[Thread 1952.0x1628 exited with code 0]
[Inferior 1 (process 1952) exited normally]
I want to know, what I have done wrong that causes the problem.我想知道,我做错了什么导致了问题。
“step” not ending program at the end of program
在程序结束时“step”不结束程序
The problem is that your notion of where your program begins and ends is quite wrong: your program executes 100s or 1000s of instructions before it reaches main
, and 100s or 1000s more after main
returns.问题是您对程序开始和结束位置的看法是完全错误的:您的程序在到达
main
之前执行了 100 或 1000 条指令,而在main
返回后又执行了 100 或 1000 条指令。
These instructions are part of C runtime startup and shutdown.这些指令是 C 运行时启动和关闭的一部分。 Usually you are not interested in debugging there, but developers of the C runtime do need to debug it, and the debugger doesn't know whether you want to or not.
通常您对在那里调试不感兴趣,但 C 运行时的开发人员确实需要对其进行调试,而调试器不知道您是否愿意。
Can you tell me how i can tell gdb to debug only my code.
你能告诉我如何告诉 gdb 只调试我的代码。
GDB doesn't know which code is your own, and which isn't (and I don't believe there is a way to tell it). GDB不知道哪些代码是你自己的,哪些不是(我不相信有办法告诉它)。
If you don't want to debug past the end of main
, then don't ask GDB to do so: once you reach the end of "your code", use continue
instead of step
.如果您不想调试超过
main
的结尾,则不要要求 GDB 这样做:一旦到达“您的代码”的末尾,请使用continue
而不是step
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.