如何加载程序读取标准输入并在 gdb 中取参数? [英] How to load program reading stdin and taking parameters in gdb?
问题描述
我有一个程序可以从stdin 并且还需要一些参数从命令行.它看起来像这样:
I have a program that takes input from stdin and also takes some parameters from command line. It looks like this:
cat input.txt > myprogram -path "/home/user/work"
我尝试用 gdb 调试代码在 emacs 中,通过 M-x gdb,我尝试使用以下命令加载程序:
I try to debug the code with gdb inside emacs, by M-x gdb, I try to load the program with the command:
gdb cat input.txt > myprogram -path "/home/user/work"
然而,gdb 不喜欢它.
However, gdb does not like it.
问题摘自此处.不幸的是,我不理解该解决方案,并且不知道除了使用 -g
选项进行编译并运行命令 M-x gdb 之外还能做什么.
Question cribbed from here.
Unfortunately I don't understand the solution and am not sure what to do beyond compiling with the -g
option and running the command M-x gdb.
推荐答案
如果你是从 shell 做的,你会这样做:
If you were doing it from a shell you'd do it like this:
% gdb myprogram
gdb> run params ... < input.txt
这似乎也适用于 emacs.
This seems to work within emacs too.
这篇关于如何加载程序读取标准输入并在 gdb 中取参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!