How to use gdb with input redirection?

user53670 picture user53670 · Jan 21, 2011 · Viewed 51.2k times · Source

In the Terminal, I have:

myapp < myfileinput

But if I want to use gdb,

gdb myapp < myfileinput

It didn't run correctly.

How to use gdb here?

Answer

Abhishek picture Abhishek · Nov 8, 2012
~$ gdb <executable>

GNU gdb (Ubuntu/Linaro 7.3-0ubuntu2) 7.3-2011.08
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-linux-gnu".
For bug reporting instructions, please see:
<http://bugs.launchpad.net/gdb-linaro/>...
Reading symbols from /home/abhishek/maxtest...done.

(gdb) run < input.txt

This is doing the trick for me. Wondering if this was what you were looking for.