Saturday, February 22, 2014

using gdb with unix pipe ./lexer | ./parser

The normal command line arg won't work because there is nowhere to insert the gdb command. You can try ./lexer  | gdb parser but this isn't the same as sending the output of the lexer to the debugger.

Tricky solution:
Have to create a temp file to serve as the output of the lexer command and have linux block on this command. Then create a separate process to read from the temp file from inside the debugger.

mkfifo foo
After you created a fifo, run from bash:
The above process should block.    
gdb parser
Then, in gdb prompt, run
And you should see an error message:
Starting program: /usr/class/cs143/cool/assignments/PA3/parser dump_with_types(cout,0);

This is much better than "Segmentation Fault" from the command line when you run ./lexer | ./parser

No comments:

Post a Comment