2
votes

So I want to run a program in gdb with the contents of a file as an argument. Then, when an EOF is hit, I want to be able to enter user input again. For a normal program in a terminal I can do something like this with the following command.

(cat input.txt; cat) | ./program

In gdb I can pass in the file arguments like this, but it continues to enter newlines forever after the end of the file has been reached.

(gdb) run < input.txt

It is almost as if stdin was not passed back to the program, similar to what happens if I simply do

(cat input.txt) | ./program

without the second cat. Is this even possible to do in gdb?

1

1 Answers

1
votes

You can run the program in one console and attach to it with gdb from another one when it is waiting for input. Therefore you will be able to enter program input in the 1st console and debug it in the 2nd.