如何使用 GDB 调试从标准输入获取用户输入的程序? [英] How to debug a program that takes user input from stdin with GDB?
本文介绍了如何使用 GDB 调试从标准输入获取用户输入的程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个程序,我正在尝试使用 gdb 对其进行调试.在程序内部,我有一些方法要求用户使用标准输入输入.当我在 gdb 中时,如何输入此输入?这样我就可以追踪我的方法是如何工作的?
I have a program and I am trying to debug it using gdb. Inside the program I have methods that require the user to enter an input using stdin. How can I enter this input when I am in gdb? So that I can trace how my methods work?
推荐答案
$ cat >foo <<EOF
something
EOF
$ gdb -quiet /bin/cat
Reading symbols from /bin/cat...(no debugging symbols found)...done.
Missing separate debuginfos, use: debuginfo-install coreutils-8.12-7.fc16.x86_64
(gdb) run <foo
Starting program: /bin/cat <foo
something
[Inferior 1 (process 22436) exited normally]
(gdb)
这篇关于如何使用 GDB 调试从标准输入获取用户输入的程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文