I\'m trying to debug a Python CLI I wrote that can take its arguments from stdin. A simple test case would have the output of
echo \"test\" | python mytool.p
Another option is to create you own Pdb object, and set there the stdin and stdout. My proof of concept involves 2 terminals, but for sure some work can be merged some kind of very unsecure network server.
Create two fifos:
mkfifo fifo_stdin
mkfifo fifo_stdout
In one terminal, open stdout on background, and write to stdin:
cat fifo_stdout &
cat > fifo_stdin
import pdb
mypdb=pdb.Pdb(stdin=open('fifo_stdin','r'), stdout=open('fifo_stdout','w'))
...
mypdb.set_trace()
...
You should be able to use pdb on the first console.
The only drawback is having to use your custom pdb, but some monkey patching at init (PYTHONSTARTUP or similar) can help:
import pdb
mypdb=pdb.Pdb(stdin=open('fifo_stdin','r'), stdout=open('fifo_stdout','w'))
pdb.set_trace=mydbp.set_trace