Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GDB Switch Between Debugging and Program Input

Tags:

debugging

gdb

So I'm trying to debug a program that takes user input through the terminal. I'm using the GNU Debugger (gdb) to do so. When I reach the point where the program is waiting for user input it no longer allows me to control gdb and instead forces me to give input to the program.

The difficulty is, I want to debug the program at this exact point, but before there is any input given. So how do I switch between giving input to the program and controlling gdb? I've tried googling and searching through the manual for gdb but can't seem to find anything on switching between input to the program and input to gdb.

like image 345
Ian Avatar asked Aug 23 '26 10:08

Ian


1 Answers

When I reach the point where the program is waiting for user input it no longer allows me to control gdb and instead forces me to give input to the program.

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.

like image 164
Employed Russian Avatar answered Aug 26 '26 23:08

Employed Russian



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!