0

I need to debug a program that feeds on the output of another program. Hence, writing the output of the 'feeder' into a file, and piping that to the 'reader' doesn't work.

Normal run:

# feeder | ./reader

This is NOT an option here:

# feeder > data
# gdb ./reader
(gdb) run < data
Bgs
  • 196
  • 1
  • 7

1 Answers1

2

You can make the reader pause and wait for GDB to attach, as described here.

Then run:

feeder | ./reader

in one terminal, and gdb -p $(pgrep reader) in another terminal.

Once gdb is attached, let the reader proceed, and debug it normally.

Update:

Now that you've clarified your constraint, another way is to use named pipe:

mknod /tmp/.pipe p
feeder > /tmp/.pipe
gdb reader
(gdb) run < /tmp/.pipe
Employed Russian
  • 199,314
  • 34
  • 295
  • 362