简体   繁体   中英

gdb launches but doesn't execute line by line

So I am trying to use GDB. I compile my code with -g , then gdb ./a.out

GNU gdb starts, but after I type r to start, the program runs like it normally would if I just called ./a.out .

Do you know what could cause this? I don't know much about gdb and I use it lightly , I've been using it the same way for a while and never encountered this type of behavior.

Edit: It works when I set up breakpoints. But I am still confused as to why I was able to use it for months without setting any breakpoints before.

Do you know what could cause this?

This is intended behavior. The run command starts the execution of the inferior (being debugged) program.

That program may encounter a bug (eg a crash), in which case GDB will be notified and would stop the execution of the inferior, and let you look around.

The program may also encounter a breakpoint that you have inserted earlier, again allowing you to look around at the current state.

Or the program may run to completion (if it doesn't execute any code in which you have set breakpoints, or if you didn't set any, and if it doesn't have any bugs that manifest in a fatal signal). If that happens, you'll get a 'program exited normally' message.

I am still confused as to why I was able to use it for months without setting any breakpoints before.

Your program was probably crashing, and now doesn't.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM