如何使用inputredirect的gdb?

在terminal,我有

myapp < myfileinput 

但是如果我想用gdb,

  gdb myapp < myfileinput 

它没有正确运行。

如何在这里使用gdb?

 ~$ 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 

这是为我做的伎俩。 想知道这是你在找什么。

尝试从gdb内运行你的应用程序?

 (gdb) file /usr/bin/head Reading symbols from /usr/bin/head...(no debugging symbols found)...done. (gdb) run -2 < /etc/passwd Starting program: /usr/bin/head -2 < /etc/passwd root:x:0:0:root:/root:/bin/bash daemon:x:1:1:daemon:/usr/sbin:/bin/sh Program exited normally. (gdb) 

编辑:或者:

 gdb -q -ex 'set args -2 < /etc/passwd' /usr/bin/head Reading symbols from /usr/bin/head...done. (gdb) run root:x:0:0:root:/root:/bin/bash daemon:x:1:1:daemon:/usr/sbin:/bin/sh Program exited normally. (gdb) quit 

你可以试试这个

(gdb)运行<input.txt