所以我正在尝试调试一个通过终端接收用户输入的程序。我正在使用 GNU 调试器 (gdb) 来执行此操作。当我到达程序等待用户输入的点时,它不再允许我控制 gdb,而是强制我向程序提供输入。
困难是,我想在这个确切的点调试程序,但在给出任何输入之前。那么如何在向程序提供输入和控制 gdb 之间切换呢?我试过谷歌搜索并搜索 gdb 的手册,但似乎无法在程序输入和 gdb 输入之间切换时找到任何内容。
当我到达程序等待用户输入的点时,它不再允许我控制 gdb,而是强制我向程序提供输入。
If you hit Control-C at that point, the inferior (being debugged) program should get interrupted, you should get a (gdb) prompt, and you should be able to control GDB all you want.
Once you are done, use continue GDB command to go back and resume the inferior reading its input.