默认情况下,程序的标准输出在gdb窗口。 有时候这样调试会比较麻烦。
gdb提供了重定向的方法。
4.1 GDB
Start up GDB as usual in some text window. Then choose another window in which your curses application
will run, and determine the device name for that latter window (which we will call the “execution
window”). To do this, run the Unix tty command in that window. Let’s suppose for example that the output
of the command is “/dev/pts/10”. Then within GDB issue the command
(gdb) tty /dev/pts/10
We must then do one more thing before issuing the run command to GDB. Go to the execution window,
and type
sleep 10000
Unix’s sleep command has the shell go inactive for the given amount of time, in this example 10,000
seconds. This is needed so that any input we type in that window will be sure to go to our pro

在调试使用ncurses的程序时,gdb和DDD提供了重定向标准输出到另一个终端窗口的功能。在gdb中,可以通过`tty /dev/pts/10`命令指定执行窗口,并用`sleep 10000`确保输入被程序接收。在DDD中,只需点击`View | Execution Window`即可自动创建执行窗口。调试完成后,注意可能需要在执行窗口使用`reset`命令恢复终端设置。


被折叠的 条评论
为什么被折叠?



