0

I'm using GDB to debug a program I've written and I'm having issues with GDB syntax. The portion of the program I'm testing requires input piped from file (via cat command), so altering the arguments to remove the pipe and read directly from file would defeat the purpose of the test.

Here's the syntax for running the test in bash:

cat input.txt | ./program | cat > output.txt

Is there a way to do this? I've tried debugging both cat and my program, but haven't been able to get it to run the way I need inside of GDB.

3
  • this is simple IO redirection, you don't need pipes. Commented May 26, 2015 at 0:06
  • I realize that, but the purpose of the test is to ensure the program works with pipes. I could easily run the test in GDB using r in.txt > out.txt but that wouldn't test the pipe functionality. My code looks for the S_ISFIFO macro and executes a different function for it. Commented May 26, 2015 at 12:59
  • I figured it out. I used mkfifo to make the input file a pipe (as suggested in the linked question) and simply directed output to file as usual. I was trying to read AND write to different pipes and presumably GDB kept hanging because my program doesn't handle blocking I/O. Oops. Commented May 26, 2015 at 14:11

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.