问题描述
如何运行 GDB
,同时允许从命令行交互输入字符,同时打印从这些条目解析的字符产生的变量的值?
How do you run GDB
while allowing interactive entry of characters from the command line while simultaneosuly "printing" the values of the variables arising from the parsed characters from those entries?
换句话说,如何运行gdb,在命令行中输入文本,看看可执行文件如何处理这些条目?
In other words how do I run gdb, enter text into the command line AND see how the executable treats those entries?
如果我在Emacs中使用 Mx gdb
运行它,gdb的行为也有什么不同?使用 C-c C-c
暂停可执行文件,然后尝试打印变量值的行为不符合我的预期。它似乎没有识别来自被调试的挂起可执行文件的有效变量值。我确实从 Clang
和 -ggdb -O0
标志生成了一个可调试的可执行文件。
Also is there any difference in the behavior of gdb if I run it from within Emacs with M-x gdb
? Suspending the executable with C-c C-c
and then trying to print variable values does not behave like I expected. It did not seem to recognize valid variable values from the suspended executable being debugged. I did generate a "debuggable" excutable from Clang
with -ggdb -O0
flags.
我也试图链接gdb到程序可执行文件的pid运行在一个单独的终端,但仍然有困难。程序需要交互地解析命令行条目;我不能将它们作为初始命令行参数传递。
I also tried to link gdb to the pid of the program executable running in a separate terminal but still am having difficulty with it. The program needs to parse command line entries interactively; I cannot pass them as initial command line arguments.
我希望我的问题清楚。
推荐答案
在启动Mx gdb后,输入Mx gdb-many-windows。这将打开你的框架中的新窗口,显示堆栈,断点,本地,你的代码和程序的I / O,意味着如果你输入将输入将被给予你的可执行文件。
After you started M-x gdb enter M-x gdb-many-windows . This opens new windows in your frame which show the stack, breakpoints, locals, your code and I/O of your program, meaning if you type there the input will be given to your executable.
这篇关于如何运行GDB,在命令行中输入文本,看看可执行文件如何处理这些条目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!