且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在没有断点的情况下停止在GDB中执行?

更新时间:2021-09-21 01:20:37

只需使用常规中断 Ctrl - c 即可正常工作. GDB只是将SIGINT转发到调试过程,然后调试过程终止. GDB将捕获非标准出口并在那里中断进程,因此您仍然可以检查所有线程,它们的堆栈和变量的当前值.这可以很好地工作,尽管使用断点会更好.我发现自己这样做的唯一机会是,如果我认为自己陷入了某种无限循环.

Just use a regular interrupt Ctrl-c will work just fine. GDB just forwards the SIGINT to the debugging process which then dies. GDB will catch the non-standard exit and break the process there, so you can still examine all the threads, their stacks and current values of variables. This works fine, though you would be better off using break points. The only time I find myself doing this is, if I think I've gotten into some sort of infinite loop.