Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
所以我正在尝试调试一个需要用户通过终端输入一些文本的程序:
$ echo 'here is the text' | ./program
如何在 GDB 中模拟该输入?
您可以使用重定向的输入运行程序:
echo 'here is the text' > intput.txt gdb ./program (gdb) run < intput.txt
您可以使用--args选项提供程序可执行文件,后跟如下参数,
--args
% gdb --args ./program arg1 arg2